1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class NewBaseFrame extends JFrame{
NewBaseFrame _me;
JTextField _dbName, _path;
JComboBox _chooseType;
NewBaseFrame()
{
super("New Base Creation");
_me=this;
this.setLayout(null);
JLabel choose = new JLabel("enter a name for the new DataBase:");
choose.setBounds(40, 10, 200, 20);
this.add(choose);
_dbName = new JTextField();
_dbName.setBounds(40, 35, 200, 25);
this.add(_dbName);
JLabel type = new JLabel("type of the new dataBase :");
type.setBounds(20, 60, 200, 20);
this.add(type);
String[] typelist = {"Eucaryote","Procaryote"};
_chooseType = new JComboBox(typelist);
_chooseType.setBounds(40, 80, 200, 22);
this.add(_chooseType);
JButton ManualAdd = new JButton("On-line Filling");
ManualAdd.setBounds(25,120,250,30);
ManualAdd.addActionListener(new ManualFillListener());
this.add(ManualAdd);
JLabel enterfile= new JLabel("Or create from a data file:");
enterfile.setBounds(20,155,200,20);
this.add(enterfile);
_path = new JTextField();
_path.setBounds(20,175,200,25);
this.add(_path);
JButton browse = new JButton("Browse");
browse.setBounds(220,177,60,20);
browse.addActionListener(new BrowseListener());
this.add(browse);
JButton fill = new JButton("Fill");
fill.setBounds(25,201,250,25);
fill.addActionListener(new FillListener());
this.add(fill);
JButton cancel = new JButton("Cancel");
cancel.setBounds(200,240,70,25);
cancel.addActionListener(new CancelListener());
this.add(cancel);
this.setBounds(250, 175, 300,300);
this.setVisible(true);
}
class ManualFillListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
}
}
class BrowseListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
String fich="";
JFileChooser _chooser = new JFileChooser();
_chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
JPanel pan=new JPanel();
try{
int returnVal = _chooser.showOpenDialog(pan);
System.out.println("ici 1");
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("ici 2");
fich=_chooser.getSelectedFile().getPath();
System.out.println("ici 3");
_path.setText(fich);
System.out.println("ici 4");
}
System.out.println("ici 5");
}catch(Throwable t){
t.printStackTrace();
JOptionPane.showMessageDialog(null,"file error! retry please");
return;
}
}
}
class FillListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
}
}
class CancelListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
_me.dispose();
System.exit(0);
}
}
public static void main(String[] args) {
new NewBaseFrame();
}
} |