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:net.lmxm.ute.gui.validation.AbstractInputValidator.java

/**
 * Gets the messages dialog./* w  w  w  . j  a  v  a 2  s .c  o m*/
 * 
 * @return the messages dialog
 */
private JDialog getMessagesDialog() {
    if (messagesDialog == null) {
        messagesDialog = new JDialog();

        messagesDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        messagesDialog.setFocusableWindowState(false);
        messagesDialog.setUndecorated(true);

        final Container contentPane = messagesDialog.getContentPane();
        contentPane.setLayout(new FlowLayout());
        contentPane.setBackground(new Color(255, 250, 1));
        contentPane.add(getMessagesIcon());
        contentPane.add(getMessagesLabel());
    }

    return messagesDialog;
}

From source file:org.openmicroscopy.shoola.agents.treeviewer.util.SaveResultsDialog.java

/**
 * Builds and lays out the UI.//w  ww. j  ava  2  s .  c om
 */
private void buildGUI() {
    Container c = getContentPane();
    c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS));
    c.add(buildContents(), BorderLayout.CENTER);
    c.add(buildToolBar(), BorderLayout.SOUTH);
}

From source file:op.tools.DlgListSelector.java

/**
 * This method is called from within the constructor to
 * initialize the form./*from  w  w w  .  java 2 s . com*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
    lblTopic = new JLabel();
    lblDetail = new JLabel();
    jScrollPane1 = new JScrollPane();
    lstSelect = new JList();
    panel1 = new JPanel();
    btnApply = new JButton();
    btnCancel = new JButton();

    //======== this ========
    setResizable(false);
    setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("$rgap, $lcgap, default:grow, $lcgap, $rgap",
            "$rgap, 2*($lgap, fill:default), $lgap, fill:default:grow, $lgap, fill:default, $lgap, $rgap"));

    //---- lblTopic ----
    lblTopic.setFont(new Font("Dialog", Font.BOLD, 14));
    lblTopic.setText("jLabel1");
    contentPane.add(lblTopic, CC.xywh(3, 3, 2, 1));

    //---- lblDetail ----
    lblDetail.setFont(new Font("Dialog", Font.PLAIN, 12));
    lblDetail.setText("jLabel2");
    contentPane.add(lblDetail, CC.xywh(3, 5, 2, 1));

    //======== jScrollPane1 ========
    {

        //---- lstSelect ----
        lstSelect.setModel(new AbstractListModel() {
            String[] values = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };

            @Override
            public int getSize() {
                return values.length;
            }

            @Override
            public Object getElementAt(int i) {
                return values[i];
            }
        });
        lstSelect.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                lstSelectMouseClicked(e);
            }
        });
        jScrollPane1.setViewportView(lstSelect);
    }
    contentPane.add(jScrollPane1, CC.xywh(3, 7, 2, 1));

    //======== panel1 ========
    {
        panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS));

        //---- btnApply ----
        btnApply.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnApply.setText("W\u00e4hlen");
        btnApply.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnApplyActionPerformed(e);
            }
        });
        panel1.add(btnApply);

        //---- btnCancel ----
        btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
        btnCancel.setText("Abbrechen");
        btnCancel.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnCancelActionPerformed(e);
            }
        });
        panel1.add(btnCancel);
    }
    contentPane.add(panel1, CC.xy(3, 9, CC.RIGHT, CC.DEFAULT));
    setSize(600, 441);
    setLocationRelativeTo(null);
}

From source file:org.usfirst.frc.team2084.neuralnetwork.RobotHeadingTest.java

/**
 * /*  w w  w. j a  v a2  s  .c o m*/
 */
