Example usage for java.awt BorderLayout EAST

List of usage examples for java.awt BorderLayout EAST

Introduction

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

Prototype

String EAST

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

Click Source Link

Document

The east layout constraint (right side of container).

Usage

From source file:JDK6TabbedPaneExample.java

public void add() {
    final JPanel content = new JPanel();
    JPanel tab = new JPanel();
    tab.setOpaque(false);//from  w  w w .  j  av  a2s.c  o m

    JLabel tabLabel = new JLabel("Tab " + (++tabCounter));

    JButton tabCloseButton = new JButton(closeXIcon);
    tabCloseButton.setPreferredSize(closeButtonSize);
    tabCloseButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int closeTabNumber = tabbedPane.indexOfComponent(content);
            tabbedPane.removeTabAt(closeTabNumber);
        }
    });

    tab.add(tabLabel, BorderLayout.WEST);
    tab.add(tabCloseButton, BorderLayout.EAST);

    tabbedPane.addTab(null, content);
    tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, tab);
}

From source file:URLMonitorPanel.java

public URLMonitorPanel(String url, Timer t) throws MalformedURLException {
    setLayout(new BorderLayout());
    timer = t;// ww w  .ja v  a2 s . co m
    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:Demo.LineGraph.java

public LineGraph(int sampleNb) {
    this.sampleNb = sampleNb;

    InitDataSet();/*www  .ja  v a 2 s .c o m*/
    InitChart();

    // layout
    setLayout(new BorderLayout());

    add(Box.createHorizontalStrut(30), BorderLayout.WEST);
    add(Box.createHorizontalStrut(30), BorderLayout.EAST);
    add(Box.createVerticalStrut(30), BorderLayout.NORTH);
    add(chartPane, BorderLayout.CENTER);
}

From source file:Main.java

public Main() {
    JPanel inputPanel = new JPanel(new BorderLayout(3, 3));
    go.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                URL pageURL = new URL("http://www.google.com");
                HttpURLConnection urlConnection = (HttpURLConnection) pageURL.openConnection();
                int respCode = urlConnection.getResponseCode();
                String response = urlConnection.getResponseMessage();
                codeArea.setText("HTTP/1.x " + respCode + " " + response + "\n");
                int count = 1;
                while (true) {
                    String header = urlConnection.getHeaderField(count);
                    String key = urlConnection.getHeaderFieldKey(count);
                    if (header == null || key == null) {
                        break;
                    }/*from  w ww.  j  av a  2 s.co m*/
                    codeArea.append(urlConnection.getHeaderFieldKey(count) + ": " + header + "\n");
                    count++;
                }
                InputStream in = new BufferedInputStream(urlConnection.getInputStream());
                Reader r = new InputStreamReader(in);
                int c;
                while ((c = r.read()) != -1) {
                    codeArea.append(String.valueOf((char) c));
                }
                codeArea.setCaretPosition(1);
            } catch (Exception ee) {
            }
        }
    });
    inputPanel.add(BorderLayout.EAST, go);
    JScrollPane codeScroller = new JScrollPane(codeArea);
    add(BorderLayout.NORTH, inputPanel);
    add(BorderLayout.CENTER, codeScroller);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setSize(700, 500);
    this.setVisible(true);
}

From source file:BoxLayoutPane.java

