Example usage for java.awt BorderLayout BorderLayout

List of usage examples for java.awt BorderLayout BorderLayout

Introduction

In this page you can find the example usage for java.awt BorderLayout BorderLayout.

Prototype

public BorderLayout() 

Source Link

Document

Constructs a new border layout with no gaps between components.

Usage

From source file:House.java

public House() {
    super(new BorderLayout());
    JPanel controlPanel = new JPanel(new GridLayout(3, 3));
    add(controlPanel, BorderLayout.NORTH);

    controlPanel.add(new JLabel("Translate(dx,dy): "));

    sliderTransX = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 300, 150, 100, 50);
    sliderTransY = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 300, 150, 100, 50);

    // To control rotation
    controlPanel.add(new JLabel("Rotate(Theta,ox,oy): "));
    sliderRotateTheta = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 360, 0, 90, 45);

    JPanel subPanel = new JPanel();
    subPanel.setLayout(new GridLayout(1, 2));

    sliderRotateX = setSlider(subPanel, JSlider.HORIZONTAL, 0, 300, 150, 150, 50);

    sliderRotateY = setSlider(subPanel, JSlider.HORIZONTAL, 0, 300, 150, 150, 50);
    controlPanel.add(subPanel);/*from  w w  w  .  j  ava2 s . c o m*/

    // To control scaling
    controlPanel.add(new JLabel("Scale(sx,sy)x10E-2:"));

    sliderScaleX = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 200, 100, 100, 10);

    sliderScaleY = setSlider(controlPanel, JSlider.HORIZONTAL, 0, 200, 100, 100, 10);

    // To control width of line segments
    JLabel label4 = new JLabel("Width Control:", JLabel.RIGHT);
    sliderWidth = new JSlider(JSlider.HORIZONTAL, 0, 20, 1);
    sliderWidth.setPaintTicks(true);
    sliderWidth.setMajorTickSpacing(5);
    sliderWidth.setMinorTickSpacing(1);
    sliderWidth.setPaintLabels(true);
    sliderWidth.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            width = sliderWidth.getValue();
            canvas.repaint();
        }
    });
    JPanel widthPanel = new JPanel();
    widthPanel.setLayout(new GridLayout(1, 2));
    widthPanel.add(label4);
    widthPanel.add(sliderWidth);
    add(widthPanel, BorderLayout.SOUTH);

    canvas = new MyCanvas();
    add(canvas, "Center");
}

From source file:Main.java

public JComponent makeUI() {
    UIManager.put("TabbedPane.tabInsets", new Insets(2, 2, 2, 50));
    final JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab("A", new JPanel());

    JPanel p = new JPanel(new BorderLayout());
    p.add(new JLayer<JTabbedPane>(tabbedPane, new CloseableTabbedPaneLayerUI()));
    p.add(new JButton(new AbstractAction("add tab") {
        @Override/*w ww  .  java  2 s.c o  m*/
        public void actionPerformed(ActionEvent e) {
            tabbedPane.addTab("test", new JPanel());
        }
    }), BorderLayout.SOUTH);
    return p;
}

From source file:com.js.quickestquail.ui.stats.YearStat.java

public YearStat() {
    setLayout(new BorderLayout());
    add(new ChartPanel(generateChart()), BorderLayout.CENTER);
}

From source file:MainClass.java

public MainClass() {
    // Build a mapping from book titles to their entries
    for (int i = 0; i < items.length; i++) {
        itemMap.put(items[i].getTitle(), items[i]);
    }/*from  ww w .j a v  a  2  s. com*/

    setLayout(new BorderLayout());

    JComboBox bookCombo = new JComboBox(items);
    bookCombo.setEditable(true);
    bookCombo.setEditor(new MyComboBoxEditor(itemMap, items[0]));
    bookCombo.setMaximumRowCount(4);
    bookCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            System.out.println("You chose " + ((JComboBox) e.getSource()).getSelectedItem() + "!");
        }
    });
    bookCombo.setActionCommand("Hello");
    add(bookCombo, BorderLayout.CENTER);
}

From source file:com.js.quickestquail.ui.stats.RatingStat.java

public RatingStat() {
    setLayout(new BorderLayout());
    add(new ChartPanel(generateChart()), BorderLayout.CENTER);
}

