Example usage for java.awt BorderLayout WEST

List of usage examples for java.awt BorderLayout WEST

Introduction

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

Prototype

String WEST

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

Click Source Link

Document

The west layout constraint (left side of container).

Usage

From source file:Main.java

public Main() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JPanel p = new JPanel(new BorderLayout());
    JTextField tf = new JTextField(5);
    JLabel label = new JLabel(new ImageIcon("Test.gif"));
    label.setOpaque(true);/*from w  w w  . j  a v  a 2  s  .c om*/
    label.setBackground(tf.getBackground());
    label.setPreferredSize(new Dimension(label.getPreferredSize().width, tf.getPreferredSize().height));
    p.setBorder(tf.getBorder());
    tf.setBorder(null);
    p.add(label, BorderLayout.WEST);
    p.add(tf, BorderLayout.CENTER);
    JPanel p1 = new JPanel();
    p1.add(p);
    getContentPane().add(p1);
    pack();
    setLocationRelativeTo(null);
}

From source file:TextForm.java

public TextForm(String[] labels, char[] mnemonics, int[] widths, String[] tips) {
    super(new BorderLayout());
    JPanel labelPanel = new JPanel(new GridLayout(labels.length, 1));
    JPanel fieldPanel = new JPanel(new GridLayout(labels.length, 1));
    add(labelPanel, BorderLayout.WEST);
    add(fieldPanel, BorderLayout.CENTER);
    fields = new JTextField[labels.length];

    for (int i = 0; i < labels.length; i += 1) {
        fields[i] = new JTextField();
        if (i < tips.length)
            fields[i].setToolTipText(tips[i]);
        if (i < widths.length)
            fields[i].setColumns(widths[i]);

        JLabel lab = new JLabel(labels[i], JLabel.RIGHT);
        lab.setLabelFor(fields[i]);/*from  w w  w .jav  a 2s. co m*/
        if (i < mnemonics.length)
            lab.setDisplayedMnemonic(mnemonics[i]);

        labelPanel.add(lab);
        JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT));
        p.add(fields[i]);
        fieldPanel.add(p);
    }
}

From source file:Main.java

Main() {
    Updater updater = new Updater();
    width.addChangeListener(updater);/*  w  w w .ja  va 2  s.com*/
    height.addChangeListener(updater);
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    f.add(width, BorderLayout.NORTH);
    f.add(height, BorderLayout.WEST);
    f.add(dynamicLabel, BorderLayout.CENTER);
    f.setSize(210, 210);
    f.setVisible(true);

}

From source file:WebBrowserBasedOnJEditorPane.java

public WebBrowserBasedOnJEditorPane() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    JPanel pnlURL = new JPanel();
    pnlURL.setLayout(new BorderLayout());
    pnlURL.add(new JLabel("URL: "), BorderLayout.WEST);
    pnlURL.add(txtURL, BorderLayout.CENTER);
    getContentPane().add(pnlURL, BorderLayout.NORTH);
    getContentPane().add(ep, BorderLayout.CENTER);

    getContentPane().add(lblStatus, BorderLayout.SOUTH);

    ActionListener al = new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            try {
                String url = ae.getActionCommand().toLowerCase();
                if (url.startsWith("http://"))
                    url = url.substring(7);
                ep.setPage("http://" + IDN.toASCII(url));
            } catch (Exception e) {
                e.printStackTrace();//w w  w  . ja v  a 2s  .  c  o  m
                JOptionPane.showMessageDialog(WebBrowserBasedOnJEditorPane.this,
                        "Browser problem: " + e.getMessage());
            }
        }
    };
    txtURL.addActionListener(al);

    setSize(300, 300);
    setVisible(true);
}

From source file:Main.java

public Main() {
    setLayout(new BorderLayout());
    treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel);
    treeScroll = new JScrollPane(tree);
    add(treeScroll, BorderLayout.WEST);

    properties.setProperty("foo1", "bar1");
    properties.setProperty("foo2", "bar2");
    properties.setProperty("foo3", "bar3");
    properties.setProperty("foo4", "bar4");

    Set<Object> keySet = properties.keySet();
    for (Object key : keySet) {
        root.add(new DefaultMutableTreeNode(key));
    }//from w  ww  .jav  a2 s. co m

    tree.expandPath(new TreePath(root));
    descriptionLabel = new JLabel(NOTHING_SELECTED);
    add(descriptionLabel, BorderLayout.CENTER);

    tree.addTreeSelectionListener(e -> {
        DefaultMutableTreeNode selection = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
        if (selection != null) {
            String key = (String) selection.getUserObject();
            String command = properties.getProperty(key);
            descriptionLabel.setText(command);
        } else {
            descriptionLabel.setText(NOTHING_SELECTED);
        }
    });
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
}

From source file:Main.java

public Main() {
    textField.addActionListener(e -> {
        comboBox.addItem(textField.getText());
        textField.setText("");
        comboBox.showPopup();/*from  w ww.  j  av  a 2  s  . c  o  m*/
    });

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frame.add(comboBox, BorderLayout.SOUTH);
    frame.add(textField, BorderLayout.WEST);
    frame.add(new JLabel("Enter to add Item  "), BorderLayout.EAST);
    frame.pack();
    frame.setVisible(true);
}

From source file:MainClass.java

public MainClass() {
    setLayout(new BorderLayout());
    model = new DefaultListModel();
    list = new JList(model);
    JScrollPane pane = new JScrollPane(list);
    JButton addButton = new JButton("Add Element");
    JButton removeButton = new JButton("Remove Element");
    for (int i = 0; i < 15; i++)
        model.addElement("Element " + i);

    addButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            model.addElement("Element " + counter);
            counter++;/*  w w  w .  j a  va2s.c  o m*/
        }
    });
    removeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (model.getSize() > 0)
                model.removeElementAt(0);
        }
    });

    add(pane, BorderLayout.NORTH);
    add(addButton, BorderLayout.WEST);
    add(removeButton, BorderLayout.EAST);
}

From source file:Main.java

void initContainer(Container container) {
    container.setLayout(new GridLayout(1, 0));
    buttonPanel = new JPanel(new GridLayout(0, 1));
    Object[] menuNames = { "ROOT",
            new Object[] { "A", new Object[] { "CSS", "HTML", "SQL", "Java" }, "Code",
                    new Object[] { "Test", "S", "C" } },
            new Object[] { "Code 1", new Object[] { "A", "I", "H", "O" }, "Code",
                    new Object[] { "P", "S", "C" }, "C" } };

    DefaultMutableTreeNode currentNode = processHierarchy(menuNames);
    menuTree = new JTree(currentNode);
    menuTree.setVisibleRowCount(10);//w  w w .  ja  v a  2  s.  co  m
    menuTree.expandRow(2);
    initializeButtons(currentNode);
    container.add(buttonPanel, BorderLayout.WEST);
    container.add(new JScrollPane(menuTree), BorderLayout.EAST);
    menuTree.addTreeSelectionListener(e -> {
        initializeButtons((DefaultMutableTreeNode) menuTree.getLastSelectedPathComponent());
    });
}

From source file:SelectionMonitor.java

public SelectionMonitor() {
    setLayout(new BorderLayout());

    list = new JList(label);
    JScrollPane pane = new JScrollPane(list);

    //  Format the list and the buttons in a vertical box
    Box rightBox = new Box(BoxLayout.Y_AXIS);
    Box leftBox = new Box(BoxLayout.Y_AXIS);

    //  Monitor all list selections
    list.addListSelectionListener(new RadioUpdater());

    for (int i = 0; i < label.length; i++) {
        checks[i] = new JCheckBox("Selection " + i);
        checks[i].setEnabled(false);//from   w  ww  .  j  a  v a 2  s .  c  o m
        rightBox.add(checks[i]);
    }
    leftBox.add(pane);
    add(rightBox, BorderLayout.EAST);
    add(leftBox, BorderLayout.WEST);
}

From source file:com.silkroad.ui.renderer.node.BuddyNode.java

public BuddyNode(UIBuddy buddy) {
    super(buddy);
    this.buddy = buddy;

    // ?//from   www.j  a v a2s .c om
    avatarImage = new WebDecoratedImage();
    avatarImage.setShadeWidth(1);
    avatarImage.setRound(4);
    avatarImage.setDrawGlassLayer(false);

    // 
    nickLbl = new WebLabel();
    signLbl = new WebLabel();
    nickLbl.setFontSize(14);
    signLbl.setFontSize(13);
    signLbl.setForeground(Color.GRAY);
    GroupPanel textGroup = new GroupPanel(0, false, nickLbl, signLbl);
    textGroup.setMargin(0, 5, 0, 5);

    view.add(avatarImage, BorderLayout.WEST);
    view.add(new CenterPanel(textGroup, false, true), BorderLayout.CENTER);
    view.setMargin(5);
}