Example usage for java.awt GridBagLayout GridBagLayout

List of usage examples for java.awt GridBagLayout GridBagLayout

Introduction

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

Prototype

public GridBagLayout() 

Source Link

Document

Creates a grid bag layout manager.

Usage

From source file:lu.lippmann.cdb.ext.hydviga.ui.GapFillingFrame.java

/**
 * Constructor./*from   w  ww . j a  v  a  2 s.  c o m*/
 */
public GapFillingFrame(final AbstractTabView atv, final Instances dataSet, final Attribute attr,
        final int dateIdx, final int valuesBeforeAndAfter, final int position, final int gapsize,
        final StationsDataProvider gcp, final boolean inBatchMode) {
    super();

    setTitle("Gap filling for " + attr.name() + " ("
            + dataSet.attribute(dateIdx).formatDate(dataSet.instance(position).value(dateIdx)) + " -> "
            + dataSet.attribute(dateIdx).formatDate(dataSet.instance(position + gapsize).value(dateIdx)) + ")");
    LogoHelper.setLogo(this);

    this.atv = atv;

    this.dataSet = dataSet;
    this.attr = attr;
    this.dateIdx = dateIdx;
    this.valuesBeforeAndAfter = valuesBeforeAndAfter;
    this.position = position;
    this.gapsize = gapsize;

    this.gcp = gcp;

    final Instances testds = WekaDataProcessingUtil.buildFilteredDataSet(dataSet, 0,
            dataSet.numAttributes() - 1, Math.max(0, position - valuesBeforeAndAfter),
            Math.min(position + gapsize + valuesBeforeAndAfter, dataSet.numInstances() - 1));

    this.attrNames = WekaTimeSeriesUtil.getNamesOfAttributesWithoutGap(testds);

    this.isGapSimulated = (this.attrNames.contains(attr.name()));
    this.originaldataSet = new Instances(dataSet);
    if (this.isGapSimulated) {
        setTitle(getTitle() + " [SIMULATED GAP]");
        /*final JXLabel fictiveGapLabel=new JXLabel("                                                                        FICTIVE GAP");
        fictiveGapLabel.setForeground(Color.RED);
        fictiveGapLabel.setFont(new Font(fictiveGapLabel.getFont().getName(), Font.PLAIN,fictiveGapLabel.getFont().getSize()*2));
        final JXPanel fictiveGapPanel=new JXPanel();
        fictiveGapPanel.setLayout(new BorderLayout());
        fictiveGapPanel.add(fictiveGapLabel,BorderLayout.CENTER);
        getContentPane().add(fictiveGapPanel,BorderLayout.NORTH);*/
        this.attrNames.remove(attr.name());
        this.originalDataBeforeGapSimulation = dataSet.attributeToDoubleArray(attr.index());
        for (int i = position; i < position + gapsize; i++)
            dataSet.instance(i).setMissing(attr);
    }

    final Object[] attrNamesObj = this.attrNames.toArray();

    this.centerPanel = new JXPanel();
    this.centerPanel.setLayout(new BorderLayout());
    getContentPane().add(this.centerPanel, BorderLayout.CENTER);

    //final JXPanel algoPanel=new JXPanel();
    //getContentPane().add(algoPanel,BorderLayout.NORTH);
    final JXPanel filterPanel = new JXPanel();
    //filterPanel.setLayout(new BoxLayout(filterPanel, BoxLayout.Y_AXIS));      
    filterPanel.setLayout(new GridBagLayout());
    final GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(10, 10, 10, 10);
    getContentPane().add(filterPanel, BorderLayout.WEST);

    final JXComboBox algoCombo = new JXComboBox(Algo.values());
    algoCombo.setBorder(new TitledBorder("Algorithm"));
    filterPanel.add(algoCombo, gbc);
    gbc.gridy++;

    final JXLabel infoLabel = new JXLabel("Usable = with no missing values on the period");
    //infoLabel.setBorder(new TitledBorder(""));
    filterPanel.add(infoLabel, gbc);
    gbc.gridy++;

    final JList<Object> timeSeriesList = new JList<Object>(attrNamesObj);
    timeSeriesList.setBorder(new TitledBorder("Usable time series"));
    timeSeriesList.setSelectionMode(DefaultListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    final JScrollPane jcpMap = new JScrollPane(timeSeriesList);
    jcpMap.setPreferredSize(new Dimension(225, 150));
    jcpMap.setMinimumSize(new Dimension(225, 150));
    filterPanel.add(jcpMap, gbc);
    gbc.gridy++;

    final JXPanel mapPanel = new JXPanel();
    mapPanel.setBorder(new TitledBorder(""));
    mapPanel.setLayout(new BorderLayout());
    mapPanel.add(gcp.getMapPanel(Arrays.asList(attr.name()), this.attrNames, true), BorderLayout.CENTER);
    filterPanel.add(mapPanel, gbc);
    gbc.gridy++;

    final JXLabel mssLabel = new JXLabel(
            "<html>Most similar usable serie: <i>[... computation ...]</i></html>");
    mssLabel.setBorder(new TitledBorder(""));
    filterPanel.add(mssLabel, gbc);
    gbc.gridy++;

    final JXLabel nsLabel = new JXLabel("<html>Nearest usable serie: <i>[... computation ...]</i></html>");
    nsLabel.setBorder(new TitledBorder(""));
    filterPanel.add(nsLabel, gbc);
    gbc.gridy++;

    final JXLabel ussLabel = new JXLabel("<html>Upstream serie: <i>[... computation ...]</i></html>");
    ussLabel.setBorder(new TitledBorder(""));
    filterPanel.add(ussLabel, gbc);
    gbc.gridy++;

    final JXLabel dssLabel = new JXLabel("<html>Downstream serie: <i>[... computation ...]</i></html>");
    dssLabel.setBorder(new TitledBorder(""));
    filterPanel.add(dssLabel, gbc);
    gbc.gridy++;

    final JCheckBox hideOtherSeriesCB = new JCheckBox("Hide the others series");
    hideOtherSeriesCB.setSelected(DEFAULT_HIDE_OTHER_SERIES_OPTION);
    filterPanel.add(hideOtherSeriesCB, gbc);
    gbc.gridy++;

    final JCheckBox showErrorCB = new JCheckBox("Show error on plot");
    filterPanel.add(showErrorCB, gbc);
    gbc.gridy++;

    final JCheckBox zoomCB = new JCheckBox("Auto-adjusted size");
    zoomCB.setSelected(DEFAULT_ZOOM_OPTION);
    filterPanel.add(zoomCB, gbc);
    gbc.gridy++;

    final JCheckBox multAxisCB = new JCheckBox("Multiple axis");
    filterPanel.add(multAxisCB, gbc);
    gbc.gridy++;

    final JCheckBox showEnvelopeCB = new JCheckBox("Show envelope (all algorithms, SLOW)");
    filterPanel.add(showEnvelopeCB, gbc);
    gbc.gridy++;

    final JXButton showModelButton = new JXButton("Show the model");
    filterPanel.add(showModelButton, gbc);
    gbc.gridy++;

    showModelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            final JXFrame dialog = new JXFrame();
            dialog.setTitle("Model");
            LogoHelper.setLogo(dialog);
            dialog.getContentPane().removeAll();
            dialog.getContentPane().setLayout(new BorderLayout());
            final JTextPane modelTxtPane = new JTextPane();
            modelTxtPane.setText(gapFiller.getModel());
            modelTxtPane.setBackground(Color.WHITE);
            modelTxtPane.setEditable(false);
            final JScrollPane jsp = new JScrollPane(modelTxtPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            jsp.setSize(new Dimension(400 - 20, 400 - 20));
            dialog.getContentPane().add(jsp, BorderLayout.CENTER);
            dialog.setSize(new Dimension(400, 400));
            dialog.setLocationRelativeTo(centerPanel);
            dialog.pack();
            dialog.setVisible(true);
        }
    });

    algoCombo.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
                showModelButton.setEnabled(gapFiller.hasExplicitModel());
            } catch (final Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    timeSeriesList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(final ListSelectionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
                mapPanel.removeAll();
                final List<String> currentlySelected = new ArrayList<String>();
                currentlySelected.add(attr.name());
                for (final Object sel : timeSeriesList.getSelectedValues())
                    currentlySelected.add(sel.toString());
                mapPanel.add(gcp.getMapPanel(currentlySelected, attrNames, true), BorderLayout.CENTER);
            } catch (final Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    hideOtherSeriesCB.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
            } catch (final Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    showErrorCB.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    zoomCB.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    showEnvelopeCB.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    multAxisCB.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            try {
                refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()),
                        timeSeriesList.getSelectedIndices(), hideOtherSeriesCB.isSelected(),
                        showErrorCB.isSelected(), zoomCB.isSelected(), showEnvelopeCB.isSelected(),
                        multAxisCB.isSelected());
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    });

    this.inBatchMode = inBatchMode;

    if (!inBatchMode) {
        try {
            refresh(Algo.valueOf(algoCombo.getSelectedItem().toString()), new int[0],
                    DEFAULT_HIDE_OTHER_SERIES_OPTION, false, DEFAULT_ZOOM_OPTION, false, false);
            showModelButton.setEnabled(gapFiller.hasExplicitModel());
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }

    if (!inBatchMode) {
        /* automatically select computed series */
        new AbstractSimpleAsync<Void>(true) {
            @Override
            public Void execute() throws Exception {
                mostSimilar = WekaTimeSeriesSimilarityUtil.findMostSimilarTimeSerie(testds, attr, attrNames,
                        false);
                mssLabel.setText("<html>Most similar usable serie: <b>" + mostSimilar + "</b></html>");

                nearest = gcp.findNearestStation(attr.name(), attrNames);
                nsLabel.setText("<html>Nearest usable serie: <b>" + nearest + "</b></html>");

                upstream = gcp.findUpstreamStation(attr.name(), attrNames);
                if (upstream != null) {
                    ussLabel.setText("<html>Upstream usable serie: <b>" + upstream + "</b></html>");
                } else {
                    ussLabel.setText("<html>Upstream usable serie: <b>N/A</b></html>");
                }

                downstream = gcp.findDownstreamStation(attr.name(), attrNames);
                if (downstream != null) {
                    dssLabel.setText("<html>Downstream usable serie: <b>" + downstream + "</b></html>");
                } else {
                    dssLabel.setText("<html>Downstream usable serie: <b>N/A</b></html>");
                }

                timeSeriesList.setSelectedIndices(
                        new int[] { attrNames.indexOf(mostSimilar), attrNames.indexOf(nearest),
                                attrNames.indexOf(upstream), attrNames.indexOf(downstream) });

                return null;
            }

            @Override
            public void onSuccess(final Void result) {
            }

            @Override
            public void onFailure(final Throwable caught) {
                caught.printStackTrace();
            }
        }.start();
    } else {
        try {
            mostSimilar = WekaTimeSeriesSimilarityUtil.findMostSimilarTimeSerie(testds, attr, attrNames, false);
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        nearest = gcp.findNearestStation(attr.name(), attrNames);
        upstream = gcp.findUpstreamStation(attr.name(), attrNames);
        downstream = gcp.findDownstreamStation(attr.name(), attrNames);
    }
}

From source file:de.codesourcery.jasm16.ide.ui.utils.UIUtils.java

public static JFrame createMessageFrame(String title, String msg) {

    final JFrame frame = new JFrame(title);

    final JTextArea message = createMultiLineLabel(msg);

    final JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());

    final JPanel messagePanel = new JPanel();
    messagePanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;/*ww  w  .  ja v a  2  s  .  co  m*/
    cnstrs.gridheight = 1;
    messagePanel.add(message, cnstrs);

    final JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());

    cnstrs = constraints(0, 0, true, false, GridBagConstraints.NONE);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(5, 2, 5, 2); // top,left,bottom,right           
    panel.add(messagePanel, cnstrs);

    cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = 1;
    cnstrs.weighty = 0;
    cnstrs.insets = new Insets(0, 2, 10, 2); // top,left,bottom,right      
    panel.add(buttonPanel, cnstrs);

    frame.getContentPane().add(panel);
    frame.pack();
    return frame;
}