From source file:FactoryDemo.java

public static JPanel demo2() {
    // Demo 2: Change the format of a field when the user presses a button.
    // We can't call field.setFormatter() because that's a protected method.
    // (Plus it wouldn't work anyway. The old factory would replace our new
    // formatter with an "old" one next time the field gains or loses
    // focus.)/*  ww  w .  j a  v a 2 s  . c  o m*/
    // The thing to do is send a new factory to field.setFormatterFactory().

    JPanel pan = new JPanel(new BorderLayout());
    pan.setBorder(new TitledBorder("Demo 2: change format midstream"));

    MaskFormatter lowercase = null;
    try {
        lowercase = new MaskFormatter("LLLL");
    } catch (ParseException pe) {
    }
    final JFormattedTextField field = new JFormattedTextField(lowercase);
    field.setValue("Fore");
    pan.add(field, BorderLayout.CENTER);

    final JButton change = new JButton("change format");
    JPanel changePanel = new JPanel();
    changePanel.add(change);
    pan.add(changePanel, BorderLayout.SOUTH);

    change.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                field.commitEdit(); // commit current edit (if any)
                MaskFormatter uppercase = new MaskFormatter("UUUU");
                DefaultFormatterFactory factory = new DefaultFormatterFactory(uppercase);
                field.setFormatterFactory(factory);
                change.setEnabled(false);
            } catch (ParseException pe) {
            }
        }
    });

    return pan;
}

From source file:Main.java

public Main() {
    super(new BorderLayout());
    populateTree(treePanel);//from   ww  w.  j ava 2s.  c o m
    JButton addButton = new JButton("Add");
    addButton.setActionCommand(ADD_COMMAND);
    addButton.addActionListener(this);
    JButton removeButton = new JButton("Remove");
    removeButton.setActionCommand(REMOVE_COMMAND);
    removeButton.addActionListener(this);
    JButton clearButton = new JButton("Clear");
    clearButton.setActionCommand(CLEAR_COMMAND);
    clearButton.addActionListener(this);
    treePanel.setPreferredSize(new Dimension(300, 150));
    add(treePanel, BorderLayout.CENTER);
    JPanel panel = new JPanel(new GridLayout(0, 3));
    panel.add(addButton);
    panel.add(removeButton);
    panel.add(clearButton);
    add(panel, BorderLayout.SOUTH);
}

From source file:Main.java

public TabPanel() {
    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS));
    int USER_INPUT = 10;
    for (int i = 0; i < USER_INPUT; i++) {
        JPanel p = new JPanel(new BorderLayout());
        JLabel label = new JLabel("Label" + i);
        JTextField textArea = new JTextField();
        p.add(label, BorderLayout.NORTH);
        p.add(textArea, BorderLayout.CENTER);
        innerPanel.add(p);//from  w  ww.j a  v a  2  s .co m
    }

    JScrollPane scrollPane = new JScrollPane(innerPanel);
    scrollPane.setPreferredSize(new Dimension(400, 200));
    this.add(scrollPane);
}

From source file:URLMonitorPanel.java

public URLMonitorPanel(String url, Timer t) throws MalformedURLException {
    setLayout(new BorderLayout());
    timer = t;/*from  w w  w.j  a v  a  2  s.  com*/
    this.url = new URL(url);
    add(new JLabel(url), BorderLayout.CENTER);
    JPanel temp = new JPanel();
    status = new JPanel();
    status.setSize(20, 20);
    temp.add(status);
    startButton = new JButton("Start");
    startButton.setEnabled(false);
    startButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            makeTask();
            startButton.setEnabled(false);
            stopButton.setEnabled(true);
        }
    });
    stopButton = new JButton("Stop");
    stopButton.setEnabled(true);
    stopButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            task.cancel();
            startButton.setEnabled(true);
            stopButton.setEnabled(false);
        }
    });
    temp.add(startButton);
    temp.add(stopButton);
    add(temp, BorderLayout.EAST);
    makeTask();
}

From source file:Main.java

/** Make a JPanel with a {@link BorderLayout}. */
public static JPanel makeBorderPanel() {
    return new JPanel(new BorderLayout());
}