📄 gridbaglayoutdemo.java
字号:
// $$$$$$$$$$$$$$$$$$$$$$$$
button55 =new JButton("w");
c.gridx=0;
c.gridy=15;
pane.add(button55,c);
button56 =new JButton("a");
c.gridx=1;
c.gridy=15;
pane.add(button56,c);
button57 =new JButton("a");
// c.ipady=20;
// c.weightx=0.0;
c.gridx=3;
c.gridy=15;
pane.add(button57,c);
button58 =new JButton("m");
c.gridx=4;
c.gridy=15;
pane.add(button58,c);
button59 =new JButton("a");
c.gridx=5;
c.gridy=15;
pane.add(button59,c);
button60 =new JButton("a");
c.gridx=7;
c.gridy=15;
pane.add(button60,c);
button61 =new JButton("w");
c.gridx=8;
c.gridy=15;
pane.add(button61,c);
// $$$$$$$$$$$$$$$$$$$$$$$$
jt1=new JTextField();
c.gridwidth=30;
c.gridx=0;
c.gridy=16;
pane.add(jt1,c);
jt2=new JTextField();
c.gridwidth=30;
c.gridx=0;
c.gridy=17;
pane.add(jt2,c);
//jt3=new JTextField();
//c.gridwidth=20;
//c.gridx=0;
//c.gridy=18;
//pane.add(jt3,c);
//jt4=new JTextField();
//c.gridwidth=30;
//c.gridx=0;
//c.gridy=19;
//pane.add(jt4,c);
jt5=new JTextField();
c.gridwidth=30;
c.gridx=0;
c.gridy=18;
pane.add(jt5,c);
jt6=new JTextField();
//c.ipadx=40;
//c.ipady=5;
c.gridwidth=5;
c.gridx=0;
c.gridy=1;
pane.add(jt6,c);
jt7=new JTextField();
c.gridwidth=30;
c.gridx=0;
c.gridy=3;
pane.add(jt7,c);
//+String info =JOptionPane.showInputDialog("please insert ur destination");
check=new JButton("check des& start");
c.gridx=0;
c.gridy=2;
pane.add(check,c);
jt9=new JTextField();
c.gridwidth=5;
c.gridx=6;
c.gridy=1;
pane.add(jt9,c);
// String info1 =JOptionPane.showInputDialog("please insert ur flight time");
final seat[]oneseat=new seat[46];
button16.add(label1);
button17.add(label2);
button181.add(label3);
button191.add(label4);
button20.add(label5);
button21.add(label6);
button22.add(label7);
button23.add(label8);
button24.add(label9);
button25.add(label10);
button26.add(label11);
button27.add(label12);
button28.add(label13);
button29.add(label14);
button30.add(label15);
button31.add(label17);
button32.add(label18);
button33.add(label19);
button34.add(label20);
button35.add(label21);
button36.add(label22);
button37.add(label23);
button38.add(label24);
button39.add(label25);
button40.add(label26);
button41.add(label27);
button42.add(label28);
button43.add(label29);
button44.add(label30);
button45.add(label31);
button46.add(label32);
button47.add(label33);
button48.add(label34);
button49.add(label35);
button50.add(label36);
button51.add(label37);
button52.add(label38);
button53.add(label39);
button54.add(label40);
button55.add(label41);
button56.add(label42);
button57.add(label43);
button58.add(label44);
button59.add(label45);
button60.add(label46);
button61.add(label47);
label16=new JLabel();
label16.setText("flightcheck");
c.gridx=5;
c.gridy=0;
pane.add(label16,c);
//c.gridx=7;
//c.gridy=4;
//pane.add(show,c);
check.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
for(int i=0;i<5;i++){
if(jt6.getText().compareTo(air.get_1st(i).get_dis())==0&&jt9.getText().compareTo(air.get_1st(i).get_start())==0){
jt7.setText("flight infomation: "+air.get_1st(i).toString() );
}
}
}});
// /////////////////////////////////////
button16.addActionListener (
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
oneseat[0]=new seat("window","f1A");
String information2 =JOptionPane.showInputDialog("please decide do " +
"u want to buy or booked or clear ");
if(information2.compareTo("buy")==0)
{ label1.setText(information2);
button16.setBackground(Color.yellow);
label1.setForeground(Color.red);
tempid1=JOptionPane.showInputDialog("please input ur ID");
temp_name1=JOptionPane.showInputDialog("please input ur name");
onepassager1=new person(tempid1,temp_name1);
jt5.setText("the owner information: "+onepassager1.toString() );
jt1.setText("seat infomation: "+oneseat[0].toString());
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
//get_throw();
write=tempid1+oneseat[0].toString() ;
System.out.println(write);
}
else if(information2.compareTo("clear")==0)
{
label1.setText("");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1++;
jt2.setText("remain seats number: "+num1);
}
else if(information2.compareTo("book")==0)
{
button16.setBackground( Color.green);
label1.setForeground(Color.red);
label1.setText("book");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
}
}});
button17.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
oneseat[1]=new seat("aisle","f1B");
String information2 =JOptionPane.showInputDialog("please decide do u want to buy or booked");
if(information2.compareTo("buy")==0)
{ label2.setText(information2);
button17.setBackground(Color.yellow);
label2.setForeground(Color.red);
tempid1=JOptionPane.showInputDialog("please input ur ID");
temp_name1=JOptionPane.showInputDialog("please input ur name");
onepassager1=new person(tempid1,temp_name1);
jt5.setText("the owner information: "+onepassager1.toString() );
jt1.setText("seat infomation: "+oneseat[1].toString());
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
}
else if(information2.compareTo("clear")==0)
{
label2.setText("");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1++;
jt2.setText("remain seats number: "+num1);
}
else if(information2.compareTo("book")==0)
{
button17.setBackground( Color.green);
label2.setForeground(Color.red);
label2.setText("book");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
}
}});
button181.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
oneseat[2]=new seat("aisle","f1C");
String information2 =JOptionPane.showInputDialog("please decide do u want to buy or booked");
if(information2.compareTo("buy")==0)
{ label3.setText(information2);
button181.setBackground(Color.yellow);
label3.setForeground(Color.red);
tempid1=JOptionPane.showInputDialog("please input ur ID");
temp_name1=JOptionPane.showInputDialog("please input ur name");
onepassager1=new person(tempid1,temp_name1);
jt5.setText("the owner information: "+onepassager1.toString() );
jt1.setText("seat infomation: "+oneseat[2].toString());
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
}
else if(information2.compareTo("clear")==0)
{
label3.setText("");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1++;
jt2.setText("remain seats number: "+num1);
}
else if(information2.compareTo("book")==0)
{
button181.setBackground( Color.green);
label3.setForeground(Color.red);
label3.setText("book");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
} }});
button191.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
oneseat[3]=new seat("window","f1D");
String information2 =JOptionPane.showInputDialog("please decide do u want to buy or booked");
if(information2.compareTo("buy")==0)
{ label4.setText(information2);
button191.setBackground(Color.yellow);
label4.setForeground(Color.red);
tempid1=JOptionPane.showInputDialog("please input ur ID");
temp_name1=JOptionPane.showInputDialog("please input ur name");
onepassager1=new person(tempid1,temp_name1);
jt5.setText("the owner information: "+onepassager1.toString() );
jt1.setText("seat infomation: "+oneseat[3].toString());
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
}
else if(information2.compareTo("clear")==0)
{
label4.setText("");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1++;
jt2.setText("remain seats number: "+num1);
}
else if(information2.compareTo("book")==0)
{
button191.setBackground( Color.green);
label4.setForeground(Color.red);
label4.setText("book");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
}
}});
// /////////////////////////////////////////
button20.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
oneseat[4]=new seat("window","1A");
String information2 =JOptionPane.showInputDialog("please decide do u want to buy or booked");
if(information2.compareTo("buy")==0)
{ label5.setText(information2);
button20.setBackground(Color.yellow);
label5.setForeground(Color.red);
tempid1=JOptionPane.showInputDialog("please input ur ID");
temp_name1=JOptionPane.showInputDialog("please input ur name");
onepassager1=new person(tempid1,temp_name1);
jt5.setText("the owner information: "+onepassager1.toString() );
jt1.setText("seat infomation: "+oneseat[4].toString());
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);}
else if(information2.compareTo("clear")==0)
{
label5.setText("");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1++;
jt2.setText("remain seats number: "+num1);
}
else if(information2.compareTo("book")==0)
{
button20.setBackground( Color.green);
label5.setForeground(Color.red);
label5.setText("book");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
} }
});
button21.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
oneseat[5]=new seat("aisle","1B");
String information2 =JOptionPane.showInputDialog("please decide do u want to buy or booked");
if(information2.compareTo("buy")==0)
{ label6.setText(information2);
button21.setBackground(Color.yellow);
label6.setForeground(Color.red);
tempid1=JOptionPane.showInputDialog("please input ur ID");
temp_name1=JOptionPane.showInputDialog("please input ur name");
onepassager1=new person(tempid1,temp_name1);
jt5.setText("the owner information: "+onepassager1.toString() );
jt1.setText("seat infomation: "+oneseat[5].toString());
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
}
else if(information2.compareTo("clear")==0)
{
label6.setText("");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1++;
jt2.setText("remain seats number: "+num1);
}
else if(information2.compareTo("book")==0)
{
button21.setBackground( Color.green);
label6.setForeground(Color.red);
label6.setText("book");
jt5.setText("" );
jt1.setText("" );
jt1.setEditable( true);
num1--;
jt2.setText("remain seats number: "+num1);
} }});
button22.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent event)
{
oneseat[6]=new seat("aisle","1C");
String information2 =JOptionPane.showInputDialog("please decide do u want to buy or booked");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -