Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import javax.swing.border.*;
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.util.*;
- public class Apleti extends JApplet{
- JTextField text_name, text_lastname,text_passport;
- JTextField text_seats;
- public void init(){
- JFrame frame = new JFrame("Lab2");
- JPanel flight = new JPanel();
- JLabel destination1 = new JLabel("Destination(from):");
- JLabel destination2 = new JLabel("Destination(to):");
- JLabel seats = new JLabel("Number of seats:");
- JLabel luggage = new JLabel("Type of luggage:");
- JComboBox comboBox1 = new JComboBox();
- JComboBox comboBox2 = new JComboBox();
- text_seats = new JTextField(10);
- JCheckBox checkBox = new JCheckBox("Bag");
- checkBox.setSelected(true);
- JCheckBox checkBox1 = new JCheckBox("Suitcase");
- JPanel info = new JPanel();
- JLabel name = new JLabel("First name:");
- JLabel lastname = new JLabel("Last name:");
- JLabel passport = new JLabel("Passport number:");
- text_name = new JTextField(10);
- text_lastname = new JTextField(20);
- text_passport = new JTextField(10);
- JPanel payment = new JPanel();
- JLabel card = new JLabel("Card:");
- JRadioButton b1 = new JRadioButton("Visa");
- JRadioButton b2 = new JRadioButton("Maestro");
- JRadioButton b3 = new JRadioButton("Master");
- ButtonGroup bg = new ButtonGroup();
- JPanel kopcinja = new JPanel();
- JButton quit = new JButton("Quit");
- JButton buy = new JButton("Buy");
- buy.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- JOptionPane.showMessageDialog(null, text_name.getText() +
- " "+text_lastname.getText()+ " vashiot bilet e potvrden!");
- }
- });
- quit.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- text_name.setText("");
- text_lastname.setText("");
- text_passport.setText("");
- text_seats.setText("");
- }
- });
- TitledBorder title1 = BorderFactory.createTitledBorder("Flight options:");
- flight.setBorder(title1);
- TitledBorder title2 = BorderFactory.createTitledBorder("Personal info:");
- info.setBorder(title2);
- TitledBorder title3 = BorderFactory.createTitledBorder("Payment:");
- payment.setBorder(title3);
- comboBox1.addItem("Pariz");
- comboBox1.addItem("Berlin");
- comboBox1.addItem("London");
- comboBox2.addItem("Barcelona");
- comboBox2.addItem("NewYork");
- comboBox2.addItem("Skopje");
- frame.setLayout(new GridLayout(4, 1));
- flight.setLayout(new GridLayout(4, 2,20,20));
- info.setLayout(new GridLayout(3, 2,20,20));
- payment.setLayout(new GridLayout(1, 4));
- JPanel tmp = new JPanel();
- //flight panel
- flight.add(destination1);
- flight.add(destination2);
- flight.add(comboBox1);
- flight.add(comboBox2);
- flight.add(seats);
- flight.add(text_seats);
- flight.add(luggage);
- tmp.add(checkBox);
- tmp.add(checkBox1);
- flight.add(tmp);
- //flight.add(checkBox1);
- //info panel
- text_name.setText("FName");
- text_lastname.setText("LName");
- text_passport.setText("A123N09");
- info.add(name);
- info.add(text_name);
- info.add(lastname);
- info.add(text_lastname);
- info.add(passport);
- info.add(text_passport);
- //payment panel
- bg.add(b1);
- bg.add(b2);
- bg.add(b3);
- b1.setSelected(true);
- payment.add(card);
- payment.add(b1);
- payment.add(b2);
- payment.add(b3);
- //kopcinja panel
- kopcinja.add(quit);
- kopcinja.add(buy);
- frame.getContentPane().add(flight);
- frame.getContentPane().add(info);
- frame.getContentPane().add(payment);
- frame.getContentPane().add(kopcinja);
- frame.setVisible(true);
- frame.setSize(600,800);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement