this below my project a part where i have been sing generate button in inward TextField, but not able to make sure.
please watch the picture. mostly see the generate action performed block.
JMenuItem home = new JMenuItem("Inward AWB Bill");
home.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent as){
JFrame frame1 = new JFrame("Inward Table");
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLO SE);
frame1.setSize(800,600);
frame1.setResizable(false);
frame1.setLocationRelativeTo(null);
frame1.setVisible(true);
JPanel panel1 = new JPanel();
panel1.setSize(500,400);
//getContentPane().add(panel);
panel1.setLayout(null);
JLabel inward =new JLabel("Inward");
inward.setSize(100,30);
inward.setLocation(50,50);
//inward.setEditable(false);
inward.setFont(new Font("Arial",Font.BOLD,13));
final JTextField inwardField =new JTextField();
inwardField.setSize(150,30);
inwardField.setLocation(190,50);
inwardField.setFont(new Font("Arial",Font.BOLD,13));
JLabel fromin = new JLabel("From Bill No");
fromin.setSize(110,30);
fromin.setLocation(350,50);
//from.setEditable(false);
fromin.setFont(new Font("Arial",Font.BOLD,13));
final JTextField fromFieldin = new JTextField();
fromFieldin.setSize(100,30);
fromFieldin.setLocation(440,50);
fromFieldin.setFont(new Font("Arial",Font.BOLD,13));
JLabel toin = new JLabel("To Bill No");
toin.setSize(100,30);
toin.setLocation(540,50);
//to.setEditable(false);
toin.setFont(new Font("Arial",Font.BOLD,13));
final JTextField toFieldin = new JTextField();
toFieldin.setSize(100,30);
toFieldin.setLocation(610,50);
toFieldin.setFont(new Font("Arial",Font.BOLD,13));
JLabel inwardDate = new JLabel("Date Of Inward");
inwardDate.setSize(100,30);
inwardDate.setLocation(50,90);
//inwardDate.setEditable(false);
inwardDate.setFont(new Font("Arial",Font.BOLD,13));
final JTextField inwardDateField = new JTextField();
inwardDateField.setSize(150,30);
inwardDateField.setLocation(190,90);
inwardDateField.setFont(new Font("Arial",Font.BOLD,13));
JLabel inwardBy = new JLabel("Inward By");
inwardBy.setSize(100,30);
inwardBy.setLocation(50,130);
//inwardBy.setEditable(false);
inwardBy.setFont(new Font("Arial",Font.BOLD,13));
final JTextField inwardByField = new JTextField();
inwardByField.setSize(150,30);
inwardByField.setLocation(190,130);
inwardByField.setFont(new Font("Arial",Font.BOLD,13));
comboBox = new JComboBox<String>();
comboBox.setSize(100,30);
comboBox.setLocation(350, 500);
JButton savea = new JButton("Save");
savea.setSize(70,30);
savea.setLocation(90,250);
savea.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
savea();
}
private void savea() {
String inField =inwardField.getText();
String indate = inwardDateField.getText();
String inby = inwardByField.getText();
addToDB(inField,indate,inby);
}
private void addToDB(String inField, String indate, String inby) {
String quary=("insert into inward(inward, inwardDate, inward By )values('"+inField+"','"+indate+"','"+inby+"')");
Connectionn.executeInsert(quary);
populateComboBox();
}
});
JButton edit = new JButton("Edit");
edit.setSize(70,30);
edit.setLocation(170,250);
edit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
}
});
final JButton exit = new JButton("Exit");
exit.setSize(70,30);
exit.setLocation(250,250);
exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent we){
if(we.getSource()==exit){
System.exit(0);
}
}
});
JButton generatei = new JButton("Auto Generate ");
generatei.setToolTipText("For Auto generate Bill Only Can Use This Button");
generatei.setSize(120,30);
generatei.setLocation(520,100);
generatei.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent r){
generatei();
}
private void generatei() {
String in =inwardField.getText();
String start=fromFieldin.getText();
String end=toFieldin.getText();
in="13276125962"; // section i have been doubt don't how to manage below mention field.
start="13276125962";
end="100000000000";
String increment="11";
for(String i=start;i<= end;i+=increment)
addToDB(in,start,end);
}
private void addToDB(String in,String start,String end) {
String quary=("insert into inward(inward,fromFieldin,toFieldin)values('"+in+" ','"+start+"','"+end+"')");
Connectionn.executeInsert(quary);
}
});
frame1.add(panel1);
panel1.add(inward);
panel1.add(inwardField);
panel1.add(inwardDate);
panel1.add(inwardDateField);
panel1.add(inwardBy);
panel1.add(inwardByField);
panel1.add(savea);
panel1.add(edit);
panel1.add(exit);
panel1.add(comboBox);
panel1.add(fromin);
panel1.add(fromFieldin);
panel1.add(toin);
panel1.add(toFieldin);
panel1.add(generatei);
}
});