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:com.db2eshop.gui.dialog.ShowDialog.java

private void buildEditor() {
    this.getContentPane().removeAll();
    Container container = this.getContentPane();
    container.setLayout(new MigLayout("filly"));
    Map<String, LabeledForm<?>> components = uiBinder.create(model);
    for (LabeledForm<?> labeledInput : components.values()) {
        labeledInput.setEditable(false);
        container.add(labeledInput, "wrap");
    }/*from   ww  w  .ja v a  2  s  .co  m*/

    this.repaint();
}

From source file:JiltBefore.java

JiltBefore(String s) {
    super("JiltBefore: " + s);

    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());

    mb = new JMenuBar();
    setJMenuBar(mb);/*  w  ww .  ja va2s.c o m*/

    JMenuItem mi;
    // The File Menu...
    fm = new JMenu("File");
    fm.add(mi = new JMenuItem("Open"));
    mi.addActionListener(this);
    fm.add(mi = new JMenuItem("Close"));
    mi.addActionListener(this);
    fm.addSeparator();
    fm.add(mi = new JMenuItem("Print"));
    mi.addActionListener(this);
    fm.addSeparator();
    fm.add(mi = new JMenuItem("Exit"));
    exitItem = mi; // save for action handler
    mi.addActionListener(this);
    mb.add(fm);

    // The Options Menu...
    om = new JMenu("Options");
    fm.add(mi = new JMenuItem("Enable"));
    opSubm = new JMenu("SubOptions");
    opSubm.add(new JMenuItem("Alpha"));
    opSubm.add(new JMenuItem("Gamma"));
    opSubm.add(new JMenuItem("Delta"));
    om.add(opSubm);
    mb.add(om);

    // The Help Menu...
    hm = new JMenu("Help");
    hm.add(mi = new JMenuItem("About"));
    mi.addActionListener(this);
    hm.add(mi = new JMenuItem("Topics"));
    mi.addActionListener(this);
    mb.add(hm);
    // mb.setHelpMenu(hm); // needed for portability (Motif, etc.).

    // the main window
    cp.add(new JLabel("Menu Demo Window"));
    // pack();
    setSize(250, 200);
}

From source file:JTreeDemo.java

/** Construct the object including its GUI */
public JTreeDemo() {
    super("JTreeDemo");
    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());

    root = new DefaultMutableTreeNode("root");

    child = new DefaultMutableTreeNode("Colors");
    root.add(child);/* w w w  . ja v  a  2s . c o  m*/
    child.add(new DefaultMutableTreeNode("Cyan"));
    child.add(new DefaultMutableTreeNode("Magenta"));
    child.add(new DefaultMutableTreeNode("Yellow"));
    child.add(new DefaultMutableTreeNode("Black"));

    myTree = new JTree(root);

    // cp.add(BorderLayout.CENTER, myTree);
    //JScrollPane scroller = new JScrollPane();
    //scroller.getViewport().add(myTree);
    JScrollPane scroller = new JScrollPane(myTree);
    cp.add(BorderLayout.CENTER, scroller);

    cp.add(BorderLayout.NORTH, addButton = new JButton("Add"));
    addButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            // Insert more nodes into the tree
            child = new DefaultMutableTreeNode("Flavors");
            child.add(new DefaultMutableTreeNode("Java"));
            child.add(new DefaultMutableTreeNode("Espresso"));
            child.add(new DefaultMutableTreeNode("Hey Joe!"));
            child.add(new DefaultMutableTreeNode("Charcoal"));
            child.add(new DefaultMutableTreeNode("Paint Remover"));

            // Notify the model, which will add it and create an event, and
            // send it up the tree...

            ((DefaultTreeModel) myTree.getModel()).insertNodeInto(child, root, 0);
        }
    });

    cp.add(BorderLayout.SOUTH, quitButton = new JButton("Exit"));
    quitButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            dispose();
            System.exit(0);
        }
    });
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            setVisible(false);
            dispose();
            System.exit(0);
        }
    });
    pack();
}

From source file:MyViewChooser.java

public MyViewChooser() {
    super("File View Test Frame");
    setSize(350, 200);//  w ww .ja  va  2s. c om
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    parent = this;

    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    JButton openButton = new JButton("Open");
    final JLabel statusbar = new JLabel("Output of your selection will go here");

    openButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            JFileChooser chooser = new JFileChooser();

            // Ok, set up our own file view for the chooser
            chooser.setFileView(new ThumbNailFileView(MyViewChooser.this));

            int option = chooser.showOpenDialog(parent);
            if (option == JFileChooser.APPROVE_OPTION) {
                statusbar.setText("You chose " + chooser.getSelectedFile().getName());
            } else {
                statusbar.setText("You cancelled.");
            }
        }
    });

    c.add(openButton);
    c.add(statusbar);
}

From source file:org.broad.igv.peaks.PeakTimePlotFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    buttonBar = new JPanel();

    //======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== dialogPane ========
    {//w w  w . j  a va2 s .  c om
        dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
        dialogPane.setLayout(new BorderLayout());

        //======== contentPanel ========
        {
            contentPanel.setLayout(new BorderLayout());
        }
        dialogPane.add(contentPanel, BorderLayout.CENTER);

        //======== buttonBar ========
        {
            buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
            buttonBar.setLayout(new GridBagLayout());
            ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] { 0, 80 };
            ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] { 1.0, 0.0 };
        }
        dialogPane.add(buttonBar, BorderLayout.SOUTH);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    setSize(495, 455);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:AnotherMenuDemo.java

