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.hexidec.ekit.component.UnicodeDialog.java

public void init(int startIndex) {
    String customFont = Translatrix.getTranslationString("UnicodeDialogButtonFont");
    if (customFont != null && customFont.length() > 0) {
        buttonFont = new Font(Translatrix.getTranslationString("UnicodeDialogButtonFont"), Font.PLAIN, 12);
    } else {//  ww w . ja  v a2 s .  com
        buttonFont = new Font("Monospaced", Font.PLAIN, 12);
    }

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    JPanel centerPanel = new JPanel();
    centerPanel.setLayout(new GridLayout(0, 17, 0, 0));
    buttonGroup = new ButtonGroup();

    int prefButtonWidth = 32;
    int prefButtonHeight = 32;

    centerPanel.add(new JLabel(""));
    for (int labelLoop = 0; labelLoop < 16; labelLoop++) {
        JLabel jlblMarker = new JLabel(
                "x" + (labelLoop > 9 ? "" + (char) (65 + (labelLoop - 10)) : "" + labelLoop));
        jlblMarker.setHorizontalAlignment(SwingConstants.CENTER);
        jlblMarker.setVerticalAlignment(SwingConstants.CENTER);
        jlblMarker.setForeground(new Color(0.5f, 0.5f, 0.75f));
        centerPanel.add(jlblMarker);
    }

    int labelcount = 0;
    for (int counter = 0; counter < UNICODEBLOCKSIZE; counter++) {
        if ((counter % 16) == 0) {
            JLabel jlblMarker = new JLabel(
                    (labelcount > 9 ? "" + (char) (65 + (labelcount - 10)) : "" + labelcount) + "x");
            jlblMarker.setHorizontalAlignment(SwingConstants.CENTER);
            jlblMarker.setVerticalAlignment(SwingConstants.CENTER);
            jlblMarker.setForeground(new Color(0.5f, 0.5f, 0.75f));
            centerPanel.add(jlblMarker);
            labelcount++;
        }
        buttonArray[counter] = new JToggleButton(" ");
        buttonArray[counter].getModel().setActionCommand("");
        buttonArray[counter].setFont(buttonFont);
        buttonArray[counter].setBorder(
                javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
        buttonArray[counter].addActionListener(this);
        if (counter == 0) {
            FontRenderContext frcLocal = ((java.awt.Graphics2D) (parentEkit.getGraphics()))
                    .getFontRenderContext();
            Rectangle2D fontBounds = buttonFont.getMaxCharBounds(frcLocal);
            int maxCharWidth = (int) (Math.abs(fontBounds.getX())) + (int) (Math.abs(fontBounds.getWidth()));
            int maxCharHeight = (int) (Math.abs(fontBounds.getY())) + (int) (Math.abs(fontBounds.getHeight()));
            Insets buttonInsets = buttonArray[counter].getBorder().getBorderInsets(buttonArray[counter]);
            prefButtonWidth = maxCharWidth + buttonInsets.left + buttonInsets.right;
            prefButtonHeight = maxCharHeight + buttonInsets.top + buttonInsets.bottom;
        }
        buttonArray[counter].setPreferredSize(new Dimension(prefButtonWidth, prefButtonHeight));
        centerPanel.add(buttonArray[counter]);
        buttonGroup.add(buttonArray[counter]);
    }

    JPanel selectorPanel = new JPanel();

    jcmbBlockSelector = new JComboBox(unicodeBlocks);
    jcmbBlockSelector.setSelectedIndex(startIndex);
    jcmbBlockSelector.setActionCommand(CMDCHANGEBLOCK);
    jcmbBlockSelector.addActionListener(this);

    String[] sPages = { "1" };
    jcmbPageSelector = new JComboBox(sPages);
    jcmbPageSelector.setSelectedIndex(0);
    jcmbPageSelector.setActionCommand(CMDCHANGEBLOCK);
    jcmbPageSelector.addActionListener(this);

    selectorPanel.add(new JLabel(Translatrix.getTranslationString("SelectorToolUnicodeBlock")));
    selectorPanel.add(jcmbBlockSelector);
    selectorPanel.add(new JLabel(Translatrix.getTranslationString("SelectorToolUnicodePage")));
    selectorPanel.add(jcmbPageSelector);

    JPanel buttonPanel = new JPanel();

    JButton closeButton = new JButton(Translatrix.getTranslationString("DialogClose"));
    closeButton.setActionCommand("close");
    closeButton.addActionListener(this);
    buttonPanel.add(closeButton);

    contentPane.add(centerPanel, BorderLayout.CENTER);
    contentPane.add(selectorPanel, BorderLayout.NORTH);
    contentPane.add(buttonPanel, BorderLayout.SOUTH);

    this.pack();

    populateButtons(startIndex, 0);

    this.setVisible(true);
}

From source file:yp.tibco.com.yang.lottery.client.GraphicalLotteryClient.java

private void initComponents() {
    JLabel jLabel1 = new JLabel();
    jTextFieldHost = new JTextField();
    jButtonConnect = new JButton();
    JLabel jLabel3 = new JLabel();
    jSpinnerWidth = new JSpinner();
    JLabel label5 = new JLabel();
    jSpinnerChars = new JSpinner();
    checkBoxContinuous = new JCheckBox();
    JLabel jLabel2 = new JLabel();
    jTextFieldPort = new JTextField();
    jButtonDisconnect = new JButton();
    JLabel jLabel4 = new JLabel();
    jSpinnerHeight = new JSpinner();
    jButtonSendRequest = new JButton();
    imagePanel1 = new LotteryPanel();

    //======== this ========
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setMinimumSize(new Dimension(700, 300));
    setPreferredSize(new Dimension(740, 600));
    Container contentPane = getContentPane();
    contentPane.setLayout(new GridBagLayout());
    ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] { 36, 167, 99, 41, 66, 75, 57, 96, 0,
            0 };/*  w  w w. jav a  2 s .c om*/
    ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] { 10, 31, 31, 256, 0 };
    ((GridBagLayout) contentPane.getLayout()).columnWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
            0.0, 1.0, 1.0E-4 };
    ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 1.0E-4 };

    //---- jLabel1 ----
    jLabel1.setText("Host");
    contentPane.add(jLabel1, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
    contentPane.add(jTextFieldHost, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 10), 0, 0));

    //---- jButtonConnect ----
    jButtonConnect.setText("Connect");
    jButtonConnect.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            jButtonConnectActionPerformed();
        }
    });
    contentPane.add(jButtonConnect, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 10), 0, 0));

    //---- jLabel3 ----
    jLabel3.setText("Width");
    contentPane.add(jLabel3, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    contentPane.add(jSpinnerWidth, new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 10), 0, 0));

    //---- label5 ----
    label5.setText("characters");
    contentPane.add(label5, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 5, 5), 0, 0));
    contentPane.add(jSpinnerChars, new GridBagConstraints(6, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 10), 0, 0));

    //---- checkBoxContinuous ----
    checkBoxContinuous.setText("continuous");
    contentPane.add(checkBoxContinuous, new GridBagConstraints(7, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 10), 0, 0));

    //---- jLabel2 ----
    jLabel2.setText("Port");
    contentPane.add(jLabel2, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
    contentPane.add(jTextFieldPort, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 10), 0, 0));

    //---- jButtonDisconnect ----
    jButtonDisconnect.setText("Disconnect");
    jButtonDisconnect.setEnabled(false);
    jButtonDisconnect.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            jButtonDisconnectActionPerformed();
        }
    });
    contentPane.add(jButtonDisconnect, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 10), 0, 0));

    //---- jLabel4 ----
    jLabel4.setText("Height");
    contentPane.add(jLabel4, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
    contentPane.add(jSpinnerHeight, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 10), 0, 0));

    //---- jButtonSendRequest ----
    jButtonSendRequest.setText("Send Request");
    jButtonSendRequest.setEnabled(false);
    jButtonSendRequest.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            jButtonSendRequestActionPerformed();
        }
    });
    contentPane.add(jButtonSendRequest, new GridBagConstraints(5, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 5, 5, 10), 0, 0));

    //======== imagePanel1 ========
    {
        imagePanel1.setBackground(new Color(51, 153, 255));
        imagePanel1.setPreferredSize(new Dimension(500, 500));

        { // compute preferred size
            Dimension preferredSize = new Dimension();
            for (int i = 0; i < imagePanel1.getComponentCount(); i++) {
                Rectangle bounds = imagePanel1.getComponent(i).getBounds();
                preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
                preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
            }
            Insets insets = imagePanel1.getInsets();
            preferredSize.width += insets.right;
            preferredSize.height += insets.bottom;
            imagePanel1.setMinimumSize(preferredSize);
            imagePanel1.setPreferredSize(preferredSize);
        }
    }
    contentPane.add(imagePanel1, new GridBagConstraints(0, 3, 9, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(8, 5, 8, 5), 0, 0));
    pack();
    setLocationRelativeTo(getOwner());
}

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