public BoxLayoutPane() {
    // Use a BorderLayout layout manager to arrange various Box components
    this.setLayout(new BorderLayout());

    // Give the entire panel a margin by adding an empty border
    // We could also do this by overriding getInsets()
    this.setBorder(new EmptyBorder(10, 10, 10, 10));

    // Add a plain row of buttons along the top of the pane
    Box row = Box.createHorizontalBox();
    for (int i = 0; i < 4; i++) {
        JButton b = new JButton("B" + i);
        b.setFont(new Font("serif", Font.BOLD, 12 + i * 2));
        row.add(b);/*from   w  ww. j  ava  2s  .co  m*/
    }
    this.add(row, BorderLayout.NORTH);

    // Add a plain column of buttons along the right edge
    // Use BoxLayout with a different kind of Swing container
    // Give the column a border: can't do this with the Box class
    JPanel col = new JPanel();
    col.setLayout(new BoxLayout(col, BoxLayout.Y_AXIS));
    col.setBorder(new TitledBorder(new EtchedBorder(), "Column"));
    for (int i = 0; i < 4; i++) {
        JButton b = new JButton("Button " + i);
        b.setFont(new Font("sanserif", Font.BOLD, 10 + i * 2));
        col.add(b);
    }
    this.add(col, BorderLayout.EAST); // Add column to right of panel

    // Add a button box along the bottom of the panel.
    // Use "Glue" to space the buttons evenly
    Box buttonbox = Box.createHorizontalBox();
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Okay"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Cancel"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Help"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    this.add(buttonbox, BorderLayout.SOUTH);

    // Create a component to display in the center of the panel
    JTextArea textarea = new JTextArea();
    textarea.setText("This component has 12-pixel margins on left and top"
            + " and has 72-pixel margins on right and bottom.");
    textarea.setLineWrap(true);
    textarea.setWrapStyleWord(true);

    // Use Box objects to give the JTextArea an unusual spacing
    // First, create a column with 3 kids. The first and last kids
    // are rigid spaces. The middle kid is the text area
    Box fixedcol = Box.createVerticalBox();
    fixedcol.add(Box.createVerticalStrut(12)); // 12 rigid pixels
    fixedcol.add(textarea); // Component fills in the rest
    fixedcol.add(Box.createVerticalStrut(72)); // 72 rigid pixels

    // Now create a row. Give it rigid spaces on the left and right,
    // and put the column from above in the middle.
    Box fixedrow = Box.createHorizontalBox();
    fixedrow.add(Box.createHorizontalStrut(12));
    fixedrow.add(fixedcol);
    fixedrow.add(Box.createHorizontalStrut(72));

    // Now add the JTextArea in the column in the row to the panel
    this.add(fixedrow, BorderLayout.CENTER);
}

From source file:SwingWorkerProcessor.java

public SwingWorkerFrame() {
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container contentPane = this.getContentPane();
    cancelButton.setEnabled(false);//from  www.  j ava  2s  .c om

    contentPane.add(statusLabel, BorderLayout.NORTH);
    contentPane.add(startButton, BorderLayout.WEST);
    contentPane.add(cancelButton, BorderLayout.EAST);

    startButton.addActionListener(e -> startProcessing());
    cancelButton.addActionListener(e -> cancelProcessing());
}

From source file:pcgen.gui2.filter.SearchFilterPanel.java

public SearchFilterPanel() {
    searchField.getDocument().addDocumentListener(this);
    clearButton.addActionListener(this);
    setLayout(new BorderLayout());
    add(new JLabel(LanguageBundle.getString("in_filterLabel")), BorderLayout.WEST);
    add(searchField, BorderLayout.CENTER);
    add(clearButton, BorderLayout.EAST);
}

From source file:ButtonScroll.java

public ButtonScroll() {
    super("Scrolling Programmatically");
    setSize(400, 400);/*from   w  w  w .  j  a v  a  2s  .  c  o m*/
    getContentPane().setLayout(new BorderLayout());

    ImageIcon shuttle = new ImageIcon("largeJava2sLogo.GIF");
    pgVertical = shuttle.getIconHeight() / 5;
    pgHorzontal = shuttle.getIconWidth() / 5;
    JLabel lbl = new JLabel(shuttle);

    viewport = new JViewport();
    viewport.setView(lbl);
    viewport.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            enableButtons(ButtonScroll.this.viewport.getViewPosition());
        }
    });
    getContentPane().add(viewport, BorderLayout.CENTER);

    JPanel pv = new JPanel(new BorderLayout());
    upButton = createButton("up", 'u');
    ActionListener lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            movePanel(0, -1);
        }
    };
    upButton.addActionListener(lst);
    pv.add(upButton, BorderLayout.NORTH);

    downButton = createButton("down", 'd');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            movePanel(0, 1);
        }
    };
    downButton.addActionListener(lst);
    pv.add(downButton, BorderLayout.SOUTH);
    getContentPane().add(pv, BorderLayout.EAST);

    JPanel ph = new JPanel(new BorderLayout());
    leftButton = createButton("left", 'l');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            movePanel(-1, 0);
        }
    };
    leftButton.addActionListener(lst);
    ph.add(leftButton, BorderLayout.WEST);

    rightButton = createButton("right", 'r');
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            movePanel(1, 0);
        }
    };
    rightButton.addActionListener(lst);
    ph.add(rightButton, BorderLayout.EAST);
    getContentPane().add(ph, BorderLayout.SOUTH);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    setVisible(true);
    movePanel(0, 0);
}

