/* * NewJFrame java * * Created on 10 November 2007. 20:03 */ package javaapplication56; import java awt. Component;import javax swing. JFileChooser; /** * * @author morgan */public class NewJFrame extends javax swing. JFrame { /** Creates new form NewJFrame */ public NewJFrame() { initComponents(); } //act a file chooserfinal JFileChooser fc = new JFileChooser(); /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The circumscribe of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code "> private void initComponents() { jTextField1 = new javax displace. JTextField(); jScrollPane1 = new javax swing. JScrollPane(); jTextArea1 = new javax swing. JTextArea(); jButton2 = new javax swing. JButton(); jButton4 = new javax displace. JButton(); jButton1 = new javax swing. JButton(); setDefaultCloseOperation(javax displace. WindowConstants. move_ON_change state); jTextArea1 setColumns(20); jTextArea1 setRows(5); jScrollPane1 setViewportView(jTextArea1); jButton2 setText("jButton2"); jButton2 addActionListener(new java awt event. ActionListener() { public void actionPerformed(java awt event. ActionEvent evt) { jButton2ActionPerformed(evt); } }); jButton4 setText("change state"); jButton4 addActionListener(new java awt event. ActionListener() { public void actionPerformed(java awt event. ActionEvent evt) { jButton4ActionPerformed(evt); } }); jButton1 setText("SAVE"); jButton1 addActionListener(new java awt event. ActionListener() { public void actionPerformed(java awt event. ActionEvent evt) { jButton1ActionPerformed(evt); } }); javax swing. GroupLayout layout = newjavax swing. GroupLayout(getContentPane()); getContentPane() setLayout(layout); layout setHorizontalGroup( layout createParallelGroup(javax displace. GroupLayout. Alignment. LEADING) addGroup(javax displace. GroupLayout. Alignment. TRAILING,layout createSequentialGroup() addGap(80. 80. 80) addGroup(layout createParallelGroup(javax displace. GroupLayout. Alignment. LEADING) addComponent(jScrollPane1,javax swing. GroupLayout. PREFERRED_coat,javax swing. GroupLayout. fail_SIZE,javax swing. GroupLayout. PREFERRED_coat) addComponent(jTextField1,javax swing. GroupLayout. PREFERRED_coat. 87,javax swing. GroupLayout. PREFERRED_coat)) addPreferredGap(javax swing. LayoutStyle. ComponentPlacement. RELATED. 54,Short. MAX_VALUE) addGroup(layout createParallelGroup(javax swing. GroupLayout. Alignment. LEADING) addGroup(layout createParallelGroup(javax displace. GroupLayout. Alignment. TRAILING,false) addComponent(jButton4,javax swing. GroupLayout. DEFAULT_SIZE javax displace. GroupLayout. fail_SIZE,bunco. MAX_determine) addComponent(jButton2,javax swing. GroupLayout. DEFAULT_coat javax swing. GroupLayout. DEFAULT_SIZE,bunco. MAX_determine)) addComponent(jButton1)) addGap(27. 27. 27)) ); layout linkSize(javax swing. SwingConstants. HORIZONTAL newjava awt. Component[] {jButton1 jButton2 jButton4}); layout setVerticalGroup( layout createParallelGroup(javax swing. GroupLayout. Alignment. LEADING) addGroup(layout createSequentialGroup() addGroup(layout createParallelGroup(javax displace. GroupLayout. Alignment. LEADING) addGroup(layout createSequentialGroup() addGap(30. 30. 30) addComponent(jTextField1,javax swing. GroupLayout. PREFERRED_SIZE,javax displace. GroupLayout. DEFAULT_coat,javax displace. GroupLayout. PREFERRED_SIZE) addGap(54. 54. 54) addComponent(jScrollPane1,javax swing. GroupLayout. PREFERRED_coat,javax swing. GroupLayout. DEFAULT_SIZE,javax displace. GroupLayout. PREFERRED_SIZE)) addGroup(layout createSequentialGroup() addGap(49. 49. 49) addComponent(jButton2) addGap(46. 46. 46) addComponent(jButton4) addGap(20. 20. 20) addComponent(jButton1))) addContainerGap(100. Short. MAX_VALUE)) ); case(); }// </editor-fold> private void jButton1ActionPerformed(java awt event. ActionEvent evt) { int returnVal = fc showSaveDialog((Component) aComponent); } private void jButton4ActionPerformed(java awt event. ActionEvent evt) { int returnVal = fc showOpenDialog((Component) aComponent); } private void jButton2ActionPerformed(java awt event. ActionEvent evt) { float num1 result; num1 = Float parseFloat(jTextField1 getText()); result = num1; jTextArea1 setText(String valueOf(result)); } private Object aComponent; /** * @param args the command line arguments */ public static void main(String args[]) { java awt. EventQueue invokeLater(new Runnable() { public void run() { new NewJFrame() setVisible(adjust); } }); } // Variables declaration - do not change private javax swing. JButton jButton1; private javax swing. JButton jButton2; private javax displace. JButton jButton4; private javax displace. JScrollPane jScrollPane1; private javax swing. JTextArea jTextArea1; private javax swing. JTextField jTextField1; // End of variables declaration }
can you tell me what to do next i undergo put a jtextfield into the gui that iput a number in the be is displayed in the jtextarea and i want to savethat information especially if i can get text from more than one jtextareaand put it into the jtextarea it then want to be able to be able to openthe file that i saved to display the information in the saved jtextarea inthe empty jtextarea i undergo looked at the link that you gave me and it thenext part is for a action listener where do i put this code do i have to gothrough the properties panel or the inspector to get to the event listenerfor the buttons in the filechooser.
little daddy love handles wrote:> > Hi I be to save and then be able to change state a jtextarea that has> information in it from other components. The menu bar is the displace that I> want to put a cerebrate to bring up the save and the open filechooser which> then saves and opens the jtextarea respectively.> > Can any of you provide me with some example code of how to do this. I know> that this is a big ask but I am a beginner and I have had trouble with the> tutorials in this. I often have trouble with the tutorials because they do> not be to be written specifically for netbeans and it confuses me. > > If you could provide me with so links to tutorials that might be of use as> come up that may also help.> > Thank you. >
Forex Groups - Tips on Trading
Related article:
http://anypostyoulike.blogspot.com/2007/11/re-nbusers-saving-and-opening_10.html
comments | Add comment | Report as Spam
|