public HeadingNeuralNetworkTrainer() {
    outputGraphNetworkSeries = new XYSeries("Network Prediction");
    outputGraphDataSeries = new XYSeries("Error");
    final XYSeriesCollection data = new XYSeriesCollection();
    data.addSeries(outputGraphDataSeries);
    data.addSeries(outputGraphNetworkSeries);
    outputGraph = ChartFactory.createXYLineChart("Error vs. Output", "Time", "Error", data,
            PlotOrientation.VERTICAL, true, true, false);

    NumberAxis xAxis = new NumberAxis();
    xAxis.setRange(new Range(-Math.PI, Math.PI));
    xAxis.setAutoRange(false);//from  www.j  a v a  2s  .c  o m
    NumberAxis yAxis = new NumberAxis();
    yAxis.setRange(new Range(-1, 1));

    XYPlot plot = (XYPlot) outputGraph.getPlot();
    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    network = new Network(new int[] { 1, 5, 1 }, eta, momentum, new TransferFunction.HyperbolicTangent());

    try {
        SwingUtilities.invokeAndWait(() -> {
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            final Container content = frame.getContentPane();
            content.setLayout(new BorderLayout());

            outputGraphPanel = new ChartPanel(outputGraph);
            outputGraphPanel.setDomainZoomable(false);
            outputGraphPanel.setRangeZoomable(false);
            graphPanel.add(outputGraphPanel);

            graphPanel.setLayout(new GridLayout(1, 1));
            content.add(graphPanel, BorderLayout.CENTER);
            {

                JLabel etaLabel = new JLabel("Eta:");
                etaLabel.setLabelFor(etaField);
                etaField.setText(Double.toString(network.getEta()));
                etaField.setColumns(5);
                etaField.addPropertyChangeListener("value",
                        (evt) -> eta = ((Number) evt.getNewValue()).doubleValue());
                controlPanel.add(etaLabel);
                controlPanel.add(etaField);

                JLabel momentumLabel = new JLabel("Momentum:");
                momentumLabel.setLabelFor(etaField);
                momentumField.setText(Double.toString(network.getMomentum()));
                momentumField.setColumns(5);
                momentumField.addPropertyChangeListener("value",
                        (evt) -> momentum = ((Number) evt.getNewValue()).doubleValue());
                controlPanel.add(momentumLabel);
                controlPanel.add(momentumField);

                JLabel iterationsLabel = new JLabel("Iterations:");
                iterationsLabel.setLabelFor(iterationsField);
                iterationsField.setText(Integer.toString(iterations));
                iterationsField.setColumns(10);
                iterationsField.addPropertyChangeListener("value",
                        (evt) -> iterations = ((Number) evt.getNewValue()).intValue());
                controlPanel.add(iterationsLabel);
                controlPanel.add(iterationsField);
            }

            chooseDataButton.addActionListener((e) -> {
                if (dataDirectoryChooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) {
                    dataDirectory = dataDirectoryChooser.getSelectedFile();
                    displayData();
                }
            });
            controlPanel.add(chooseDataButton);

            trainButton.addActionListener((e) -> trainNetwork());
            controlPanel.add(trainButton);

            saveButton.addActionListener((e) -> {
                saveNetwork();
            });
            controlPanel.add(saveButton);

            content.add(controlPanel, BorderLayout.SOUTH);

            dataDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setVisible(true);
        });
    } catch (InvocationTargetException | InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:org.nuclos.client.layout.wysiwyg.editor.ui.panels.WYSIWYGMetaInformationPicker.java

/**
 * /*from  w  w w.  j  av a  2 s.c o  m*/
 * @param values
 * @param parent
 */
private WYSIWYGMetaInformationPicker(Window owner, List<String> values, TableLayoutPanel parent) {
    super(owner);

    this.setIconImage(NuclosIcons.getInstance().getScaledDialogIcon(48).getImage());

    Container contentPane = this.getContentPane();
    contentPane.setLayout(new TableLayout(layoutDefinition));

    originalValues = values;

    filter = new JTextField();

    /** the keybinding*/
    filter.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            /** up and down cursor for selecting the next or previous entry */
            if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) {
                int selectedItem = itemList.getSelectedIndex();
                if (e.getKeyCode() == KeyEvent.VK_UP)
                    selectedItem--;
                else if (e.getKeyCode() == KeyEvent.VK_DOWN)
                    selectedItem++;

                if (selectedItem < 0) {
                    selectedItem = listModel.getSize() - 1;
                } else if (selectedItem == listModel.getSize()) {
                    selectedItem = 0;
                }

                itemList.setSelectedIndex(selectedItem);
                itemList.ensureIndexIsVisible(selectedItem);
            } else if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                /** enter for saving, esc for cancel */
                if (e.getKeyCode() == KeyEvent.VK_ESCAPE)
                    selectedEntity = null;
                dispose();

            } else {
                /** every other key is used for filtering the entries */
                filterItems(WYSIWYGMetaInformationPicker.this.filter.getText());
            }
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

    });
    /** request focus in the filter window */
    filter.requestFocusInWindow();

    this.add(filter, new TableLayoutConstraints(1, 1, 3, 1));
    itemList = new JList(listModel);
    itemList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    itemList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (itemList.getSelectedValue() != null)
                selectedEntity = (String) itemList.getSelectedValue();
        }

    });
    freeExpr = new JCheckBox(SpringLocaleDelegate.getInstance()
            .getMessageFromResource("wysiwg.metainformation.picker.freeexpr"));
    this.add(freeExpr, new TableLayoutConstraints(1, 2, 3, 2));
    freeExpr.setVisible(true);

    // double click on item to select
    itemList.addMouseListener(new MouseListener() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
                performSaveAction();
            }
        }

        @Override
        public void mouseEntered(MouseEvent e) {
        }

        @Override
        public void mouseExited(MouseEvent e) {
        }

        @Override
        public void mousePressed(MouseEvent e) {
        }

        @Override
        public void mouseReleased(MouseEvent e) {
        }

    });

    filterItems(null);

    JScrollPane scrollpane = new JScrollPane(itemList);

    this.add(scrollpane, new TableLayoutConstraints(1, 4, 3, 4));

    JButton apply = new JButton(BUTTON_LABELS.LABEL_APPLY);
    apply.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            performSaveAction();
        }

    });
    this.add(apply, new TableLayoutConstraints(1, 6));

    JButton cancel = new JButton(BUTTON_LABELS.LABEL_CANCEL);
    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            performCancelAction();
        }

    });

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            performCancelAction();
        }
    });

    this.add(cancel, new TableLayoutConstraints(3, 6));

    this.setBounds(this.getBounds().x, this.getBounds().y, 300, 400);
    this.setTitle(TABLELAYOUT_PANEL.SELECT_FIELD_FOR_METAINFORMATION);
    this.setModal(true);
}

