Example usage for java.awt Container setLayout

List of usage examples for java.awt Container setLayout

Introduction

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

Prototype

public void setLayout(LayoutManager mgr) 

Source Link

Document

Sets the layout manager for this container.

Usage

From source file:MainClass.java

public MainClass() {
    super("MainClass");

    Container contentPane = getContentPane();
    contentPane.setLayout(new FlowLayout());
    contentPane.add(new JButton("OK"));
    contentPane.add(new JButton("Cancel"));

    applyOrientation(this, ComponentOrientation.RIGHT_TO_LEFT);
}

From source file:Main.java

public Main() {
    super("Main");

    Container contentPane = getContentPane();
    contentPane.setLayout(new FlowLayout());
    contentPane.add(new JButton("OK"));
    contentPane.add(new JButton("Cancel"));

    applyOrientation(this, ComponentOrientation.RIGHT_TO_LEFT);
}

From source file:SimpleMenus.java

public void init() {
    for (int i = 0; i < items.length; i++) {
        items[i].addActionListener(al);/*from   ww  w  .  j a  v  a 2s .  c  om*/
        menus[i % 3].add(items[i]);
    }
    JMenuBar mb = new JMenuBar();
    for (int i = 0; i < menus.length; i++)
        mb.add(menus[i]);
    setJMenuBar(mb);
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(t);
}

From source file:SwingRadioButtons.java

public void init() {
    rb1.addActionListener(al);/*  www .j  a  v a 2 s.c o m*/
    rb2.addActionListener(al);
    rb3.addActionListener(al);
    g.add(rb1);
    g.add(rb2);
    g.add(rb3);
    t.setEditable(false);
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(t);
    cp.add(rb1);
    cp.add(rb2);
    cp.add(rb3);
}

From source file:MyDialog.java

public MyDialog(JFrame parent) {
    super(parent, "My dialog", true);
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(new JLabel("Here is my dialog"));
    JButton ok = new JButton("OK");
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dispose(); // Closes the dialog
        }//from w w w  .ja  va 2s. c o m
    });
    cp.add(ok);
    setSize(150, 125);
}

From source file:LookAndFeel.java

public LookAndFeel() {
    super("Look And Feel");
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    for (int i = 0; i < samples.length; i++)
        cp.add(samples[i]);/*from  w  ww  .  j  a v  a  2s .  co m*/
}

From source file:MainClass.java

public MainClass() {
    super("JSpinner Icon Test");
    setSize(300, 80);//w ww. ja v a2  s.  c  o  m
    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Container c = getContentPane();
    c.setLayout(new GridLayout(0, 2));

    Icon nums[] = new Icon[] { new ImageIcon("1.gif"), new ImageIcon("2.gif"), new ImageIcon("3.gif"),
            new ImageIcon("4.gif"), new ImageIcon("5.gif"), new ImageIcon("6.gif") };
    JSpinner s1 = new JSpinner(new SpinnerListModel(nums));
    s1.setEditor(new IconEditor(s1));
    c.add(new JLabel(" Icon Spinner"));
    c.add(s1);

    setVisible(true);
}

From source file:TableValues.java

public Main() {
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    TableValues tv = new TableValues();
    table = new JTable(tv);
    pane.add(table, BorderLayout.CENTER);
}

From source file:TableValues.java

public ExtendsAbstractTableModel() {
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    TableValues tv = new TableValues();
    table = new JTable(tv);
    pane.add(table, BorderLayout.CENTER);
}

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);/*www  . j  a v  a  2s.  c o  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());
    });
}