@Override
public void run() {
    try {
        final DefaultValueDataset headingData = new DefaultValueDataset(0);
        final DefaultValueDataset desiredHeadingData = new DefaultValueDataset(0);
        final CompassPlot headingPlot = new CompassPlot();
        headingPlot.addDataset(headingData);
        headingPlot.addDataset(desiredHeadingData);
        final JFreeChart headingChart = new JFreeChart("Heading", headingPlot);

        final XYSeries headingTimeSeries = new XYSeries("Heading");
        final XYSeriesCollection headingTimeData = new XYSeriesCollection();
        headingTimeData.addSeries(headingTimeSeries);
        final JFreeChart headingTimeChart = ChartFactory.createXYLineChart("Heading vs. Time", "Time",
                "Heading", headingTimeData, PlotOrientation.VERTICAL, true, true, false);

        final XYSeries errorTimeSeries = new XYSeries("Error");
        final XYSeriesCollection errorTimeData = new XYSeriesCollection();
        errorTimeData.addSeries(errorTimeSeries);
        final JFreeChart errorTimeChart = ChartFactory.createXYLineChart("Error vs. Time", "Time", "Error",
                errorTimeData, PlotOrientation.VERTICAL, true, true, false);

        SwingUtilities.invokeAndWait(() -> {
            final JFrame frame = new JFrame("Charts");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            final Container content = frame.getContentPane();
            content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS));

            final JPanel chartPanel = new JPanel();
            chartPanel.setLayout(new GridLayout(2, 2));
            content.add(chartPanel);

            final ChartPanel headingPanel = new ChartPanel(headingChart);
            chartPanel.add(headingPanel);

            final ChartPanel headingTimePanel = new ChartPanel(headingTimeChart);
            chartPanel.add(headingTimePanel);

            final ChartPanel errorTimePanel = new ChartPanel(errorTimeChart);
            chartPanel.add(errorTimePanel);

            final JPanel buttonPanel = new JPanel();
            content.add(buttonPanel);

            final JButton startButton = new JButton("Start");
            final JButton stopButton = new JButton("Stop");

            startButton.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    stop();
                    startButton.setEnabled(false);
                    stopButton.setEnabled(true);
                    start(headingData, desiredHeadingData, headingTimeSeries, errorTimeSeries);
                }
            });
            buttonPanel.add(startButton);

            stopButton.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    stop();
                    startButton.setEnabled(true);
                    stopButton.setEnabled(false);
                }
            });
            stopButton.setEnabled(false);
            buttonPanel.add(stopButton);

            frame.pack();
            frame.setVisible(true);
        });
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:edu.oregonstate.eecs.mcplan.domains.planetwars.PwVisualization.java

public PwVisualization(final PwGame game, final Dimension dim, final int width, final int height,
        final int sleep) {
    super("Planet Wars!");

    this.sleep = sleep;

    final Container cp = getContentPane();
    cp.setPreferredSize(dim);//from   w w  w  .j  av  a 2 s  .  c  om
    cp.setLayout(null);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setResizable(false);
    setVisible(true);

    canvas = new PwVisualizationCanvas(this, game, width, height);
    canvas.setBounds(0, 0, dim.width, dim.height);
}

From source file:pcgen.gui2.dialog.PostLevelUpDialog.java

private void initComponents() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    JTable table = new JTable(tableModel) {

        @Override/* w ww.jav a  2 s.co m*/
        public TableCellEditor getCellEditor(int row, int column) {
            if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {//TODO: the max roll should be calculated in a different manner
                String hd = levels.getClassTaken(levels.getElementAt(row + oldLevel)).getHD();
                int max = NumberUtils.toInt(hd);
                return new SpinnerEditor(new SpinnerNumberModel(1, 1, max, 1));
            }
            return super.getCellEditor(row, column);
        }

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {
                return new SpinnerRenderer();
            }
            return super.getCellRenderer(row, column);
        }

    };
    table.setCellSelectionEnabled(false);
    table.setRowHeight(new JSpinner().getPreferredSize().height);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);

    JScrollPane scrollPane = new JScrollPane(table);
    pane.add(scrollPane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    JButton button = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$
    button.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$
    button.setActionCommand("Close"); //$NON-NLS-1$
    button.addActionListener(this);
    box.add(button);
    pane.add(box, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            //Make sure to remove the listeners so that the garbage collector can
            //dispose of this dialog and prevent a memory leak
            levels.removeHitPointListener(tableModel);
        }

    });

    Utility.installEscapeCloseOperation(this);
}

From source file:org.cytoscape.ding.impl.cyannotator.dialogs.LoadImageDialog.java

private void initComponents(Container pane) {

    setTitle("Select an Image");
    setResizable(false);//from ww w. ja v  a  2s  . c o  m

    setMinimumSize(new java.awt.Dimension(625, 440));

    pane.setLayout(null);

    jFileChooser1 = new javax.swing.JFileChooser();
    jFileChooser1.setControlButtonsAreShown(false);
    jFileChooser1.setCurrentDirectory(null);
    jFileChooser1.setDialogTitle("");

    jFileChooser1.setAcceptAllFileFilterUsed(false);
    jFileChooser1.addChoosableFileFilter(new ImageFilter());

    pane.add(jFileChooser1);
    jFileChooser1.setBounds(0, 0, 540, 400);

    jButton1 = new javax.swing.JButton();

    jButton1.setText("Open");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    pane.add(jButton1);
    jButton1.setBounds(540, 335, 70, (int) jButton1.getPreferredSize().getHeight());

    jButton2 = new javax.swing.JButton();

    jButton2.setText("Cancel");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });

    pane.add(jButton2);
    jButton2.setBounds(540, 365, 70, (int) jButton2.getPreferredSize().getHeight());
    pack();
}

