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:op.care.med.inventory.DlgOpenStock.java

/**
 * This method is called from within the constructor to
 * initialize the form./*w  w  w .  j  a v  a2 s  .c  o m*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    lbl1 = new JLabel();
    cmbBestID = new JComboBox<>();
    lbl2 = new JLabel();
    btnClose = new JButton();
    btnOK = new JButton();

    //======== this ========
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setResizable(false);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout(
            "default, $lcgap, default:grow, 2*($lcgap, default), $lcgap, default:grow, $lcgap, default",
            "default, $lgap, fill:default, 21dlu, default, $lgap, default"));

    //---- lbl1 ----
    lbl1.setText("Die Packung mit der Nummer:");
    lbl1.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(lbl1, CC.xy(3, 3));

    //---- cmbBestID ----
    cmbBestID.setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    cmbBestID.setFont(new Font("Arial", Font.PLAIN, 14));
    cmbBestID.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            cmbBestIDItemStateChanged(e);
        }
    });
    contentPane.add(cmbBestID, CC.xy(5, 3));

    //---- lbl2 ----
    lbl2.setText("anbrechen.");
    lbl2.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(lbl2, CC.xywh(7, 3, 3, 1));

    //---- btnClose ----
    btnClose.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
    btnClose.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnCloseActionPerformed(e);
        }
    });
    contentPane.add(btnClose, CC.xy(7, 5));

    //---- btnOK ----
    btnOK.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
    btnOK.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            btnOKActionPerformed(e);
        }
    });
    contentPane.add(btnOK, CC.xy(9, 5));
    setSize(455, 165);
    setLocationRelativeTo(getOwner());
}

From source file:DisplayModeModel.java

private void initComponents(Container c) {
    setContentPane(c);//from   w  w w. j  a va  2  s.co m
    c.setLayout(new BorderLayout());
    // Current DM
    JPanel currentPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    c.add(currentPanel, BorderLayout.NORTH);
    JLabel current = new JLabel("Current Display Mode : ");
    currentPanel.add(current);
    currentPanel.add(currentDM);
    // Display Modes
    JPanel modesPanel = new JPanel(new GridLayout(1, 2));
    c.add(modesPanel, BorderLayout.CENTER);
    // List of display modes
    for (int i = 0; i < COLUMN_WIDTHS.length; i++) {
        TableColumn col = new TableColumn(i, COLUMN_WIDTHS[i]);
        col.setIdentifier(COLUMN_NAMES[i]);
        col.setHeaderValue(COLUMN_NAMES[i]);
        dmList.addColumn(col);
    }
    dmList.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    dmList.getSelectionModel().addListSelectionListener(this);
    modesPanel.add(dmPane);
    // Controls
    JPanel controlsPanelA = new JPanel(new BorderLayout());
    modesPanel.add(controlsPanelA);
    JPanel controlsPanelB = new JPanel(new GridLayout(2, 1));
    controlsPanelA.add(controlsPanelB, BorderLayout.NORTH);
    // Exit
    JPanel exitPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    controlsPanelB.add(exitPanel);
    exitPanel.add(exit);
    // Change DM
    JPanel changeDMPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    controlsPanelB.add(changeDMPanel);
    changeDMPanel.add(changeDM);
    controlsPanelA.add(new JPanel(), BorderLayout.CENTER);
}

From source file:FontDemoLabel.java

public FontDemoLabel() {
    super("Font Demo - Label");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container cp = getContentPane();

    // get font name list
    fl = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();

    // IGNORE the setLayout and North/South stuff...
    // we will discuss it in a few pages!

    cp.setLayout(new BorderLayout());
    cp.add(BorderLayout.NORTH, new Label("Number of Fonts = " + fl.length, Label.CENTER));
    cp.add(BorderLayout.CENTER, p = new JPanel());
    p.setLayout(new GridLayout(5, 0, 5, 5));

    for (int i = 0; i < fl.length; i++) {
        JLabel lab;/*from w ww .  j  a v  a2  s  . c o m*/

        // The crux of the matter: for each font name,
        // create a label using the name as the text,
        // AND set the font to be the named font!
        p.add(lab = new JLabel(fl[i]));
        lab.setFont(new Font(fl[i], Font.ITALIC | Font.BOLD, 14));
    }
    pack();
}