From source file:edu.oregonstate.eecs.mcplan.domains.racegrid.RacegridVisualization.java

public RacegridVisualization(final RacegridSimulator sim, final TerrainType[][] circuit, final int scale) {
    if (sim != null) {
        this.sim = sim;
        this.state = sim.state();
    }//from   w w  w  . j  a  v  a 2 s  .  c  o m

    this.scale = scale;

    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                frame = new JFrame();
                final Container cp = frame.getContentPane();
                cp.setLayout(new BorderLayout());

                draw_panel_ = new DrawPanel(circuit);
                final Dimension d = new Dimension(scale * circuit[0].length + 20, scale * circuit.length + 20);
                draw_panel_.setPreferredSize(d);
                draw_panel_.setSize(d);
                cp.add(draw_panel_, BorderLayout.CENTER);

                control_panel_ = new ControlPanel();
                cp.add(control_panel_, BorderLayout.SOUTH);

                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setResizable(false);
                frame.pack();
                frame.setVisible(true);
            }
        });
    } catch (final Exception ex) {
        throw new RuntimeException(ex);
    }

    if (sim != null) {
        updateStateOnEDT(sim.state());
    }
}

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

private void initLayout() {
    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    {//layout top bar
        JPanel bar = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.anchor = GridBagConstraints.BASELINE;
        gbc.insets = new Insets(8, 6, 8, 2);
        bar.add(new JLabel("Select Template:"), gbc);
        gbc.insets = new Insets(8, 2, 8, 6);
        gbc.weightx = 1;//from w w  w .  j  a  va  2  s.com
        bar.add(sheetBox, gbc);
        pane.add(bar, BorderLayout.NORTH);
    }
    {
        Box vbox = Box.createVerticalBox();
        previewPanelParent.setPreferredSize(new Dimension(600, 800));
        vbox.add(previewPanelParent);
        vbox.add(progressBar);
        pane.add(vbox, BorderLayout.CENTER);
    }
    {
        Box hbox = Box.createHorizontalBox();
        hbox.add(new JLabel("Page:"));
        hbox.add(Box.createHorizontalStrut(4));
        hbox.add(pageBox);
        hbox.add(Box.createHorizontalStrut(10));
        hbox.add(new JLabel("Zoom:"));
        hbox.add(Box.createHorizontalStrut(4));
        hbox.add(zoomBox);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(zoomInButton);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(zoomOutButton);
        hbox.add(Box.createHorizontalGlue());
        hbox.add(printButton);
        hbox.add(Box.createHorizontalStrut(5));
        hbox.add(cancelButton);
        hbox.setBorder(BorderFactory.createEmptyBorder(8, 5, 8, 5));
        pane.add(hbox, BorderLayout.SOUTH);
    }
}