From source file:com.vgi.mafscaling.ClosedLoop.java

protected void createRunPanel(JPanel dataPanel) {
    JPanel runPanel = new JPanel();
    GridBagConstraints gbc_runPanel = new GridBagConstraints();
    gbc_runPanel.fill = GridBagConstraints.BOTH;
    gbc_runPanel.weightx = 1.0;//from w  w w.  j a  v a 2  s.  c  o m
    gbc_runPanel.weighty = 1.0;
    gbc_runPanel.gridx = 0;
    gbc_runPanel.gridy = 3;
    dataPanel.add(runPanel, gbc_runPanel);

    GridBagLayout gbl_runPanel = new GridBagLayout();
    gbl_runPanel.columnWidths = new int[] { 0, 0 };
    gbl_runPanel.rowHeights = new int[] { 0 };
    gbl_runPanel.columnWeights = new double[] { 0.0, 0.0 };
    gbl_runPanel.rowWeights = new double[] { 0.0 };
    runPanel.setLayout(gbl_runPanel);

    JScrollPane dataScrollPane = new JScrollPane();
    createLogDataTable(dataScrollPane);
    GridBagConstraints gbc_dataScrollPane = new GridBagConstraints();
    gbc_dataScrollPane.fill = GridBagConstraints.BOTH;
    gbc_dataScrollPane.ipadx = ColumnWidth * ColumnCount;
    gbc_dataScrollPane.weighty = 1.0;
    gbc_dataScrollPane.gridx = 0;
    gbc_dataScrollPane.gridy = 0;
    runPanel.add(dataScrollPane, gbc_dataScrollPane);

    JScrollPane aprScrollPane = new JScrollPane();
    createAfrDataTables(aprScrollPane);
    GridBagConstraints gbc_aprScrollPane = new GridBagConstraints();
    gbc_aprScrollPane.weightx = 1.0;
    gbc_aprScrollPane.weighty = 1.0;
    gbc_aprScrollPane.anchor = GridBagConstraints.PAGE_START;
    gbc_aprScrollPane.fill = GridBagConstraints.BOTH;
    gbc_aprScrollPane.gridx = 1;
    gbc_aprScrollPane.gridy = 0;
    runPanel.add(aprScrollPane, gbc_aprScrollPane);
}