From source file:org.ut.biolab.medsavant.client.view.util.PeekingPanel.java

public PeekingPanel(String label, String borderLayoutPosition, JComponent panel, boolean isExpanded, int size) {

    final boolean isVertical = borderLayoutPosition.equals(BorderLayout.EAST)
            || borderLayoutPosition.equals(BorderLayout.WEST);

    this.setAnimated(false);

    if (borderLayoutPosition.equals(BorderLayout.NORTH)) {
        dockedSide = DockedSide.NORTH;//from   w ww  .  j av  a 2s. com
        this.setDirection(JXCollapsiblePane.Direction.UP);
    } else if (borderLayoutPosition.equals(BorderLayout.SOUTH)) {
        dockedSide = DockedSide.SOUTH;
        this.setDirection(JXCollapsiblePane.Direction.DOWN);
    } else if (borderLayoutPosition.equals(BorderLayout.EAST)) {
        dockedSide = DockedSide.EAST;
        this.setDirection(JXCollapsiblePane.Direction.RIGHT);
    } else {
        dockedSide = DockedSide.WEST;
        this.setDirection(JXCollapsiblePane.Direction.LEFT);
    }

    this.setLayout(new BorderLayout());
    this.panel = panel;

    if (isVertical) {
        panel.setPreferredSize(new Dimension(size, 999));
    } else {
        panel.setPreferredSize(new Dimension(999, size));
    }
    titlePanel = new JPanel();

    titlePanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    titlePanel.setBorder(ViewUtil.getTinyBorder());
    if (isVertical) {
        titlePanel.setLayout(new BoxLayout(titlePanel, BoxLayout.Y_AXIS));
    } else {
        titlePanel.setLayout(new BoxLayout(titlePanel, BoxLayout.X_AXIS));
    }
    titlePanel.add(Box.createHorizontalGlue());

    this.titleString = label.toUpperCase();
    title = new JLabel(" ");//titleString);

    title.setForeground(Color.darkGray);
    if (borderLayoutPosition.equals(BorderLayout.EAST)) {
        title.setUI(new VerticalLabelUI(true));
    } else if (borderLayoutPosition.equals(BorderLayout.WEST)) {
        title.setUI(new VerticalLabelUI(false));
    }
    titlePanel.add(title);

    if (!isVertical) {
        titlePanel.add(Box.createHorizontalGlue());
    }

    titlePanel.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            toggleExpanded();
        }
    });

    this.add(titlePanel, borderLayoutPosition);
    this.add(panel, BorderLayout.CENTER);

    setExpanded(isExpanded);
}

From source file:Sketch.java

public Sketch() {
    super(true);/* w ww.j a v  a 2 s.  co m*/

    setLayout(new BorderLayout());
    board = new JPanel(true);
    board.setPreferredSize(new Dimension(300, 300));
    board.setBorder(new LineBorder(Color.black, 5));

    clear = new JButton("Clear Drawing Area");
    clear.addActionListener(this);

    shuttle1 = new JogShuttle(0, 300, 150);
    lastX = shuttle1.getValue();
    shuttle2 = new JogShuttle(0, 300, 150);
    lastY = shuttle2.getValue();

    shuttle1.setValuePerRevolution(100);
    shuttle2.setValuePerRevolution(100);

    shuttle1.addPropertyChangeListener(this);
    shuttle2.addPropertyChangeListener(this);

    shuttle1.setBorder(new BevelBorder(BevelBorder.RAISED));
    shuttle2.setBorder(new BevelBorder(BevelBorder.RAISED));

    add(board, BorderLayout.NORTH);
    add(shuttle1, BorderLayout.WEST);
    add(clear, BorderLayout.CENTER);
    add(shuttle2, BorderLayout.EAST);
}