From source file:edu.oregonstate.eecs.mcplan.domains.taxi.TaxiVisualization.java

public TaxiVisualization(final TaxiSimulator sim, final int[][] topology, final ArrayList<int[]> locations,
        final int scale) {
    if (sim != null) {
        this.sim = sim;
        this.state = sim.state();
    }//from   ww  w .  j  a v  a2 s  .  com

    this.scale = scale;

    try {
        SwingUtilities.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                final JFrame frame = new JFrame();
                final Container cp = frame.getContentPane();
                cp.setLayout(new BorderLayout());

                draw_panel_ = new DrawPanel(topology, locations);
                final Dimension d = new Dimension(scale * topology.length + 20,
                        scale * topology[0].length + 20);
                draw_panel_.setPreferredSize(d);
                draw_panel_.setSize(d);
                cp.add(draw_panel_, BorderLayout.CENTER);

                control_panel_ = new ControlPanel();
                cp.add(control_panel_, BorderLayout.SOUTH);

                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setResizable(false);
                frame.pack();
                frame.setVisible(true);
            }
        });
    } catch (final Exception ex) {
        throw new RuntimeException(ex);
    }

    if (sim != null) {
        updateStateOnEDT(sim.state());
    }
}

From source file:op.controlling.DlgQMSPlan.java