From source file:org.apache.cayenne.modeler.dialog.ErrorDebugDialog.java

protected void init() {
    setResizable(false);/*from w ww .  jav  a2  s . c  om*/

    Container pane = this.getContentPane();
    pane.setLayout(new BorderLayout());

    // info area
    JEditorPane infoText = new JEditorPane("text/html", infoHTML());
    infoText.setBackground(pane.getBackground());
    infoText.setEditable(false);
    // popup hyperlinks
    infoText.addHyperlinkListener(this);

    JPanel infoPanel = new JPanel();
    infoPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    infoPanel.add(infoText);
    pane.add(infoPanel, BorderLayout.NORTH);

    // exception area
    if (throwable != null) {
        exText.setEditable(false);
        exText.setLineWrap(true);
        exText.setWrapStyleWord(true);
        exText.setRows(16);
        exText.setColumns(40);
        JScrollPane exScroll = new JScrollPane(exText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        exPanel = new JPanel();
        exPanel.setLayout(new BorderLayout());
        exPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        exPanel.add(exScroll, BorderLayout.CENTER);

        // buttons
        showHide = new JButton("");
        showHide.addActionListener(this);
        if (isDetailed()) {
            showDetails();
        } else {
            hideDetails();
        }
    }

    close = new JButton("Close");
    close.addActionListener(this);

    JButton[] buttons = (showHide != null) ? new JButton[] { showHide, close } : new JButton[] { close };
    pane.add(PanelFactory.createButtonPanel(buttons), BorderLayout.SOUTH);

    //add a listener to clear static variables, not to produce garbage
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            instance = null;
        }
    });

    // prepare to display
    this.pack();
    this.centerWindow();
}

From source file:IDlook.java

private void buildGUI() {
    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    accountNumberList = new JList();
    loadAccounts();//from www  .  ja  v a  2  s  .  c  o m
    accountNumberList.setVisibleRowCount(2);
    JScrollPane accountNumberListScrollPane = new JScrollPane(accountNumberList);

    //Do Get Account Button
    getAccountButton = new JButton("Get Account");
    getAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                rs.beforeFirst();
                while (rs.next()) {
                    if (rs.getString("acc_id").equals(accountNumberList.getSelectedValue()))
                        break;
                }
                if (!rs.isAfterLast()) {
                    accountIDText.setText(rs.getString("acc_id"));
                    thumbIDText.setText(rs.getString("thumb_id"));

                    icon = new ImageIcon(rs.getBytes("pic"));
                    createThumbnail();
                    photographLabel.setIcon(iconThumbnail);
                }
            } catch (SQLException selectException) {
                displaySQLErrors(selectException);
            }
        }
    });

    //Do Update Account Button
    updateAccountButton = new JButton("Update Account");
    updateAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                byte[] bytes = new byte[50000];
                FileInputStream fs = new FileInputStream(nailFileText.getText());
                BufferedInputStream bis = new BufferedInputStream(fs);
                bis.read(bytes);

                rs.updateBytes("thumbnail.pic", bytes);
                rs.updateRow();
                bis.close();

                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            } catch (Exception generalE) {
                generalE.printStackTrace();
            }
        }
    });

    //Do insert Account Button
    insertAccountButton = new JButton("Insert Account");
    insertAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                byte[] bytes = new byte[50000];
                FileInputStream fs = new FileInputStream(nailFileText.getText());
                BufferedInputStream bis = new BufferedInputStream(fs);
                bis.read(bytes);

                rs.moveToInsertRow();
                rs.updateInt("thumb_id", Integer.parseInt(thumbIDText.getText()));
                rs.updateInt("acc_id", Integer.parseInt(accountIDText.getText()));
                rs.updateBytes("pic", bytes);
                rs.updateObject("sysobject", null);
                rs.updateTimestamp("ts", new Timestamp(0));
                rs.updateTimestamp("act_ts", new Timestamp(new java.util.Date().getTime()));
                rs.insertRow();
                bis.close();

                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            } catch (Exception generalE) {
                generalE.printStackTrace();
            }
        }
    });

    photographLabel = new JLabel();
    photographLabel.setHorizontalAlignment(JLabel.CENTER);
    photographLabel.setVerticalAlignment(JLabel.CENTER);
    photographLabel.setVerticalTextPosition(JLabel.CENTER);
    photographLabel.setHorizontalTextPosition(JLabel.CENTER);

    JPanel first = new JPanel(new GridLayout(4, 1));
    first.add(accountNumberListScrollPane);
    first.add(getAccountButton);
    first.add(updateAccountButton);
    first.add(insertAccountButton);

    accountIDText = new JTextField(15);
    thumbIDText = new JTextField(15);
    errorText = new JTextArea(5, 15);
    errorText.setEditable(false);

    JPanel second = new JPanel();
    second.setLayout(new GridLayout(2, 1));
    second.add(thumbIDText);
    second.add(accountIDText);

    JPanel third = new JPanel();
    third.add(new JScrollPane(errorText));

    nailFileText = new JTextField(25);

    c.add(first);
    c.add(second);
    c.add(third);
    c.add(nailFileText);
    c.add(photographLabel);

    setSize(500, 500);
    show();
}