AnotherMenuDemo(String s) {
    super("MenuDemo: " + s);

    Container cp = this;
    cp.setLayout(new FlowLayout());

    mb = new MenuBar();
    setMenuBar(mb); // Frame implements MenuContainer

    MenuItem mi;//from  w  ww . j a  va  2  s  .  co m
    // The File Menu...
    fm = new Menu("File");
    fm.add(mi = new MenuItem("Open", new MenuShortcut('O')));
    mi.addActionListener(this);
    fm.add(mi = new MenuItem("Close", new MenuShortcut('W')));
    mi.addActionListener(this);
    fm.addSeparator();
    fm.add(mi = new MenuItem("Print", new MenuShortcut('P')));
    mi.addActionListener(this);
    fm.addSeparator();
    fm.add(mi = new MenuItem("Exit", new MenuShortcut('Q')));
    exitItem = mi; // save for action handler
    mi.addActionListener(this);
    mb.add(fm);

    // The Options Menu...
    om = new Menu("Options");
    cb = new CheckboxMenuItem("AutoSave");
    cb.setState(true);
    cb.addItemListener(this);
    om.add(cb);
    opSubm = new Menu("SubOptions");
    opSubm.add(new MenuItem("Alpha"));
    opSubm.add(new MenuItem("Gamma"));
    opSubm.add(new MenuItem("Delta"));
    om.add(opSubm);
    mb.add(om);

    // The Help Menu...
    hm = new Menu("Help");
    hm.add(mi = new MenuItem("About"));
    mi.addActionListener(this);
    hm.add(mi = new MenuItem("Topics"));
    mi.addActionListener(this);
    mb.add(hm);
    mb.setHelpMenu(hm); // needed for portability (Motif, etc.).

    // the main window
    cp.add(new Label("Menu Demo Window", 200, 150));
    pack();
}

From source file:MainClass.java

public MainClass() {
    JToggleButton tog = new JToggleButton("ToggleButton");
    JCheckBox cb = new JCheckBox("CheckBox");
    JRadioButton radio = new JRadioButton("RadioButton");

    SimpleListener sl = new SimpleListener();
    tog.addActionListener(sl);//w w w .  jav a  2 s.  c  o m
    cb.addActionListener(sl);
    radio.addActionListener(sl);

    Box buttonBox = new Box(BoxLayout.Y_AXIS);
    buttonBox.add(tog);
    buttonBox.add(cb);
    buttonBox.add(radio);

    undoButton.setEnabled(false);
    redoButton.setEnabled(false);

    undoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            try {
                edit.undo();
            } catch (CannotUndoException ex) {
                ex.printStackTrace();
            } finally {
                undoButton.setEnabled(edit.canUndo());
                redoButton.setEnabled(edit.canRedo());
            }
        }
    });

    redoButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            try {
                edit.redo();
            } catch (CannotRedoException ex) {
                ex.printStackTrace();
            } finally {
                undoButton.setEnabled(edit.canUndo());
                redoButton.setEnabled(edit.canRedo());
            }
        }
    });

    Box undoRedoBox = new Box(BoxLayout.X_AXIS);
    undoRedoBox.add(Box.createGlue());
    undoRedoBox.add(undoButton);
    undoRedoBox.add(Box.createHorizontalStrut(2));
    undoRedoBox.add(redoButton);
    undoRedoBox.add(Box.createGlue());

    Container content = getContentPane();
    content.setLayout(new BorderLayout());
    content.add(buttonBox, BorderLayout.CENTER);
    content.add(undoRedoBox, BorderLayout.SOUTH);
    setSize(400, 150);
}

From source file:com.db2eshop.gui.dialog.RemoveDialog.java

/**
 * <p>buildEditor.</p>//from www  .ja v a2 s.c  o  m
 */
public void buildEditor() {
    this.getContentPane().removeAll();
    Container container = this.getContentPane();
    container.setLayout(new MigLayout("filly"));
    components = uiBinder.create(model);
    for (LabeledForm<?> labeledInput : components.values()) {
        labeledInput.setEditable(false);
        container.add(labeledInput, "wrap");
    }
}

From source file:com.db2eshop.gui.dialog.AddDialog.java

private void buildEditor() {
    this.getContentPane().removeAll();
    Container container = this.getContentPane();
    container.setLayout(new MigLayout("fill"));
    components = uiBinder.create(table.getEntityClazz());
    for (LabeledForm<?> labeledInput : components.values()) {
        container.add(labeledInput, "wrap");
    }/*www. j ava2 s .  c o m*/
}

From source file:src.main.java.com.github.hsmrs_gui.project.view.MainFrame.java

public void setup() {
    Container cp = this.getContentPane();
    cp.setLayout(new MigLayout("insets 0", "[20%]0[60%]0[20%]", "[75%]0[25%]"));
    //cp.setLayout(new BorderLayout());
    cp.setBackground(Color.white);

    //Task List/*from   w  ww . ja va2s  . c o  m*/
    taskPane = new TaskListPanel(taskListModel);
    //taskPane.setMaximumSize(new Dimension(500, 200));

    //Situational Awareness View
    situAwareView = new SAPanel();

    //Robot List
    robotPane = new RobotListView(robotListModel);

    //Console
    feedbackPane = new FeedbackPane();

    //      bottomPane = new JTabbedPane();
    //      JPanel panel3 = new JPanel(false);
    //      JLabel filler3 = new JLabel("Console Filler");
    //      filler3.setHorizontalAlignment(JLabel.CENTER);
    //      panel3.add(filler3);
    //      bottomPane.addTab("Console Output", panel3);

    //Image label
    //imageDisplay = new JLabel();
    //defaultImage = new ImageIcon(getClass().getResource("/com/github/hsmrs_gui/project/resources/wall_e.jpg"));

    cp.add(taskPane, "left, grow");
    cp.add(situAwareView, "left, push, grow");
    cp.add(robotPane, "right, push, grow, wrap");
    cp.add(feedbackPane, "push, grow, span 3");

    pack();
}