From source file:netcap.JcaptureConfiguration.java

private void initGUI() {
    Container container = getContentPane();
    container.setLayout(ViewModules.createBoxLayout(container, BoxLayout.X_AXIS));
    try {//from w ww .j  av  a2s  . c o m
        JPanel jPanel_west = ViewModules.createSimplePanel(null, -1f, -1f, BoxLayout.Y_AXIS);
        JPanel netPanel = getNetDevicesPanel();
        checkBox = getPromiscCheckBox();
        JPanel filterPanel = getProtocolFilterPanel();
        ViewModules.addComponent(jPanel_west, netPanel, checkBox, filterPanel);

        JPanel jPanel_east = ViewModules.createSimplePanel(null, -1f, -1f, BoxLayout.Y_AXIS);
        JPanel caplenPanel = getCaplenPanel();
        JPanel buttonPanel = getOkCanelPanel();
        ViewModules.addComponent(jPanel_east, caplenPanel, buttonPanel);

        container.add(jPanel_west);
        container.add(jPanel_east);
        pack();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:op.care.prescription.DlgDiscontinue.java

/**
 * This method is called from within the constructor to
 * initialize the form.//from w w  w .jav  a 2 s .c o  m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc=" Erzeugter Quelltext ">//GEN-BEGIN:initComponents
private void initComponents() {
    lblQuestion = new JLabel();
    cmbArztAb = new JComboBox();
    cmbKHAb = new JComboBox();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnOK = new JButton();

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

    //---- lblQuestion ----
    lblQuestion.setText("Wer hat die Verordnung abgesetzt ?");
    lblQuestion.setFont(new Font("Arial", Font.PLAIN, 18));
    contentPane.add(lblQuestion, CC.xy(2, 3));

    //---- cmbArztAb ----
    cmbArztAb.setModel(new DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    cmbArztAb.setFont(new Font("Arial", Font.PLAIN, 14));
    cmbArztAb.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            cmbArztAbKeyPressed(e);
        }
    });
    contentPane.add(cmbArztAb, CC.xy(2, 5));

    //---- cmbKHAb ----
    cmbKHAb.setModel(new DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
    cmbKHAb.setFont(new Font("Arial", Font.PLAIN, 14));
    contentPane.add(cmbKHAb, CC.xy(2, 7));

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

        //---- btnCancel ----
        btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
        btnCancel.setText(null);
        btnCancel.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnCancelActionPerformed(e);
            }
        });
        panel1.add(btnCancel);

        //---- btnOK ----
        btnOK.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnOK.setText(null);
        btnOK.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnOKActionPerformed(e);
            }
        });
        panel1.add(btnOK);
    }
    contentPane.add(panel1, CC.xy(2, 9, CC.RIGHT, CC.DEFAULT));
    setSize(490, 175);
    setLocationRelativeTo(getOwner());
}

From source file:com.fisher.mainFrame.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - nick xu
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    scrollPaneLogArea = new JScrollPane();
    logArea = new JTextArea();
    buttonBar = new JPanel();
    startButton = new JButton();
    stopButton = new JButton();

    //======== this ========
    setTitle("Fish Transform Trading");
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== dialogPane ========
    {//  w  ww .  j a  v a  2s  .c  o m
        dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
        dialogPane.setPreferredSize(new Dimension(758, 900));

        // JFormDesigner evaluation mark
        dialogPane.setBorder(new javax.swing.border.CompoundBorder(
                new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                        "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                        javax.swing.border.TitledBorder.BOTTOM,
                        new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red),
                dialogPane.getBorder()));
        dialogPane.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent e) {
                if ("border".equals(e.getPropertyName()))
                    throw new RuntimeException();
            }
        });

        dialogPane.setLayout(new BorderLayout());

        //======== contentPanel ========
        {

            //======== scrollPaneLogArea ========
            {
                scrollPaneLogArea.setViewportView(logArea);
            }

            GroupLayout contentPanelLayout = new GroupLayout(contentPanel);
            contentPanel.setLayout(contentPanelLayout);
            contentPanelLayout.setHorizontalGroup(contentPanelLayout.createParallelGroup()
                    .addComponent(scrollPaneLogArea, GroupLayout.DEFAULT_SIZE, 734, Short.MAX_VALUE));
            contentPanelLayout
                    .setVerticalGroup(contentPanelLayout.createParallelGroup()
                            .addGroup(contentPanelLayout
                                    .createSequentialGroup().addComponent(scrollPaneLogArea,
                                            GroupLayout.PREFERRED_SIZE, 225, GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 476, Short.MAX_VALUE)));
        }
        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, 85, 80 };
            ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] { 1.0, 0.0, 0.0 };

            //---- startButton ----
            startButton.setText("Start");
            startButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    startButtonActionPerformed(e);
                }
            });
            buttonBar.add(startButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));

            //---- stopButton ----
            stopButton.setText("Stop");
            stopButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    stopButtonActionPerformed(e);
                }
            });
            buttonBar.add(stopButton, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        }
        dialogPane.add(buttonBar, BorderLayout.SOUTH);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    pack();
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:fungus.PeerRatioChartFrame.java

public PeerRatioChartFrame(String prefix) {
    simulationCycles = Configuration.getDouble(PAR_SIMULATION_CYCLES);
    this.setTitle("MycoNet Statistics Chart");
    graph = JungGraphObserver.getGraph();

    //data.add(-1,0);
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.setAutoWidth(false);//w  ww . ja  v a 2s  . c  om
    dataset.setIntervalWidth(simulationCycles);

    //averageUtilizationData = new XYSeries("Average Utilization");
    //dataset.addSeries(averageUtilizationData);
    //averageStableUtilizationData = new XYSeries("Avg Stable Util");
    //dataset.addSeries(averageStableUtilizationData);
    bulwarkRatioData = new XYSeries("Bulwark Ratio");
    dataset.addSeries(bulwarkRatioData);
    biomassRatioData = new XYSeries("Biomass Ratio");
    dataset.addSeries(biomassRatioData);
    hyphaRatioData = new XYSeries("Hypha Ratio");
    dataset.addSeries(hyphaRatioData);
    // stableHyphaRatioData = new XYSeries("Stable Hypha Ratio");
    // dataset.addSeries(stableHyphaRatioData);

    //XYSeriesCollection dataset;

    JFreeChart peerRatioChart = ChartFactory.createXYLineChart("Bulwark Metrics", "Cycle", "Peer State Ratio",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    ChartPanel peerRatioChartPanel = new ChartPanel(peerRatioChart);

    XYPlot xyplot = peerRatioChart.getXYPlot();

    NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis();
    NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setRange(0, 1);

    //chart.setBackgroundPaint(Color.white);
    //XYPlot plot = chart.getXYPlot();

    //        BufferedImage chartImage = chart.createBufferedImage(500,300);
    //        chartLabel = new JLabel();
    //chartLabel.setIcon(new ImageIcon(chartImage));

    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    JPanel labelPane = new JPanel();
    labelPane.setLayout(new GridLayout(1, 1));
    //chartPane.setPreferredSize(new java.awt.Dimension(500, 300));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    ////contentPane.add(labelPane,BorderLayout.PAGE_START);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(peerRatioChartPanel, BorderLayout.CENTER);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    ////contentPane.add(buttonPane, BorderLayout.PAGE_END);

    //data = node.getHyphaData();
    //link = node.getHyphaLink();
    //mycocast = node.getMycoCast();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    //chartPanel.add(chartLabel);

    /*JButton updateButton = new JButton("Refresh");
      ActionListener updater = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      refreshData();
      }
      };
      updateButton.addActionListener(updater);
            
      JButton closeButton = new JButton("Close");
      ActionListener closer = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      closeFrame();
      }
      };
      closeButton.addActionListener(closer);
            
      buttonPane.add(Box.createHorizontalGlue());
      buttonPane.add(updateButton);
      buttonPane.add(Box.createRigidArea(new Dimension(5,0)));
      buttonPane.add(closeButton);
      refreshData();
    */

    //JungGraphObserver.addChangeListener(this);

    this.pack();
    this.setVisible(true);
}

From source file:opendial.gui.stateviewer.DistributionViewer.java

/**
 * Constructs or update the current viewer with the distribution.
 * //from   ww w  . j av  a  2  s. co  m
 * @param currentState the updated dialogue state
 */
protected void update(DialogueState currentState) {

    if (!currentState.hasChanceNode(queryVar)) {
        return;
    } else if (lastDistrib != null
            && this.lastDistrib.equals(currentState.getChanceNode(queryVar).getDistrib())) {
        return;
    }
    this.lastDistrib = currentState.queryProb(queryVar);

    Container container = new Container();
    container.setLayout(new BorderLayout());
    container.add(new JLabel("        "), BorderLayout.NORTH);
    container.add(new JLabel("        "), BorderLayout.WEST);
    container.add(new JLabel("        "), BorderLayout.EAST);
    container.add(new JLabel("        "), BorderLayout.SOUTH);

    try {
        IndependentProbDistribution indepDistrib = currentState.queryProb(queryVar);
        if (indepDistrib instanceof ContinuousDistribution) {
            container.add(generatePanel(indepDistrib.toContinuous()), BorderLayout.CENTER);
        } else {
            container.add(generatePanel(indepDistrib.toDiscrete()), BorderLayout.CENTER);
        }
    } catch (DialException e) {
        log.warning("could not generate distribution viewer: " + e);
    }
    setContentPane(container);
    if (getSize().height == 0 || getSize().width == 0) {
        pack();
        setLocation(new Random().nextInt(500), (new Random()).nextInt(500));
        setVisible(true);
    } else {
        validate();
    }
}

From source file:opendial.gui.utils.DistributionViewer.java

/**
 * Constructs or update the current viewer with the distribution.
 * //from  w w  w  .  j a  va 2  s.c o  m
 * @param currentState the updated dialogue state
 */
protected void update(DialogueState currentState) {

    if (!currentState.hasChanceNode(queryVar)) {
        return;
    } else if (lastDistrib != null
            && this.lastDistrib.equals(currentState.getChanceNode(queryVar).getDistrib())) {
        return;
    }
    this.lastDistrib = currentState.queryProb(queryVar);

    Container container = new Container();
    container.setLayout(new BorderLayout());
    container.add(new JLabel("        "), BorderLayout.NORTH);
    container.add(new JLabel("        "), BorderLayout.WEST);
    container.add(new JLabel("        "), BorderLayout.EAST);
    container.add(new JLabel("        "), BorderLayout.SOUTH);

    try {
        IndependentDistribution indepDistrib = currentState.queryProb(queryVar);
        if (indepDistrib instanceof ContinuousDistribution) {
            container.add(generatePanel(indepDistrib.toContinuous()), BorderLayout.CENTER);
        } else {
            container.add(generatePanel(indepDistrib.toDiscrete()), BorderLayout.CENTER);
        }
    } catch (RuntimeException e) {
        log.warning("could not generate distribution viewer: " + e);
    }
    setContentPane(container);
    if (getSize().height == 0 || getSize().width == 0) {
        pack();
        setLocation(new Random().nextInt(500), (new Random()).nextInt(500));
        setVisible(true);
    } else {
        validate();
    }
}

From source file:SortedTableModel.java

public SimpleTableTestMultilineHeader() {
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    TableValues tv = new TableValues();
    SortedTableModel stm = new SortedTableModel(tv);
    stm.sortRows(TableValues.ACCOUNT_BALANCE, true);
    table = new JTable(stm);
    table.setRowSelectionAllowed(false);
    table.setColumnSelectionAllowed(true);
    TableColumnModel tcm = table.getColumnModel();
    TableColumn tc = tcm.getColumn(TableValues.GENDER);
    MultiLineHeaderRenderer mlhr = new MultiLineHeaderRenderer();
    tc = tcm.getColumn(TableValues.ACCOUNT_BALANCE);
    tc.setHeaderRenderer(mlhr);/*  w w w.  j  ava 2s .c  o  m*/
    renderer = new SortedColumnHeaderRenderer(stm, mlhr);
    int count = tcm.getColumnCount();
    for (int i = 0; i < count; i++) {
        tc = tcm.getColumn(i);
        tc.setHeaderRenderer(renderer);
    }
    JTableHeaderToolTips jthtt = new JTableHeaderToolTips(table.getColumnModel());
    jthtt.setToolTips(new String[] { "Customer's First Name", "Customer's Last Name",
            "Customer's Date of Birth", "Customer's Account Balance", "Customer's Gender" });
    table.setTableHeader(jthtt);
    JScrollPane jsp = new JScrollPane(table);
    pane.add(jsp, BorderLayout.CENTER);
    addHeaderListener();
}