/**
 * This method is called from within the constructor to
 * initialize the form.//from  w  w  w  . j a  v  a  2 s .co  m
 * 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() {
    pnlLeft = new JPanel();
    lblTitle = new JLabel();
    txtTitle = new JTextField();
    lblNotify = new JideLabel();
    cmbNotify = new JComboBox();
    jScrollPane3 = new JScrollPane();
    txtDescription = new JTextArea();
    lblDescription = new JideLabel();
    scrollPane1 = new JScrollPane();
    lstNotify = new JList();
    lblTags = new JLabel();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnSave = new JButton();

    //======== this ========
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("14dlu, $lcgap, pref:grow, $ugap, pref",
            "fill:14dlu, $lgap, fill:default:grow, $rgap, pref, $lgap, 14dlu"));

    //======== pnlLeft ========
    {
        pnlLeft.setLayout(new FormLayout("pref, $lcgap, default:grow, $lcgap, pref, $lcgap, default:grow",
                "default, $lgap, fill:default, $rgap, fill:default:grow, $lgap, 40dlu, $rgap, default"));

        //---- lblTitle ----
        lblTitle.setFont(new Font("Arial", Font.PLAIN, 18));
        lblTitle.setText("Stichwort");
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        pnlLeft.add(lblTitle, CC.xy(3, 1));

        //---- txtTitle ----
        txtTitle.setFont(new Font("Arial", Font.PLAIN, 20));
        txtTitle.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                txtTitleFocusGained(e);
            }
        });
        pnlLeft.add(txtTitle, CC.xy(3, 3));

        //---- lblNotify ----
        lblNotify.setText("text");
        lblNotify.setOrientation(1);
        lblNotify.setFont(new Font("Arial", Font.PLAIN, 18));
        lblNotify.setHorizontalAlignment(SwingConstants.CENTER);
        lblNotify.setClockwise(false);
        pnlLeft.add(lblNotify, CC.xywh(5, 3, 1, 3));

        //---- cmbNotify ----
        cmbNotify.addItemListener(new ItemListener() {
            @Override
            public void itemStateChanged(ItemEvent e) {
                cmbNotifyItemStateChanged(e);
            }
        });
        pnlLeft.add(cmbNotify, CC.xy(7, 3));

        //======== jScrollPane3 ========
        {

            //---- txtDescription ----
            txtDescription.setColumns(20);
            txtDescription.setLineWrap(true);
            txtDescription.setRows(5);
            txtDescription.setWrapStyleWord(true);
            txtDescription.setFont(new Font("Arial", Font.PLAIN, 14));
            txtDescription.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtDescriptionFocusGained(e);
                }
            });
            jScrollPane3.setViewportView(txtDescription);
        }
        pnlLeft.add(jScrollPane3, CC.xy(3, 5));

        //---- lblDescription ----
        lblDescription.setFont(new Font("Arial", Font.PLAIN, 18));
        lblDescription.setText("Situation");
        lblDescription.setOrientation(1);
        lblDescription.setClockwise(false);
        pnlLeft.add(lblDescription, CC.xy(1, 5, CC.DEFAULT, CC.CENTER));

        //======== scrollPane1 ========
        {

            //---- lstNotify ----
            lstNotify.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            lstNotify.addListSelectionListener(new ListSelectionListener() {
                @Override
                public void valueChanged(ListSelectionEvent e) {
                    lstNotifyValueChanged(e);
                }
            });
            scrollPane1.setViewportView(lstNotify);
        }
        pnlLeft.add(scrollPane1, CC.xy(7, 5));

        //---- lblTags ----
        lblTags.setFont(new Font("Arial", Font.PLAIN, 18));
        lblTags.setText("Markierung");
        lblTags.setHorizontalAlignment(SwingConstants.CENTER);
        pnlLeft.add(lblTags, CC.xywh(3, 9, 5, 1));
    }
    contentPane.add(pnlLeft, CC.xy(3, 3));

    //======== panel1 ========
    {
        panel1.setLayout(new HorizontalLayout(5));

        //---- 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);

        //---- btnSave ----
        btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnSave.setText(null);
        btnSave.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnSaveActionPerformed(e);
            }
        });
        panel1.add(btnSave);
    }
    contentPane.add(panel1, CC.xy(3, 5, CC.RIGHT, CC.DEFAULT));
    setSize(710, 495);
    setLocationRelativeTo(getOwner());
}

From source file:org.archiviststoolkit.plugin.utils.CodeViewerDialog.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();
    scrollPane1 = new JScrollPane();
    messageTextArea = new JTextArea();
    buttonBar = new JPanel();
    recordTestPanel = new JPanel();
    storeButton = new JButton();
    testButton = new JButton();
    label1 = new JLabel();
    testHostUrlTextField = new JTextField();
    deleteButton = new JButton();
    okButton = new JButton();
    CellConstraints cc = new CellConstraints();

    //======== this ========
    setTitle("Code Viewer");
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== dialogPane ========
    {//from  w w  w  .ja  v a  2s. co  m
        dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
        dialogPane.setLayout(new BorderLayout());

        //======== contentPanel ========
        {
            contentPanel.setLayout(new BorderLayout());

            //======== scrollPane1 ========
            {

                //---- messageTextArea ----
                messageTextArea.setRows(4);
                messageTextArea.setEditable(false);
                scrollPane1.setViewportView(messageTextArea);
            }
            contentPanel.add(scrollPane1, BorderLayout.SOUTH);
        }
        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 };

            //======== recordTestPanel ========
            {
                recordTestPanel.setLayout(new FormLayout(
                        new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                                FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                                FormFactory.DEFAULT_COLSPEC, FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                                new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
                                FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC },
                        RowSpec.decodeSpecs("default")));

                //---- storeButton ----
                storeButton.setText("Store");
                storeButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        storeButtonActionPerformed();
                    }
                });
                recordTestPanel.add(storeButton, cc.xy(1, 1));

                //---- testButton ----
                testButton.setText("Test");
                testButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        testButtonActionPerformed();
                    }
                });
                recordTestPanel.add(testButton, cc.xy(3, 1));

                //---- label1 ----
                label1.setText("Url");
                recordTestPanel.add(label1, cc.xy(5, 1));
                recordTestPanel.add(testHostUrlTextField, cc.xy(7, 1));

                //---- deleteButton ----
                deleteButton.setText("Delete");
                deleteButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        deleteButtonActionPerformed();
                    }
                });
                recordTestPanel.add(deleteButton, cc.xy(9, 1));
            }
            buttonBar.add(recordTestPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));

            //---- okButton ----
            okButton.setText("OK");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    okButtonActionPerformed();
                }
            });
            buttonBar.add(okButton, new GridBagConstraints(1, 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:phex.gui.dialogs.NewDownloadDialog.java

/**
 * //w ww.j a  v a2s  .c  om
 */
