import java.awt.*; import oracle.jdeveloper.layout.*; import java.awt.event.*; import java.io.*; import java.util.*; public class GUIFrame extends Frame { Label DBConnectionURL = new Label(); Label UserName = new Label(); Label PassWord = new Label(); Label DriverClassName = new Label(); Label InitialConnections = new Label(); Label Increment = new Label(); TextField tf_DBConnectionURL = new TextField("",20); TextField tf_UserName = new TextField("",20); TextField tf_PassWord = new TextField("",20); TextField tf_DriverClassName = new TextField("",20); TextField tf_InitialConnections = new TextField("",20); TextField tf_Increment = new TextField("",20); Button Update = new Button(); Button Cancel = new Button(); GridBagLayout gridBagLayout1 = new GridBagLayout(); Properties p_values=new Properties(); public GUIFrame() { super(); try { jbInit(); } catch (Exception e) { e.printStackTrace(); } } private void jbInit() throws Exception { this.setTitle("Frame Title"); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowActivated(WindowEvent e) { this_windowActivated(e); } }); DBConnectionURL.setText(" DBConnectionURL"); UserName.setText(" UserName"); PassWord.setText(" PassWord"); DriverClassName.setText(" DriverClassName"); InitialConnections.setText(" InitialConnections"); Increment.setText(" Increment"); tf_DBConnectionURL.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tf_DBConnectionURL_actionPerformed(e); } }); Update.setLabel("Update"); Update.addActionListener(new GUIFrame_Update_actionAdapter(this)); Cancel.setLabel("Cancel"); Cancel.addActionListener(new GUIFrame_Cancel_actionAdapter(this)); tf_Increment.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { tf_Increment_actionPerformed(e); } }); this.setLayout(gridBagLayout1); this.setSize(new Dimension(400, 414)); this.setBackground(SystemColor.control); this.add(DBConnectionURL, new GridBagConstraints2(0, 0, 5, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(72, 1, 0, 0), 0, 0)); this.add(UserName, new GridBagConstraints2(0, 2, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(12, 1, 0, 0), 19, 3)); this.add(PassWord, new GridBagConstraints2(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(18, 1, 0, 0), -3, 0)); this.add(DriverClassName, new GridBagConstraints2(0, 5, 4, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(15, 1, 0, 0), -8, -5)); this.add(InitialConnections, new GridBagConstraints2(0, 7, 4, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(18, 1, 0, 0), -4, -8)); this.add(Increment, new GridBagConstraints2(0, 9, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(8, 1, 0, 0), 18, -2)); this.add(tf_DBConnectionURL, new GridBagConstraints2(5, 0, 3, 2, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(72, 60, 0, 0), 139, 8)); this.add(tf_UserName, new GridBagConstraints2(5, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, 70, 0, 0), 139, 5)); this.add(tf_PassWord, new GridBagConstraints2(5, 3, 3, 2, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(20, 67, 0, 0), 142, 4)); this.add(tf_DriverClassName, new GridBagConstraints2(5, 5, 3, 2, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(16, 66, 0, 0), 143, 8)); this.add(tf_InitialConnections, new GridBagConstraints2(5, 7, 3, 2, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(19, 66, 0, 0), 143, 6)); this.add(tf_Increment, new GridBagConstraints2(5, 9, 3, 2, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(13, 64, 0, -3), 148, 8)); this.add(Update, new GridBagConstraints2(4, 11, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(40, 6, 13, 0), 52, 8)); this.add(Cancel, new GridBagConstraints2(6, 11, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(40, 25, 14, 0), 55, 7)); } void tf_Increment_actionPerformed(ActionEvent e) { } void Cancel_actionPerformed(ActionEvent e) { System.exit(0); } void Update_actionPerformed(ActionEvent e) { String s_DBCon,s_UName,s_PWord,s_DClassName,s_InitCon,s_Incr; /* if( tf_DBConnectionURL.getText() ||tf_UserName.getText() ||tf_PassWord.getText() ||tf_DriverClassName.getText() ||tf_InitialConnections.getText() ||tf_Increment.getText()==null) { System.out.println("Error");} */ try{ p_values.put("DBConURL",tf_DBConnectionURL.getText()); p_values.put("UName",tf_UserName.getText()); p_values.put("PWord",tf_PassWord.getText()); p_values.put("DClassName",tf_DriverClassName.getText()); p_values.put("InitCon",tf_InitialConnections.getText()); p_values.put("Incr",tf_Increment.getText()); FileOutputStream fos=new FileOutputStream("DBProperties.props"); ObjectOutputStream ostrm=new ObjectOutputStream(fos); ostrm.writeObject(p_values); p_values.save(System.out,"Saved"); System.out.println(""+tf_UserName.getText()); System.out.println(""+p_values.getProperty("UserName")); } catch(Exception ex){System.out.println(""+ex);} } void this_windowActivated(WindowEvent e) { try{ FileInputStream fis=new FileInputStream("DBProperties.props"); ObjectInputStream istrm=new ObjectInputStream(fis); Properties p=new Properties(); p=(Properties)istrm.readObject(); tf_DBConnectionURL.setText(p.getProperty("DBConURL")); tf_UserName.setText(p.getProperty("UName")); tf_PassWord.setText(p.getProperty("PWord")); tf_DriverClassName.setText(p.getProperty("DClassName")); tf_InitialConnections.setText(p.getProperty("InitCon")); tf_Increment.setText(p.getProperty("Incr")); } catch(Exception exp){System.out.println(""+exp);} System.out.println(""+tf_UserName.getText()); } void tf_DBConnectionURL_actionPerformed(ActionEvent e) { } } class GUIFrame_Cancel_actionAdapter implements java.awt.event.ActionListener { GUIFrame adaptee; GUIFrame_Cancel_actionAdapter(GUIFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.Cancel_actionPerformed(e); } } class GUIFrame_Update_actionAdapter implements java.awt.event.ActionListener { GUIFrame adaptee; GUIFrame_Update_actionAdapter(GUIFrame adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.Update_actionPerformed(e); } }