import java.awt.*; import java.awt.event.*; import java.util.*; import java.io.*; public class FileMgrServer extends Frame implements ActionListener,WindowListener { BorderLayout borderLayout1 = new BorderLayout(); Label l_Path = new Label("Path"); Label l_Sent = new Label("Sent Folder"); Label l_InBox = new Label("InBox Folder"); Label l_OffLine = new Label("OffLine Folder"); TextField tf_Path = new TextField("",20); TextField tf_Sent = new TextField("",20); TextField tf_InBox = new TextField("",20); TextField tf_OffLine = new TextField("",20); Button b_Browse=new Button("Browse"); Button b_Update = new Button("Update"); Button b_Cancel = new Button("Cancel"); Button b1 ;//= new Button("b1"); Button b2; //= new Button("b2"); Button b3; //= new Button("b3"); Button b4 ;//= new Button("b4"); Panel p=new Panel(); Properties props =new Properties(); GridLayout gridLayout1 = new GridLayout(5,0); public FileMgrServer() { super(); try { p.setLayout(gridLayout1); jbInit(); } catch (Exception e) { e.printStackTrace(); } } public Insets getInsets() { return new Insets(200,200,200,200); } private void jbInit() throws Exception { this.setTitle("File Manager Server"); this.setLayout(borderLayout1); this.setSize(new Dimension(800, 800)); this.setBackground(SystemColor.control); this.setResizable(false); this.add(p,"Center"); b1 = new Button("b1"); b2 = new Button("b2"); b3 = new Button("b3"); b4= new Button("b4"); //p.setLayout(gridLayout1); p.setBackground(SystemColor.control); p.add(l_Path); p.add(tf_Path); //b1.setVisible(false); p.add(b_Browse); p.add(l_Sent); p.add(tf_Sent); p.add(b1); b1.setVisible(false); // b3.setVisible(false); p.add(l_InBox); add(tf_InBox); p.add(b2); p.add(l_OffLine); p.add(tf_OffLine); p.add(b3); p.add(b_Update); p.add(b_Cancel); p.add(b4); this.addWindowListener(this); b_Browse.addActionListener(this); b_Update.addActionListener(this); b_Cancel.addActionListener(this); } public void actionPerformed(ActionEvent evt) { String arg=evt.getActionCommand(); if(arg=="Browse") { FileDialog FD=new FileDialog(this,"File Dialog Box"); FD.show(); tf_Path.setText(FD.getFile()); } else if( arg=="Update") { try{ props.put("Path",tf_Path.getText()); props.put("SFN",tf_Sent.getText()); props.put("IFN",tf_InBox.getText()); props.put("OFN",tf_OffLine.getText()); // props.put("InitCon",tf_InitialConnections.getText()); //props.put("Incr",tf_Increment.getText()); FileOutputStream fos=new FileOutputStream("FMProperties.props"); ObjectOutputStream ostrm=new ObjectOutputStream(fos); ostrm.writeObject(props); props.save(System.out,"Saved"); System.out.println(""+tf_Path.getText()); System.out.println(""+props.getProperty("Path")); } catch(Exception ex){System.out.println(""+ex);} } else if(arg=="Cancel") { System.exit(0); } } public void windowActivated(WindowEvent e) { try{ FileInputStream fis=new FileInputStream("FMProperties.props"); ObjectInputStream istrm=new ObjectInputStream(fis); Properties p=new Properties(); p=(Properties)istrm.readObject(); tf_Path.setText(p.getProperty("Path")); tf_Sent.setText(p.getProperty("SFN")); tf_InBox.setText(p.getProperty("IFN")); tf_OffLine.setText(p.getProperty("OFN")); } catch(Exception exp){System.out.println(""+exp);} System.out.println(""+tf_Path.getText()); } public void windowClosing(WindowEvent e) { System.exit(0); } public void windowDeactivated(WindowEvent e){} public void windowClosed(WindowEvent e){} public void windowIconified(WindowEvent e){} public void windowDeiconified(WindowEvent e){} public void windowOpened(WindowEvent e){} }