Example usage for java.awt BorderLayout LINE_START

List of usage examples for java.awt BorderLayout LINE_START

Introduction

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

Prototype

String LINE_START

To view the source code for java.awt BorderLayout LINE_START.

Click Source Link

Document

The component goes at the beginning of the line direction for the layout.

Usage

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel outerPanel = new JPanel(new BorderLayout());
    JPanel topPanel = new JPanel(new BorderLayout());
    JLabel label = new JLabel("Name:");
    JTextField text = new JTextField();
    topPanel.add(label, BorderLayout.LINE_START);
    topPanel.add(text, BorderLayout.CENTER);
    outerPanel.add(topPanel, BorderLayout.AFTER_LAST_LINE);

    frame.add(outerPanel);/*from www .ja  va  2  s.  c om*/
    frame.setSize(300, 200);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) throws Exception {
    URL url = new URL("http://www.java2s.com/style/download.png");
    final BufferedImage image = ImageIO.read(url);
    int x = 50;/*w w w. java 2s.c om*/
    final Image crop = image.getSubimage(x, 0, image.getWidth() - x, image.getHeight());
    Runnable r = new Runnable() {
        @Override
        public void run() {
            JPanel gui = new JPanel();
            gui.add(new JLabel(new ImageIcon(image)), BorderLayout.LINE_START);
            gui.add(new JLabel("java2s.com"));
            gui.add(new JLabel(new ImageIcon(crop)), BorderLayout.LINE_END);
            JOptionPane.showMessageDialog(null, gui);
        }
    };
    SwingUtilities.invokeLater(r);
}

From source file:Main.java

public static void main(String[] args) {

    showFrameWithToolBar(BorderLayout.PAGE_START);
    showFrameWithToolBar(BorderLayout.PAGE_END);
    showFrameWithToolBar(BorderLayout.LINE_START);
    showFrameWithToolBar(BorderLayout.LINE_END);
    showFrameWithToolBar(BorderLayout.CENTER);

}

From source file:Main.java

private void display() {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.add(new JButton(new AbstractAction("<Prev") {
        @Override/*w  ww  . j av  a  2  s .  co m*/
        public void actionPerformed(ActionEvent e) {
            if (--index < 0) {
                index = list.size() - 1;
            }
            update();
        }
    }), BorderLayout.LINE_START);
    f.add(label);
    f.add(new JButton(new AbstractAction("Next>") {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (++index == list.size()) {
                index = 0;
            }
            update();
        }
    }), BorderLayout.LINE_END);
    f.pack();
    f.setVisible(true);
}

From source file:Main.java

public Main() {
    setPreferredSize(new Dimension(500, 500));
    getContentPane().setLayout(new BorderLayout());
    JPanel panel = new JPanel(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(4, 4, 4, 4);
    panel.add(new JLabel("Label"), c);

    panel.add(new JTextField(20), c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    panel.add(new JButton("btn"), c);
    c.gridwidth = 1;/*from   w ww.  j a  v  a2  s .  c  om*/

    panel.add(new JLabel("Name"), c);

    panel.add(new JTextField(20), c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    panel.add(new JButton("btn"), c);
    c.weighty = 1.0;
    panel.add(Box.createGlue(), c);

    add(panel, BorderLayout.LINE_START);

    pack();
    setVisible(true);
}

From source file:layout.BorderLayoutDemo.java

public static void addComponentsToPane(Container pane) {

    if (!(pane.getLayout() instanceof BorderLayout)) {
        pane.add(new JLabel("Container doesn't use BorderLayout!"));
        return;//from ww w . j ava2  s .c om
    }

    if (RIGHT_TO_LEFT) {
        pane.setComponentOrientation(java.awt.ComponentOrientation.RIGHT_TO_LEFT);
    }

    JButton button = new JButton("Button 1 (PAGE_START)");
    pane.add(button, BorderLayout.PAGE_START);

    //Make the center component big, since that's the
    //typical usage of BorderLayout.
    button = new JButton("Button 2 (CENTER)");
    button.setPreferredSize(new Dimension(200, 100));
    pane.add(button, BorderLayout.CENTER);

    button = new JButton("Button 3 (LINE_START)");
    pane.add(button, BorderLayout.LINE_START);

    button = new JButton("Long-Named Button 4 (PAGE_END)");
    pane.add(button, BorderLayout.PAGE_END);

    button = new JButton("5 (LINE_END)");
    pane.add(button, BorderLayout.LINE_END);
}

From source file:components.MenuLayoutDemo.java

/**
 * Create the GUI and show it.  For thread safety,
 * this method should be invoked from the
 * event-dispatching thread.//from w w w. j a va  2 s .co m
 */
private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("MenuLayoutDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    //Create and set up the content pane.
    MenuLayoutDemo demo = new MenuLayoutDemo();
    Container contentPane = frame.getContentPane();
    contentPane.setBackground(Color.WHITE); //contrasting bg
    contentPane.add(demo.createMenuBar(), BorderLayout.LINE_START);

    //Display the window.
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:Main.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *//*from ww w.j  a va  2s.c  om*/
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("MenuLayoutDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    Main demo = new Main();
    Container contentPane = frame.getContentPane();
    contentPane.setBackground(Color.WHITE); // contrasting bg
    contentPane.add(demo.createMenuBar(), BorderLayout.LINE_START);

    // Display the window.
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:MenuLayoutDemo.java

/**
 * Create the GUI and show it. For thread safety, this method should be
 * invoked from the event-dispatching thread.
 *///from   w  ww.j  a v  a2  s  .c  o m
private static void createAndShowGUI() {
    // Create and set up the window.
    JFrame frame = new JFrame("MenuLayoutDemo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // Create and set up the content pane.
    MenuLayoutDemo demo = new MenuLayoutDemo();
    Container contentPane = frame.getContentPane();
    contentPane.setBackground(Color.WHITE); // contrasting bg
    contentPane.add(demo.createMenuBar(), BorderLayout.LINE_START);

    // Display the window.
    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:com.zigabyte.stock.stratplot.StockMarketHistoryViewer.java

private void initLayout() {
    Container content = this.getContentPane();
    content.setLayout(new BorderLayout());
    content.add(new JLabel("Select stock to view chart"), BorderLayout.NORTH);
    content.add(new JScrollPane(stockList), BorderLayout.LINE_START);
    content.add(chartPanel, BorderLayout.CENTER);
    this.setSize(1024, 768);
}