From source file:com.qspin.qtaste.ui.ConfigInfoPanel.java

public void init() {

    setLayout(new GridBagLayout());
    GridBagLineAdder adder = new GridBagLineAdder(this);
    adder.setWeight(1.0f, 0.0f);/*from  w w  w  . j  a  va2s . c  om*/
    adder.setLength(6);

    //1st column - 1st row
    adder.setWeight(0.0, 0.0);
    adder.add(new JLabel("Test suite:"));
    adder.setWeight(1.0, 0.0);
    adder.add(mTestSuiteLabel);
    adder.setWeight(0.0, 0.0);

    //2d column - 1st row
    adder.add(new JLabel("Testbed config:"));
    // set the combobox as read only (not possible to modify the testbed from GUI at this time
    UIManager.put("ComboBox.disabledForeground", Color.BLACK);
    mTestbedList.setEnabled(true);
    adder.add(mTestbedList);

    // add testbed mouse listener, for the "Edit File" action
    TestbedMouseListener testbedMouseListener = new TestbedMouseListener();
    java.awt.Component[] mTestbedListComponents = mTestbedList.getComponents();
    for (int i = 0; i < mTestbedListComponents.length; i++) {
        mTestbedListComponents[i].addMouseListener(testbedMouseListener);
    }

    // go to second row
    adder.addSeparator();

    //1st column - 2d row
    adder.add(new JLabel("Test results directory:"));
    adder.add(mTestResultsLabel);

    //2d column - 2d row
    m_ignoreControlScript.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            TestEngine.setIgnoreControlScript(ignoreControlScript());
            setControlTestbedButtonsEnabled();

            GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
            guiConfiguration.setProperty(StaticConfiguration.IGNORE_CONTROL_SCRIPT_PROPERTY,
                    m_ignoreControlScript.isSelected());
            try {
                guiConfiguration.save();
            } catch (ConfigurationException ex) {
                logger.error("Error while saving GUI configuration: " + ex.getMessage());
            }
        }
    });
    adder.add(m_ignoreControlScript);
    JPanel sutPanel = new JPanel();
    JLabel sutVersion = new JLabel("SUT version: ");
    sutPanel.add(sutVersion);
    m_SUTVersion.setHorizontalAlignment(JTextField.RIGHT);
    m_SUTVersion.setPreferredSize(new Dimension(150, m_SUTVersion.getPreferredSize().height));
    sutPanel.add(m_SUTVersion);
    adder.add(sutPanel);
    m_SUTVersion.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            TestBedConfiguration.setSUTVersion(m_SUTVersion.getText());
        }
    });
    //create a 3d row
    adder.addSeparator();

    //1st column - 3d row
    adder.add(new JLabel("Reporting Format:"));
    adder.add(mTestReportingFormat);

    //2d column - 3d row
    // add a button to manually start the testbed
    m_startTestbed.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            isStartingOrStoppingTestbed = true;
            setControlTestbedButtonsEnabled();
            parent.getTestCasePanel().setStopButtonEnabled(true, true);
            parent.getTestCasePanel().showTestcaseResultsTab();
            TestBedConfiguration.setSUTVersion(getSUTVersion());
            new SUTStartStopThread("start").start();
        }
    });
    m_startTestbed.setEnabled(false);
    adder.add(m_startTestbed);

    // add a button to manually stop the testbed
    m_stopTestbed.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            isStartingOrStoppingTestbed = true;
            setControlTestbedButtonsEnabled();
            parent.getTestCasePanel().showTestcaseResultsTab();
            TestBedConfiguration.setSUTVersion(getSUTVersion());
            new SUTStartStopThread("stop").start();
        }
    });
    m_stopTestbed.setEnabled(false);
    adder.add(m_stopTestbed);

    DefaultComboBoxModel model = (DefaultComboBoxModel) mTestbedList.getModel();
    model.removeAllElements();
    String testbedDir = testbedConfig.getFile().getParent();
    File fTestbedDir = new File(testbedDir);
    FileMask fileMask = new FileMask();
    fileMask.addExtension("xml");
    File[] fTestbedList = FileUtilities.listSortedFiles(fTestbedDir, fileMask);
    for (int i = 0; i < fTestbedList.length; i++) {
        // remove the extension
        String testbedName = fTestbedList[i].getName().substring(0, fTestbedList[i].getName().lastIndexOf('.'));
        model.addElement(testbedName);
    }

    mTestbedList.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (mTestbedList.getSelectedItem() != null) {
                String selectedTestbed = (String) mTestbedList.getSelectedItem();
                String configFile = StaticConfiguration.TESTBED_CONFIG_DIRECTORY + "/" + selectedTestbed + "."
                        + StaticConfiguration.TESTBED_CONFIG_FILE_EXTENSION;
                TestBedConfiguration.setConfigFile(configFile);

                GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
                guiConfiguration.setProperty(StaticConfiguration.LAST_SELECTED_TESTBED_PROPERTY,
                        selectedTestbed);
                try {
                    guiConfiguration.save();
                } catch (ConfigurationException ex) {
                    logger.error("Error while saving GUI configuration: " + ex.getMessage());
                }
            }
            refreshData();
        }
    });

    refreshTestBed();
    refreshData();
    if (GUIConfiguration.getInstance().getBoolean(StaticConfiguration.IGNORE_CONTROL_SCRIPT_PROPERTY, false))
        m_ignoreControlScript.doClick();

    TestBedConfiguration
            .registerConfigurationChangeHandler(new TestBedConfiguration.ConfigurationChangeHandler() {

                public void onConfigurationChange() {
                    testbedConfig = TestBedConfiguration.getInstance();
                    String configFileName = testbedConfig.getFile().getName();
                    mTestbedList.getModel()
                            .setSelectedItem(configFileName.substring(0, configFileName.lastIndexOf('.')));
                }
            });
}