From source file:IDlookBlob.java

private void buildGUI() {
    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    accountNumberList = new JList();
    loadAccounts();//w w  w .  j  a va2 s  . c o m
    accountNumberList.setVisibleRowCount(2);
    JScrollPane accountNumberListScrollPane = new JScrollPane(accountNumberList);

    //Do Get Account Button
    getAccountButton = new JButton("Get Account");
    getAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                rs.beforeFirst();
                while (rs.next()) {
                    if (rs.getString("acc_id").equals(accountNumberList.getSelectedValue()))
                        break;
                }
                if (!rs.isAfterLast()) {
                    accountIDText.setText(rs.getString("acc_id"));
                    thumbIDText.setText(rs.getString("thumb_id"));
                    Blob b = rs.getBlob("pic");

                    icon = new ImageIcon(b.getBytes(1L, (int) b.length()));
                    createThumbnail();
                    photographLabel.setIcon(iconThumbnail);
                }
            } catch (SQLException selectException) {
                displaySQLErrors(selectException);
            }
        }
    });

    //Do Update Account Button
    updateAccountButton = new JButton("Update Account");
    updateAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                byte[] bytes = new byte[50000];
                FileInputStream fs = new FileInputStream(nailFileText.getText());
                BufferedInputStream bis = new BufferedInputStream(fs);
                bis.read(bytes);

                rs.updateBytes("thumbnail.pic", bytes);
                rs.updateRow();
                bis.close();

                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            } catch (Exception generalE) {
                generalE.printStackTrace();
            }
        }
    });

    //Do insert Account Button
    insertAccountButton = new JButton("Insert Account");
    insertAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                byte[] bytes = new byte[50000];
                FileInputStream fs = new FileInputStream(nailFileText.getText());
                BufferedInputStream bis = new BufferedInputStream(fs);
                bis.read(bytes);

                rs.moveToInsertRow();
                rs.updateInt("thumb_id", Integer.parseInt(thumbIDText.getText()));
                rs.updateInt("acc_id", Integer.parseInt(accountIDText.getText()));
                rs.updateBytes("pic", bytes);
                rs.updateObject("sysobject", null);
                rs.updateTimestamp("ts", new Timestamp(0));
                rs.updateTimestamp("act_ts", new Timestamp(new java.util.Date().getTime()));
                rs.insertRow();
                bis.close();

                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            } catch (Exception generalE) {
                generalE.printStackTrace();
            }
        }
    });

    photographLabel = new JLabel();
    photographLabel.setHorizontalAlignment(JLabel.CENTER);
    photographLabel.setVerticalAlignment(JLabel.CENTER);
    photographLabel.setVerticalTextPosition(JLabel.CENTER);
    photographLabel.setHorizontalTextPosition(JLabel.CENTER);

    JPanel first = new JPanel(new GridLayout(4, 1));
    first.add(accountNumberListScrollPane);
    first.add(getAccountButton);
    first.add(updateAccountButton);
    first.add(insertAccountButton);

    accountIDText = new JTextField(15);
    thumbIDText = new JTextField(15);
    errorText = new JTextArea(5, 15);
    errorText.setEditable(false);

    JPanel second = new JPanel();
    second.setLayout(new GridLayout(2, 1));
    second.add(thumbIDText);
    second.add(accountIDText);

    JPanel third = new JPanel();
    third.add(new JScrollPane(errorText));

    nailFileText = new JTextField(25);

    c.add(first);
    c.add(second);
    c.add(third);
    c.add(nailFileText);
    c.add(photographLabel);

    setSize(500, 500);
    show();
}