private void prepareComponent() {
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            closeDialog();
        }
    });
    CellConstraints cc = new CellConstraints();
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());
    JPanel contentPanel = new JPanel();
    //JPanel contentPanel = new FormDebugPanel();
    contentPane.add(contentPanel, BorderLayout.CENTER);

    FormLayout layout = new FormLayout("2dlu, fill:d:grow, 2dlu", // columns
            "p, p, 2dlu, p, 6dlu, p, 3dlu, p 6dlu"); //row
    PanelBuilder builder = new PanelBuilder(layout, contentPanel);

    DialogBanner banner = new DialogBanner(Localizer.getString("NewDownload_BannerHeader"),
            Localizer.getString("NewDownload_BannerSubHeader"));
    builder.add(banner, cc.xywh(1, 1, 3, 1));

    builder.add(new JSeparator(), cc.xywh(1, 2, 3, 1));

    downloadTabPane = new JTabbedPane();
    JPanel urlPanel = createByUrlPanel();
    downloadTabPane.addTab(Localizer.getString("NewDownload_ByUrl"), urlPanel);
    JPanel magmaPanel = createByMagmaPanel();
    downloadTabPane.addTab(Localizer.getString("NewDownload_ByMagmaFile"), magmaPanel);
    JPanel rssPanel = createByRSSPanel();
    downloadTabPane.addTab(Localizer.getString("NewDownload_ByRSSFile"), rssPanel);
    builder.add(downloadTabPane, cc.xy(2, 4));

    builder.add(new JSeparator(), cc.xywh(1, 6, 3, 1));

    JButton cancelBtn = new JButton(Localizer.getString("Cancel"));
    cancelBtn.addActionListener(new CancelBtnListener());
    JButton okBtn = new JButton(Localizer.getString("OK"));
    okBtn.addActionListener(new OkBtnListener());
    JPanel btnPanel = ButtonBarFactory.buildOKCancelBar(okBtn, cancelBtn);
    builder.add(btnPanel, cc.xy(2, 8));

    pack();
    setLocationRelativeTo(getParent());
}