From source file:com.wet.wired.jsr.player.JPlayer.java

public void showWindow() {

    setTitle("TestingOwl Player");
    setIconImage(owl.getWelcomeIcon().getImage());
    getContentPane().removeAll();/*w  w  w  . j av  a2  s.co m*/

    JPanel panel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    panel.setLayout(gbl);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            closePlayer();
            System.exit(0);
        }
    });

    open = new JButton("Open Recording");
    open.setActionCommand("open");
    open.addActionListener(this);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    panel.add(open, gbc);

    reset = new JButton("Reset");
    reset.setActionCommand("reset");
    reset.setEnabled(false);
    reset.addActionListener(this);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    panel.add(reset, gbc);

    play = new JButton("Play");
    play.setActionCommand("play");
    play.setEnabled(false);
    play.addActionListener(this);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    panel.add(play, gbc);

    fastForward = new JButton("Fast Forward");
    fastForward.setActionCommand("fastForward");
    fastForward.setEnabled(false);
    fastForward.addActionListener(this);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 3;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    panel.add(fastForward, gbc);

    pause = new JButton("Pause");
    pause.setActionCommand("pause");
    pause.setEnabled(false);
    pause.addActionListener(this);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 4;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    panel.add(pause, gbc);

    close = new JButton("Close File");
    close.setActionCommand("close");
    close.setEnabled(false);
    close.addActionListener(this);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 5;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    panel.add(close, gbc);

    // slider
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 6;
    gbc.gridy = 0;
    gbc.weightx = 1;
    gbc.weighty = 1;
    panel.add(createSliderLayout(), gbc);

    soundLevel.setSize(30, (int) close.getSize().getHeight());
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 7;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    panel.add(soundLevel, gbc);

    recorder = new JButton("to Recorder");
    recorder.setActionCommand("recorder");
    recorder.setEnabled(true);
    recorder.addActionListener(this);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridx = 8;
    gbc.gridy = 0;
    gbc.weightx = 0;
    gbc.weighty = 1;
    panel.add(recorder, gbc);

    panel.doLayout();

    this.getContentPane().add(panel, BorderLayout.NORTH);

    panel = new JPanel();
    panel.setLayout(new GridLayout(1, 2));

    frameLabel = new JLabel("Frame: 0 Time: 0");
    frameLabel.setForeground(Color.black);
    text = new JLabel("No recording selected");
    text.setForeground(Color.black);

    panel.add(text);
    panel.add(frameLabel);

    this.getContentPane().add(panel, BorderLayout.SOUTH);

    this.setSize(700, this.getHeight());
    this.pack();
    this.setVisible(true);
}

From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java

private JPanel getJPanelForDocumentExportInfo() {
    if (jPanelForDocumentExportInfo == null) {
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints5.gridx = -1;//from w w w  .  j  a v a 2  s . c om
        gridBagConstraints5.gridy = -1;
        gridBagConstraints5.gridwidth = 1;
        gridBagConstraints5.anchor = GridBagConstraints.CENTER;
        gridBagConstraints5.weightx = 1.0;
        gridBagConstraints5.weighty = 0.0;
        gridBagConstraints5.insets = new Insets(0, 0, 10, 5); //  margin // top, left, bottom, right
        jPanelForDocumentExportInfo = new JPanel();
        jPanelForDocumentExportInfo.setLayout(new GridBagLayout());
        jPanelForDocumentExportInfo.setBorder(BorderFactory.createTitledBorder(null, "Report Export Location",
                TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
                new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51)));
        jPanelForDocumentExportInfo.add(getJPanelDocumentExportInfo(), gridBagConstraints5);
    }
    return jPanelForDocumentExportInfo;
}

From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileGraphicDetailPanel.java

private Component createControls() {
    JPanel controlPanel = new JPanel(new GridBagLayout());
    controlPanel.setOpaque(false);//w  w w  .  j  a  v  a 2s .c  o  m

    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);

    GridBagLayoutManager.addComponent(controlPanel, createInstantDataPanel(), c, 0, 0, 1, 1, 0, 0,
            GridBagConstraints.BOTH, GridBagConstraints.CENTER);

    GridBagLayoutManager.addComponent(controlPanel, createWarningsPanel(), c, 0, 1, 1, 1, 0, 0,
            GridBagConstraints.BOTH, GridBagConstraints.CENTER);

    GridBagLayoutManager.addComponent(controlPanel, createOptionsPanel(), c, 0, 2, 1, 1, 0, 0,
            GridBagConstraints.BOTH, GridBagConstraints.CENTER);

    GridBagLayoutManager.addComponent(controlPanel, createEditorButton(), c, 0, 3, 1, 1, 0, 0,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH);

    GridBagLayoutManager.addComponent(controlPanel, createImportExportButtons(), c, 0, 4, 1, 1, 0, 0,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH);

    GridBagLayoutManager.addComponent(controlPanel, Box.createVerticalGlue(), c, 0, 5, 1, 1, 1, 1,
            GridBagConstraints.VERTICAL, GridBagConstraints.CENTER);

    return controlPanel;
}

From source file:replicatorg.app.ui.panels.ControlPanel.java

public ControlPanel() {
    super(Base.getMainWindow(), Dialog.ModalityType.MODELESS);
    initComponents();//from  w ww. j av  a 2 s.c om
    Base.writeLog("Control panel opened...", this.getClass());
    setTextLanguage();
    super.centerOnScreen();
    super.enableDrag();
    evaluateInitialConditions();

    this.tempPanel.setLayout(new GridBagLayout());
    this.tempPanel.add(this.makeChart());

    //Sets legend colors
    BufferedImage image = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
    Graphics g = image.getGraphics();
    g.setColor(t0MeasuredColor);
    g.fillRect(0, 0, 10, 10);
    Icon icon1 = new ImageIcon(image);

    this.colorCurrentTemp.setIcon(icon1);
    this.colorCurrentTemp.setText("");

    BufferedImage image2 = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
    Graphics g2 = image2.getGraphics();
    g2.setColor(t0TargetColor);
    g2.fillRect(0, 0, 10, 10);
    Icon icon2 = new ImageIcon(image2);

    this.colorTargetTemp.setIcon(icon2);
    this.colorTargetTemp.setText("");

    if (connectedPrinter == PrinterInfo.BEETHEFIRST) {
        jSliderBlowerSpeed.setMaximum(1);
        jSliderBlowerSpeed.setMinorTickSpacing(0);
        jSliderBlowerSpeed.setMajorTickSpacing(1);

        jSliderExtruderSpeed.setEnabled(false);
    }

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowOpened(WindowEvent e) {
            consoleInput.requestFocus();
        }

        @Override
        public void windowClosed(WindowEvent e) {
            if (movButtonHoldDown != null && movButtonHoldDown.isRunning()) {
                movButtonHoldDown.stop();
            }
            driver.dispatchCommand("M1110 S0", COM.NO_RESPONSE);

            if (loggingTemperature == false) {
                disposeThread.cancel();
            }
            inputValidationThread.cancel();
            getInitialValuesThread.cancel();
        }
    });
}

From source file:dk.dma.epd.shore.gui.views.SendRouteDialog.java

/**
 * Initialize the GUI/*from   w  ww . ja v a2  s.c  o m*/
 */
public void initGUI() {

    JPanel content = new JPanel(new GridBagLayout());
    setContentPane(content);
    Insets insets1 = new Insets(5, 5, 5, 0);
    Insets insets2 = new Insets(5, 0, 5, 5);
    Insets insets5 = new Insets(5, 5, 5, 5);

    // *******************
    // *** Target panel
    // *******************
    JPanel targetPanel = new JPanel(new GridBagLayout());
    targetPanel.setBorder(new TitledBorder("Target"));
    content.add(targetPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    mmsiListComboBox.addActionListener(this);
    targetPanel.add(new JLabel("MMSI:"),
            new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    targetPanel.add(mmsiListComboBox,
            new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    nameComboBox.addActionListener(this);
    targetPanel.add(new JLabel("Name:"),
            new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    targetPanel.add(nameComboBox,
            new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    chatBtn.setEnabled(false);
    chatBtn.addActionListener(this);
    targetPanel.add(new JLabel("Call Sign:"),
            new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    targetPanel.add(callsignLbl, new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));
    targetPanel.add(chatBtn, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, EAST, NONE, insets5, 0, 0));

    statusLbl.setVisible(false);
    targetPanel.add(statusLbl, new GridBagConstraints(0, 3, 3, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    // *******************
    // *** Route panel
    // *******************
    JPanel routePanel = new JPanel(new GridBagLayout());
    routePanel.setBorder(new TitledBorder("Route"));
    content.add(routePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    routeListComboBox.addActionListener(this);
    routePanel.add(new JLabel("Route name:"),
            new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    routePanel.add(routeListComboBox,
            new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    routePanel.add(new JLabel("Route length:"),
            new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    routePanel.add(routeLengthLbl,
            new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    int h = (int) departurePicker.getPreferredSize().getHeight();
    initDatePicker(departurePicker, departureSpinner);
    routePanel.add(new JLabel("ETD:"), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    routePanel.add(fixSize(departurePicker, 120),
            new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0));
    routePanel.add(fixSize(departureSpinner, 60, h),
            new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0));

    initDatePicker(arrivalPicker, arrivalSpinner);
    routePanel.add(new JLabel("ETA:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    routePanel.add(fixSize(arrivalPicker, 120),
            new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, WEST, NONE, insets1, 0, 0));
    routePanel.add(fixSize(arrivalSpinner, 60, h),
            new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0));

    speedTxtField.getDocument().addDocumentListener(new TextFieldChangeListener(speedTxtField));
    speedTxtField.setHorizontalAlignment(JTextField.RIGHT);
    routePanel.add(new JLabel("Avg. speed:"),
            new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    routePanel.add(speedTxtField,
            new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets5, 0, 0));

    zoomBtn.addActionListener(this);
    routePanel.add(zoomBtn, new GridBagConstraints(0, 5, 3, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));

    // *******************
    // *** Send panel
    // *******************
    JPanel sendPanel = new JPanel(new GridBagLayout());
    sendPanel.setBorder(new TitledBorder("Send"));
    content.add(sendPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, CENTER, BOTH, insets5, 0, 0));

    messageTxtField.setLineWrap(true);
    JScrollPane scrollPane = new JScrollPane(messageTxtField);
    scrollPane.setMinimumSize(new Dimension(180, 40));
    scrollPane.setPreferredSize(new Dimension(180, 40));

    sendPanel.add(new JLabel("Message:"),
            new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, NORTHWEST, NONE, insets5, 0, 0));
    sendPanel.add(scrollPane, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, WEST, BOTH, insets5, 0, 0));

    sendBtn.addActionListener(this);
    cancelBtn.addActionListener(this);
    sendPanel.add(sendBtn, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, WEST, NONE, insets5, 0, 0));
    sendPanel.add(cancelBtn, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, EAST, NONE, insets5, 0, 0));
}

From source file:com.att.aro.ui.view.menu.tools.RegexWizard.java

public void init() {
    GoogleAnalyticsUtil.getGoogleAnalyticsInstance().sendViews("VideoParserWizard");
    setDefaultCloseOperation(RegexWizard.DISPOSE_ON_CLOSE);
    enableCheckBoxes(true);/* ww w.j a  v a 2 s  .c  om*/
    this.setSize(815, 800);
    this.setMaximumSize(new Dimension(815, 800));
    this.setMinimumSize(new Dimension(815, 700));
    this.setModal(false);
    this.setTitle(resourceBundle.getString("videoParser.wizard.title"));
    this.setLocationRelativeTo(getOwner());
    this.setAlwaysOnTop(true);
    this.setResizable(false);

    setLayout(new GridBagLayout());
    GridBagConstraints constraint = new GridBagConstraints();

    constraint.fill = GridBagConstraints.BOTH;
    constraint.gridx = 0;
    constraint.gridy = 0;
    constraint.weightx = 1;
    constraint.weighty = 0.6;
    constraint.gridwidth = 2;
    add(getFieldPanel(), constraint);

    constraint.gridy = 1;
    constraint.gridwidth = 1;
    constraint.weighty = 0.38;
    constraint.weightx = 0.4;
    constraint.insets = new Insets(0, 2, 0, 5);
    add(getMatcherPanel(), constraint);

    constraint.weightx = 0.5;
    constraint.gridx = 1;
    constraint.insets = new Insets(0, 1, 0, 2);
    add(getResultPanel(), constraint);

    constraint.weightx = 1;
    constraint.gridy = 2;
    constraint.gridx = 0;
    constraint.weighty = 0.02;
    constraint.gridwidth = 2;
    add(getBottomPanel(), constraint);

    this.addWindowListener(new WindowAdapter() {
        public void windowClosed(WindowEvent e) {
            clear();
        }
    });
    pack();
}