Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author Ilija
- */
- import javax.swing.*;
- import java.awt.*;
- /**
- *
- * @author Ilija
- */
- public class UIBilet extends JApplet{
- public JPanel createFlightOptions()
- {
- JComboBox start = new JComboBox();
- start.addItem("London");
- start.addItem("Skopje");
- start.addItem("Tokyo");
- JComboBox end = new JComboBox();
- end.addItem("Barcelona");
- end.addItem("Madrid");
- end.addItem("Paris");
- JPanel flightPane = new JPanel(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.fill = GridBagConstraints.HORIZONTAL;
- c.weightx = 1.0;
- flightPane.setBorder(BorderFactory.createTitledBorder("Flight options:"));
- // DEST
- JPanel destinationOpts = new JPanel(new GridBagLayout());
- c.gridx = 0;
- c.gridy = 0;
- destinationOpts.add(new JLabel("From:", SwingConstants.RIGHT), c);
- c.gridx = 1;
- c.gridy = 0;
- destinationOpts.add(new JLabel("To:", SwingConstants.RIGHT), c);
- c.gridx = 0;
- c.gridy = 1;
- destinationOpts.add(start,c);
- c.gridx = 1;
- c.gridy = 1;
- destinationOpts.add(end,c);
- c.gridx = 0;
- c.gridy = 0;
- c.ipady = 10;
- flightPane.add(destinationOpts,c);
- c.ipady = 0;
- // /DEST
- JPanel otherOpts = new JPanel(new GridBagLayout());
- c.gridx = 0;
- c.gridy = 0;
- otherOpts.add(new JLabel("Number of seats:"), c);
- c.gridx = 1;
- c.gridy = 0;
- otherOpts.add(new JTextPane(), c);
- c.gridx = 0;
- c.gridy = 1;
- otherOpts.add(new JLabel("Type of luggage: "), c);
- JPanel luggagePanel = new JPanel(new GridLayout(2, 1));
- luggagePanel.add(new JCheckBox("Bag", true));
- luggagePanel.add(new JCheckBox("Suitcase", false));
- c.gridx = 1;
- c.gridy = 1;
- otherOpts.add(luggagePanel, c);
- c.gridx = 0;
- c.gridy = 1;
- flightPane.add(otherOpts,c);
- return flightPane;
- }
- public JPanel createPersonalOptions()
- {
- GridLayout lay = new GridLayout(3, 2);
- lay.setVgap(5);
- JPanel opts = new JPanel(lay);
- opts.setBorder(BorderFactory.createTitledBorder("Personal options:"));
- opts.add(new JLabel("First name: "));
- opts.add(new JTextPane());
- opts.add(new JLabel("Last name: "));
- opts.add(new JTextPane());
- opts.add(new JLabel("Passport number: "));
- opts.add(new JTextPane());
- return opts;
- }
- public JPanel createPaymentInfo()
- {
- GridLayout lay = new GridLayout(1, 4);
- lay.setVgap(5);
- JPanel opts = new JPanel(lay);
- opts.setBorder(BorderFactory.createTitledBorder("Payment:"));
- opts.add(new JLabel("Card: "));
- ButtonGroup gr = new ButtonGroup();
- JRadioButton v = new JRadioButton("Visa", true)
- , m1 = new JRadioButton("Maestro", false)
- , m2 = new JRadioButton("Master", false);
- gr.add(v);
- gr.add(m1);
- gr.add(m2);
- opts.add(v);
- opts.add(m1);
- opts.add(m2);
- return opts;
- }
- @Override
- public void init() {
- JPanel pane = new JPanel(new GridBagLayout());
- GridBagConstraints c = new GridBagConstraints();
- c.fill = GridBagConstraints.HORIZONTAL;
- c.weightx = 1.0;
- c.gridx = 0;
- Dimension d = new Dimension(500, 1024);
- //this.getContentPane().setMaximumSize(d);
- //this.getContentPane().setMinimumSize(d);
- c.gridy++;
- pane.add(createFlightOptions(), c);
- c.gridy++;
- pane.add(createPersonalOptions(), c);
- c.gridy++;
- pane.add(createPaymentInfo(), c);
- c.gridy++;
- JPanel btnPane = new JPanel(new GridLayout(1, 2));
- JButton b1 = new JButton("Quit"), b2 = new JButton("Buy");
- int y = c.gridy;
- c.gridx = 0;
- c.gridy = 0;
- btnPane.add(b1, c);
- btnPane.add(b2, c);
- c.gridy = y;
- c.fill = GridBagConstraints.NONE;
- c.anchor = GridBagConstraints.EAST;
- pane.add(btnPane,c);
- this.getContentPane().add(pane);
- this.setSize(300, 320);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment