Advertisement
Guest User

ElenaIPLAB2

a guest
Oct 23rd, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.35 KB | None | 0 0
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.applet.Applet;
  4. import javax.swing.border.TitledBorder;
  5.  
  6. public class Airport extends Applet{
  7.      
  8.     private static final long serialVersionUID = -5436879954963310328L;
  9.     @Override
  10.     public void init(){
  11.         this.setSize(500, 500);
  12.         this.setLayout(new BorderLayout());
  13.        
  14.         JPanel p1 = new JPanel();
  15.         p1.setLayout(new GridLayout(1,2));
  16.        
  17.         JPanel p11 = new JPanel();
  18.         p11.setLayout(new GridLayout(4,1));    
  19.         JLabel df = new JLabel("Destination(from):");
  20.         df.setHorizontalTextPosition(JLabel.RIGHT);
  21.         p11.add(df);  
  22.         JComboBox<String> j1 = new JComboBox<String>();
  23.         j1.addItem("London");
  24.         j1.addItem("Paris");
  25.         j1.addItem("Berlin");
  26.         p11.add(j1);
  27.         p11.add(new JLabel("Number of seats:"));      
  28.         p11.add(new JLabel("Type of luggage:"));      
  29.        
  30.         p1.add(p11);
  31.        
  32.         JPanel p12 = new JPanel();
  33.         p12.setLayout(new GridLayout(4,1));    
  34.         JLabel dt = new JLabel("Destination(to):");
  35.         dt.setHorizontalTextPosition(JLabel.CENTER);
  36.         p12.add(dt);  
  37.         JComboBox<String> j2 = new JComboBox<String>();
  38.         j2.addItem("Barcelona");
  39.         j2.addItem("Prague");
  40.         j2.addItem("Amsterdam");
  41.         p12.add(j2);
  42.         p12.add(new JTextField());    
  43.        
  44.         JPanel p123 = new JPanel();
  45.         p123.setLayout(new GridLayout(2,1));  
  46.         ButtonGroup bt = new ButtonGroup();
  47.         JCheckBox cb1= new JCheckBox("Bag");
  48.         JCheckBox cb2= new JCheckBox("Suitcase");
  49.         bt.add(cb1);
  50.         bt.add(cb2);          
  51.         p123.add(cb1);
  52.         p123.add(cb2);
  53.        
  54.         p12.add(p123);
  55.        
  56.         p1.add(p12);
  57.        
  58.         TitledBorder tb1=new TitledBorder("Flight options:");
  59.         p1.setBorder(tb1);
  60.        
  61.         JPanel p2= new JPanel();
  62.         p2.setLayout(new GridLayout(3,2));
  63.         p2.add(new JLabel("First name:"));
  64.         p2.add(new JTextField());
  65.         p2.add(new JLabel("Last name:"));
  66.         p2.add(new JTextField());
  67.         p2.add(new JLabel("Passport number:"));
  68.         p2.add(new JTextField());
  69.        
  70.         TitledBorder tb2=new TitledBorder("Personal info:");
  71.         p2.setBorder(tb2);
  72.        
  73.         JPanel p3= new JPanel();
  74.         p3.setLayout(new GridLayout(1,4));    
  75.         p3.add(new JLabel("Card:"));  
  76.         ButtonGroup bg = new ButtonGroup();
  77.         JRadioButton a= new JRadioButton("Visa");
  78.         JRadioButton b= new JRadioButton("Maestro");
  79.         JRadioButton c= new JRadioButton("Master");
  80.         bg.add(a);
  81.         bg.add(b);
  82.         bg.add(c);
  83.         p3.add(a);
  84.         p3.add(b);
  85.         p3.add(c);
  86.        
  87.         TitledBorder tb3=new TitledBorder("Payment:");
  88.         p3.setBorder(tb3);
  89.        
  90.         JPanel glavna=new JPanel(new GridLayout(3,1));
  91.         glavna.add(p1);
  92.         glavna.add(p2);
  93.         glavna.add(p3);
  94.        
  95.         JPanel p4= new JPanel();
  96.         p4.setLayout(new GridLayout(1,3));
  97.         JPanel prazna=new JPanel();
  98.         p4.add(prazna);
  99.         JButton quit = new JButton("Quit");
  100.         JButton buy = new JButton("Buy");      
  101.         p4.add(quit);
  102.         p4.add(buy);  
  103.         this.add(glavna,BorderLayout.CENTER);
  104.         this.add(p4,BorderLayout.SOUTH);
  105.         }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement