Example usage for javax.swing BorderFactory createEtchedBorder

List of usage examples for javax.swing BorderFactory createEtchedBorder

Introduction

In this page you can find the example usage for javax.swing BorderFactory createEtchedBorder.

Prototype

public static Border createEtchedBorder(int type) 

Source Link

Document

Creates a border with an "etched" look using the component's current background color for highlighting and shading.

Usage

From source file:cnu.eslab.fileTest.NewJFrame.java

private void initGUI() {
    try {/*from ww w .java 2 s .co m*/
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(null);
        {
            jPanel1 = new JPanel();
            FlowLayout jPanel1Layout = new FlowLayout();
            jPanel1.setLayout(jPanel1Layout);
            getContentPane().add(jPanel1, "North");
            jPanel1.setBounds(12, 434, 590, 66);
            jPanel1.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            {
                mParsingBtn = new JButton();
                jPanel1.add(mParsingBtn);
                mParsingBtn.setText("Parsing");
                mParsingBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mTotalPowerBtn = new JButton();
                jPanel1.add(mTotalPowerBtn);
                mTotalPowerBtn.setText("Phone Total Power");
                mTotalPowerBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mBatteryCapacityBtn = new JButton();
                jPanel1.add(mBatteryCapacityBtn);
                mBatteryCapacityBtn.setText("Battery Capacity");
                mBatteryCapacityBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mTotalCompareBtn = new JButton();
                jPanel1.add(mTotalCompareBtn);
                mTotalCompareBtn.setText("Total Compare");
                mTotalCompareBtn.setPreferredSize(new java.awt.Dimension(124, 24));
            }
            {
                mPhoneTotalStackPowerBtn = new JButton();
                jPanel1.add(mPhoneTotalStackPowerBtn);
                mPhoneTotalStackPowerBtn.setText("Phone Total Stack Power");
            }
            {
                mDevicesPowerButton = new JButton();
                jPanel1.add(mDevicesPowerButton);
                mDevicesPowerButton.setText("Hardware Component Max Power");
                mDevicesPowerButton.setPreferredSize(new java.awt.Dimension(280, 24));
            }
            {
                mCompareAppPowerBtn = new JButton();
                jPanel1.add(mCompareAppPowerBtn);
                mCompareAppPowerBtn.setText("Compare");
            }
        }
        {
            jPanel2 = new JPanel();
            getContentPane().add(jPanel2, "West");
            jPanel2.setBounds(12, 25, 589, 67);
            jPanel2.setLayout(null);
            jPanel2.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            {
                mFilePathLabel = new JLabel();
                jPanel2.add(mFilePathLabel);
                mFilePathLabel.setText("File Path");
                mFilePathLabel.setPreferredSize(new java.awt.Dimension(48, 17));
                mFilePathLabel.setBounds(8, 8, 48, 17);
            }
            {
                mFilePathTextField = new JTextField();
                jPanel2.add(mFilePathTextField);
                mFilePathTextField.setText("None");
                mFilePathTextField.setEditable(false);
                mFilePathTextField.setBounds(68, 4, 430, 24);
            }
            {
                mFileBtn = new JButton();
                jPanel2.add(mFileBtn);
                mFileBtn.setText("OPEN");
                mFileBtn.setBounds(503, 6, 81, 24);
            }
            {
                LOGTimeLabel = new JLabel();
                jPanel2.add(LOGTimeLabel);
                LOGTimeLabel.setText("LOG Time");
                LOGTimeLabel.setBounds(8, 37, 60, 17);
            }
            {
                mLogScaleTextFiled = new JTextField();
                jPanel2.add(mLogScaleTextFiled);
                mLogScaleTextFiled.setText("None");
                mLogScaleTextFiled.setEditable(false);
                mLogScaleTextFiled.setBounds(68, 34, 430, 24);
            }
        }
        {
            jScrollPane1 = new JScrollPane();
            getContentPane().add(jScrollPane1);
            jScrollPane1.setBounds(13, 122, 424, 228);
            {
                listModel = new DefaultListModel();// List? ??  ??.
                mUidList = new JList(listModel);
                mUidList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // 
                // ?
                // ?
                // .
                jScrollPane1.setViewportView(mUidList);
                jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

                mUidList.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
                //mUidList.setPreferredSize(new java.awt.Dimension(586, 222));   /?  ?.
            }
        }
        {
            jPanel3 = new JPanel();
            getContentPane().add(jPanel3);
            jPanel3.setBounds(12, 0, 579, 31);
            {
                dd = new JLabel();
                jPanel3.add(dd);
                dd.setText("Power Tutor Trace");
                dd.setPreferredSize(new java.awt.Dimension(106, 17));
            }
        }
        {
            jPanel5 = new JPanel();
            getContentPane().add(jPanel5, "West");
            jPanel5.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel5.setBounds(12, 356, 304, 58);
            jPanel5.setLayout(null);
            {
                Range = new JLabel();
                jPanel5.add(Range);
                Range.setText("Range");
                Range.setBounds(14, 10, 46, 17);
            }
            {
                mFirstRangeText = new JTextField();
                jPanel5.add(mFirstRangeText);
                mFirstRangeText.setBounds(59, 7, 63, 24);
            }
            {
                mUidPieDiagramBtn = new JButton();
                jPanel5.add(mUidPieDiagramBtn);
                mUidPieDiagramBtn.setText("UID Pie");
                mUidPieDiagramBtn.setBounds(207, 7, 90, 24);
            }
            {
                jLabel3 = new JLabel();
                jPanel5.add(jLabel3);
                jLabel3.setText("-");
                jLabel3.setBounds(128, 10, 10, 17);
            }
            {
                mSecondRangeText = new JTextField();
                jPanel5.add(mSecondRangeText);
                mSecondRangeText.setBounds(138, 7, 63, 24);
            }
            {
                mComponentPieBtn = new JButton();
                jPanel5.add(mComponentPieBtn);
                mComponentPieBtn.setText("PHONE Pie");
                mComponentPieBtn.setBounds(59, 36, 238, 16);
            }
        }
        {
            jPanel6 = new JPanel();
            getContentPane().add(jPanel6, "West");
            jPanel6.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel6.setBounds(322, 356, 275, 66);
            jPanel6.setLayout(null);
            {
                jLabel4 = new JLabel();
                jPanel6.add(jLabel4);
                jLabel4.setText("TotalPM");
                jLabel4.setBounds(16, 10, 56, 26);
            }
            {
                mChartMeanUnitTextField = new JTextField();
                jPanel6.add(mChartMeanUnitTextField);
                mChartMeanUnitTextField.setBounds(77, 7, 135, 29);
            }
            {
                m3DBarChartMean = new JButton();
                jPanel6.add(m3DBarChartMean);
                m3DBarChartMean.setText("ok");
                m3DBarChartMean.setBounds(218, 7, 49, 24);
            }
            {
                mAudioCheckBox = new JCheckBox();
                jPanel6.add(mAudioCheckBox);
                mAudioCheckBox.setText("AUDIO");
                mAudioCheckBox.setBounds(79, 40, 65, 21);
            }
            {
                mGPSCheckBox = new JCheckBox();
                jPanel6.add(mGPSCheckBox);
                mGPSCheckBox.setText("GPS");
                mGPSCheckBox.setBounds(151, 40, 56, 21);
            }
        }
        {
            jPanel4 = new JPanel();
            getContentPane().add(jPanel4, "North");
            FlowLayout jPanel4Layout = new FlowLayout();
            jPanel4.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel4.setLayout(jPanel4Layout);
            jPanel4.setBounds(12, 523, 590, 66);
            {
                mAppTotalPowerBtn = new JButton();
                jPanel4.add(mAppTotalPowerBtn);
                mAppTotalPowerBtn.setText("UID Line Total Power");
                mAppTotalPowerBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mAppStackedPower = new JButton();
                jPanel4.add(mAppStackedPower);
                mAppStackedPower.setText("UID Stack Total Power");
                mAppStackedPower.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mLedBtn = new JButton();
                jPanel4.add(mLedBtn);
                mLedBtn.setText("UID LED Power");
                mLedBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mCpuBtn = new JButton();
                jPanel4.add(mCpuBtn);
                mCpuBtn.setText("UID CPU Power");
                mCpuBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mWifiBtn = new JButton();
                jPanel4.add(mWifiBtn);
                mWifiBtn.setText("UID WIFI Power");
                mWifiBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                m3GBtn = new JButton();
                jPanel4.add(m3GBtn);
                m3GBtn.setText("UID ThreeG Power");
                m3GBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
        }
        {
            jPanel7 = new JPanel();
            getContentPane().add(jPanel7, "North");
            FlowLayout jPanel7Layout = new FlowLayout();
            jPanel7.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jPanel7.setLayout(jPanel7Layout);
            jPanel7.setBounds(12, 618, 590, 63);
            {
                mComponentLEDBtn = new JButton();
                jPanel7.add(mComponentLEDBtn);
                mComponentLEDBtn.setText("LED Power");
                mComponentLEDBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentWIFIBtn = new JButton();
                jPanel7.add(mComponentWIFIBtn);
                mComponentWIFIBtn.setText("WIFI Power");
                mComponentWIFIBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mGpsBtn = new JButton();
                jPanel7.add(mGpsBtn);
                mGpsBtn.setText("GPS Power");
                mGpsBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentCPUBtn = new JButton();
                jPanel7.add(mComponentCPUBtn);
                mComponentCPUBtn.setText("CPU Power");
                mComponentCPUBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mComponentThreeGBtn = new JButton();
                jPanel7.add(mComponentThreeGBtn);
                mComponentThreeGBtn.setText("ThreeG Power");
                mComponentThreeGBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
            {
                mAudioBtn = new JButton();
                jPanel7.add(mAudioBtn);
                mAudioBtn.setText("AUDIO Power");
                mAudioBtn.setPreferredSize(new java.awt.Dimension(140, 24));
            }
        }
        {
            jLabel1 = new JLabel();
            getContentPane().add(jLabel1);
            jLabel1.setText("Individual App component Power");
            jLabel1.setBounds(12, 506, 202, 17);
        }
        {
            jLabel2 = new JLabel();
            getContentPane().add(jLabel2);
            jLabel2.setText("Function Button");
            jLabel2.setBounds(12, 411, 181, 17);
        }
        {
            jLabel5 = new JLabel();
            getContentPane().add(jLabel5);
            jLabel5.setText("Individual H/W Component Power");
            jLabel5.setBounds(12, 601, 223, 17);
        }
        {
            jScrollPane2 = new JScrollPane();
            getContentPane().add(jScrollPane2);
            jScrollPane2.setBounds(493, 122, 108, 194);
            {
                listModelUidDelte = new DefaultListModel();// List? ??  ??.
                mDeleteList = new JList(listModelUidDelte);
                jScrollPane2.setViewportView(mDeleteList);
            }
        }
        {
            mDeleteAllBtn = new JButton();
            getContentPane().add(mDeleteAllBtn);
            mDeleteAllBtn.setText("A");
            mDeleteAllBtn.setBounds(493, 321, 51, 24);
        }
        {
            mDeleteOneBtn = new JButton();
            getContentPane().add(mDeleteOneBtn);
            mDeleteOneBtn.setText("O");
            mDeleteOneBtn.setBounds(549, 321, 48, 24);
        }
        {
            mDeleteUidMoveBtn = new JButton();
            getContentPane().add(mDeleteUidMoveBtn);
            mDeleteUidMoveBtn.setText(">");
            mDeleteUidMoveBtn.setBounds(443, 169, 45, 95);
        }
        {
            jLabel6 = new JLabel();
            getContentPane().add(jLabel6);
            jLabel6.setText("Package Name List");
            jLabel6.setBounds(13, 99, 139, 17);
        }
        {
            jLabel7 = new JLabel();
            getContentPane().add(jLabel7);
            jLabel7.setText("Remove Uid");
            jLabel7.setBounds(493, 100, 139, 17);
        }
        pack();
        this.setSize(623, 725);
        // setVisible(true);
    } catch (Exception e) {
        // add your error handling code here
        e.printStackTrace();
    }
}

From source file:net.minelord.gui.panes.IRCPane.java

public void connected() {
    SwingUtilities.invokeLater(new Runnable() {

        @Override/*from  ww  w  .  j  av  a 2s .com*/
        public void run() {
            scroller.setBounds(scrollerWithoutTopicWithUserlist);
            scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            status = "Connected";
            client.connectAlertListener();
            TitledBorder title = BorderFactory
                    .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Connected");
            title.setTitleJustification(TitledBorder.RIGHT);
            userList = new JList(client.getUserList().toArray());
            userScroller = new JScrollPane(userList);
            userScroller.setBounds(userScrollerWithoutTopic);
            userList.setBounds(0, 0, 210, 250);
            userList.setBackground(Color.gray);
            userList.setForeground(Color.gray.darker().darker().darker());
            userScroller.setBorder(title);
            userScroller.getVerticalScrollBar().setUnitIncrement(5);
            scroller.setBorder(BorderFactory
                    .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), ""));
            if (client.getTopic().trim().length() > 0) {
                topic = new JLabel(client.getTopic());
                scroller.setBounds(scrollerWithTopicWithUserlist);
                userScroller.setBounds(userScrollWithTopic);
                userList.setBounds(0, 0, 210, 225);
                title = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
                        "Topic set by " + client.getTopicSetter());
                title.setTitleJustification(TitledBorder.LEFT);
                topic.setBorder(title);
                topic.setBounds(topicBounds);
                add(topic);
            } else
                topic = new JLabel("");
            input.setEnabled(true);
            input.requestFocus();
            final JPopupMenu userPopup = new JPopupMenu();
            JLabel breakLine = new JLabel("____");
            JLabel help = new JLabel("Politely ask for help");
            JLabel message = new JLabel("Message");
            JLabel sortNormal = new JLabel("Normal");
            JLabel sortAlphabetical = new JLabel("Alphabetical");
            JLabel sortRoles = new JLabel("Roles");

            help.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    userPopup.setVisible(false);
                    sendMessage("/me kicks " + userList.getModel().getElementAt(userList.getSelectedIndex())
                            + " in the shins");
                    sendMessage("I need help you pleb");
                }

                public void mouseReleased(MouseEvent e) {
                }
            });
            message.addMouseListener(new MouseAdapter() {

                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    input.setText("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex())
                            + (input.getText().length() > 0 && input.getText().charAt(0) == ' '
                                    ? input.getText()
                                    : " " + input.getText()));
                    input.select(0, ("/msg " + userList.getModel().getElementAt(userList.getSelectedIndex())
                            + (input.getText().length() > 0 && input.getText().charAt(0) == ' ' ? "" : " "))
                                    .length());
                    input.requestFocus();
                }
            });
            sortNormal.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    updateUserList(0);
                }
            });
            sortAlphabetical.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    updateUserList(1);
                }
            });
            sortRoles.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    userPopup.setVisible(false);
                    updateUserList(2);
                }
            });
            userPopup.add(help);
            userPopup.add(message);
            userPopup.add(breakLine);
            userPopup.add(sortNormal);
            userPopup.add(sortAlphabetical);
            userPopup.add(sortRoles);

            userList.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                    check(e);
                }

                public void mouseReleased(MouseEvent e) {
                    check(e);
                }

                public void check(MouseEvent e) {
                    userList.setSelectedIndex(userList.locationToIndex(e.getPoint()));
                    userPopup.show(userList, e.getX(), e.getY());
                }
            });
            add(userScroller);

            final JPopupMenu textPopup = new JPopupMenu();
            JLabel copy = new JLabel("Copy");
            copy.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseReleased(MouseEvent paramMouseEvent) {
                    textPopup.setVisible(false);
                    if (text.getSelectedText() != null && text.getSelectedText().length() != 0) {
                        StringSelection selection = new StringSelection(text.getSelectedText());
                        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                        clipboard.setContents(selection, selection);
                    }
                }
            });
            textPopup.add(copy);
            text.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent e) {
                }

                public void mouseReleased(MouseEvent e) {
                    if (SwingUtilities.isRightMouseButton(e))
                        textPopup.show(text, e.getX(), e.getY());
                }
            });
            add(userScroller);
            repaint();
        }
    });
}

From source file:ffx.ui.KeywordPanel.java

private void initialize() {
    // Load the Keyword Definitions
    loadXML();/*from   w  ww  . ja v  a2 s .c  o  m*/
    // TextAreas
    flatfileTextArea = new JTextArea();
    flatfileTextArea.setEditable(false);
    flatfileTextArea.setFont(Font.decode("monospaced plain 12"));
    Insets insets = flatfileTextArea.getInsets();
    insets.set(5, 5, 5, 5);
    flatfileTextArea.setMargin(insets);
    // Keyword Edit Panel
    editPanel = new JPanel(flowLayout);
    ClassLoader loader = getClass().getClassLoader();
    ImageIcon icKeyPanel = new ImageIcon(loader.getResource("ffx/ui/icons/page_key.png"));
    noSystemLabel.setIcon(icKeyPanel);
    ImageIcon icon = new ImageIcon(loader.getResource("ffx/ui/icons/information.png"));
    noKeywordLabel.setIcon(icon);
    noKeywordPanel.add(noKeywordLabel);
    editScrollPane = new JScrollPane(editPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    descriptScrollPane = new JScrollPane(descriptTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    Border eb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    descriptScrollPane.setBorder(eb);
    // Add the Keyword Group Panel and Decription Panel to a JSplitPane
    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editScrollPane, descriptScrollPane);
    splitPane.setResizeWeight(1.0);
    splitPane.setOneTouchExpandable(true);
    statusLabel.setBorder(eb);
    // Add the main pieces to the overall KeywordPanel (except the ToolBar)
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    add(statusLabel, BorderLayout.SOUTH);
    // Init the GridBagContraints
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.anchor = GridBagConstraints.WEST;
    gridBagConstraints.gridheight = 1;
    gridBagConstraints.gridwidth = 1;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    initToolBar();
    add(toolBar, BorderLayout.NORTH);
    setParamPath();
    loadPrefs();
    loadKeywordGroup();
}

From source file:projects.wdlf47tuc.ProcessAllSwathcal.java

/**
 * Main entry point./*from   w  w  w .  ja va  2 s.c o m*/
 * 
 * @param args
 * 
 * @throws IOException 
 * 
 */
public ProcessAllSwathcal() {

    // Path to AllSwathcal.dat file
    File allSwathcal = new File(
            "/home/nrowell/Astronomy/Data/47_Tuc/Kalirai_2012/UVIS/www.stsci.edu/~jkalirai/47Tuc/AllSwathcal.dat");

    // Read file contents into the List
    try (BufferedReader in = new BufferedReader(new FileReader(allSwathcal))) {
        String sourceStr;
        while ((sourceStr = in.readLine()) != null) {
            Source source = Source.parseSource(sourceStr);
            if (source != null) {
                allSources.add(source);
            }
        }
    } catch (IOException e) {
    }

    logger.info("Parsed " + allSources.size() + " Sources from AllSwathcal.dat");

    // Initialise chart
    cmdPanel = new ChartPanel(updateDataAndPlotCmd(allSources));
    cmdPanel.addChartMouseListener(new ChartMouseListener() {
        @Override
        public void chartMouseClicked(ChartMouseEvent e) {
            // Capture mouse click location, transform to graph coordinates and add
            // a point to the polygonal selection box.
            Point2D p = cmdPanel.translateScreenToJava2D(e.getTrigger().getPoint());
            Rectangle2D plotArea = cmdPanel.getScreenDataArea();
            XYPlot plot = (XYPlot) cmdPanel.getChart().getPlot();
            double chartX = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge());
            double chartY = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge());
            points.add(new double[] { chartX, chartY });
            cmdPanel.setChart(plotCmd());
        }

        @Override
        public void chartMouseMoved(ChartMouseEvent arg0) {
        }
    });

    // Create colour combo boxes
    final JComboBox<Filter> magComboBox = new JComboBox<Filter>(filters);
    final JComboBox<Filter> col1ComboBox = new JComboBox<Filter>(filters);
    final JComboBox<Filter> col2ComboBox = new JComboBox<Filter>(filters);

    // Set initial values
    magComboBox.setSelectedItem(magFilter);
    col1ComboBox.setSelectedItem(col1Filter);
    col2ComboBox.setSelectedItem(col2Filter);

    // Create an action listener for these
    ActionListener al = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            if (evt.getSource() == magComboBox) {
                magFilter = (Filter) magComboBox.getSelectedItem();
            }
            if (evt.getSource() == col1ComboBox) {
                col1Filter = (Filter) col1ComboBox.getSelectedItem();
            }
            if (evt.getSource() == col2ComboBox) {
                col2Filter = (Filter) col2ComboBox.getSelectedItem();
            }
            // Changed colour(s), so reset selection box coordinates
            points.clear();
            cmdPanel.setChart(updateDataAndPlotCmd(allSources));
        }
    };
    magComboBox.addActionListener(al);
    col1ComboBox.addActionListener(al);
    col2ComboBox.addActionListener(al);
    // Add a bit of padding to space things out
    magComboBox.setBorder(new EmptyBorder(5, 5, 5, 5));
    col1ComboBox.setBorder(new EmptyBorder(5, 5, 5, 5));
    col2ComboBox.setBorder(new EmptyBorder(5, 5, 5, 5));

    // Set up statistic sliders
    final JSlider magErrMaxSlider = GuiUtil.buildSlider(magErrorRangeMin, magErrorRangeMax, 3, "%3.3f");
    final JSlider chi2MaxSlider = GuiUtil.buildSlider(chi2RangeMin, chi2RangeMax, 3, "%3.3f");
    final JSlider sharpMinSlider = GuiUtil.buildSlider(sharpRangeMin, sharpRangeMax, 3, "%3.3f");
    final JSlider sharpMaxSlider = GuiUtil.buildSlider(sharpRangeMin, sharpRangeMax, 3, "%3.3f");

    // Set intial values
    magErrMaxSlider.setValue(
            (int) Math.rint(100.0 * (magErrMax - magErrorRangeMin) / (magErrorRangeMax - magErrorRangeMin)));
    chi2MaxSlider.setValue((int) Math.rint(100.0 * (chi2Max - chi2RangeMin) / (chi2RangeMax - chi2RangeMin)));
    sharpMinSlider
            .setValue((int) Math.rint(100.0 * (sharpMin - sharpRangeMin) / (sharpRangeMax - sharpRangeMin)));
    sharpMaxSlider
            .setValue((int) Math.rint(100.0 * (sharpMax - sharpRangeMin) / (sharpRangeMax - sharpRangeMin)));

    // Set labels & initial values
    final JLabel magErrMaxLabel = new JLabel(getMagErrMaxLabel());
    final JLabel chi2MaxLabel = new JLabel(getChi2MaxLabel());
    final JLabel sharpMinLabel = new JLabel(getSharpMinLabel());
    final JLabel sharpMaxLabel = new JLabel(getSharpMaxLabel());

    // Create a change listener fot these
    ChangeListener cl = new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();

            if (source == magErrMaxSlider) {
                // Compute max mag error from slider position
                double newMagErrMax = magErrorRangeMin
                        + (magErrorRangeMax - magErrorRangeMin) * (source.getValue() / 100.0);
                magErrMax = newMagErrMax;
                magErrMaxLabel.setText(getMagErrMaxLabel());
            }
            if (source == chi2MaxSlider) {
                // Compute Chi2 max from slider position
                double newChi2Max = chi2RangeMin + (chi2RangeMax - chi2RangeMin) * (source.getValue() / 100.0);
                chi2Max = newChi2Max;
                chi2MaxLabel.setText(getChi2MaxLabel());
            }
            if (source == sharpMinSlider) {
                // Compute sharp min from slider position
                double newSharpMin = sharpRangeMin
                        + (sharpRangeMax - sharpRangeMin) * (source.getValue() / 100.0);
                sharpMin = newSharpMin;
                sharpMinLabel.setText(getSharpMinLabel());
            }
            if (source == sharpMaxSlider) {
                // Compute sharp max from slider position
                double newSharpMax = sharpRangeMin
                        + (sharpRangeMax - sharpRangeMin) * (source.getValue() / 100.0);
                sharpMax = newSharpMax;
                sharpMaxLabel.setText(getSharpMaxLabel());
            }
            cmdPanel.setChart(updateDataAndPlotCmd(allSources));
        }
    };
    magErrMaxSlider.addChangeListener(cl);
    chi2MaxSlider.addChangeListener(cl);
    sharpMinSlider.addChangeListener(cl);
    sharpMaxSlider.addChangeListener(cl);
    // Add a bit of padding to space things out
    magErrMaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5));
    chi2MaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5));
    sharpMinSlider.setBorder(new EmptyBorder(5, 5, 5, 5));
    sharpMaxSlider.setBorder(new EmptyBorder(5, 5, 5, 5));

    // Text field to store distance modulus
    final JTextField distanceModulusField = new JTextField(Double.toString(mu));
    distanceModulusField.setBorder(new EmptyBorder(5, 5, 5, 5));

    Border compound = BorderFactory.createCompoundBorder(new LineBorder(this.getBackground(), 5),
            BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));

    final JButton lfButton = new JButton("Luminosity function for selection");
    lfButton.setBorder(compound);
    lfButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {

            // Read distance modulus field
            try {
                double mu_new = Double.parseDouble(distanceModulusField.getText());
                mu = mu_new;
            } catch (NullPointerException | NumberFormatException ex) {
                JOptionPane.showMessageDialog(lfButton,
                        "Error parsing the distance modulus: " + ex.getMessage(), "Distance Modulus Error",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }

            if (boxedSources.isEmpty()) {
                JOptionPane.showMessageDialog(lfButton, "No sources are currently selected!", "Selection Error",
                        JOptionPane.ERROR_MESSAGE);
            } else {
                computeAndPlotLuminosityFunction(boxedSources);
            }
        }
    });
    final JButton clearSelectionButton = new JButton("Clear selection");
    clearSelectionButton.setBorder(compound);
    clearSelectionButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            points.clear();
            cmdPanel.setChart(plotCmd());
        }
    });

    JPanel controls = new JPanel(new GridLayout(9, 2));
    controls.setBorder(new EmptyBorder(10, 10, 10, 10));
    controls.add(new JLabel("Magnitude = "));
    controls.add(magComboBox);
    controls.add(new JLabel("Colour 1 = "));
    controls.add(col1ComboBox);
    controls.add(new JLabel("Colour 2 = "));
    controls.add(col2ComboBox);
    controls.add(magErrMaxLabel);
    controls.add(magErrMaxSlider);
    controls.add(chi2MaxLabel);
    controls.add(chi2MaxSlider);
    controls.add(sharpMinLabel);
    controls.add(sharpMinSlider);
    controls.add(sharpMaxLabel);
    controls.add(sharpMaxSlider);
    controls.add(new JLabel("Adopted distance modulus = "));
    controls.add(distanceModulusField);
    controls.add(lfButton);
    controls.add(clearSelectionButton);

    this.setLayout(new BorderLayout());
    this.add(cmdPanel, BorderLayout.CENTER);
    this.add(controls, BorderLayout.SOUTH);

    this.validate();
}

From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java

private JPanel getJPanel3() {
    if (jPanel3 == null) {
        jPanel3 = new JPanel();
        TableLayout jPanel3Layout = new TableLayout(new double[][] {
                { TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL },
                { TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL,
                        TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL } });
        jPanel3Layout.setHGap(5);/*from  ww  w  . j a v a  2  s  .c om*/
        jPanel3Layout.setVGap(5);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        jPanel3.add(getJPanel1(), "0, 5, 1, 8, l, f");
        {
            jlblCurrentTime = new javax.swing.JLabel();
            jPanel3.add(jlblCurrentTime, "0, 0, 1, 1");
            jPanel3.add(getJpnlDateChooser(), "0, 0, 1, 4");
            jPanel3.add(getJchkCompleted(), "3, 0, 4, 2");
            jPanel3.add(getLblMessages(), "2, 6, 4, 8");
            jlblCurrentTime.setFont(new java.awt.Font("Tahoma", 1, 14));
            jlblCurrentTime.setVerticalAlignment(SwingConstants.TOP);
            jlblCurrentTime.setVisible(false);
        }
    }
    return jPanel3;
}

From source file:edu.ku.brc.specify.extras.ViewToSchemaReview.java

/**
 * /*from   w  w  w.  ja va2s .  co m*/
 */
public void checkSchemaAndViews() {

    Hashtable<String, HashSet<String>> viewFieldHash = new Hashtable<String, HashSet<String>>();

    SpecifyAppContextMgr sacm = (SpecifyAppContextMgr) AppContextMgr.getInstance();

    for (ViewIFace view : sacm.getEntirelyAllViews()) {
        //System.err.println(view.getName() + " ----------------------");
        for (AltViewIFace av : view.getAltViews()) {
            ViewDefIFace vd = av.getViewDef();
            if (vd.getType() == ViewType.form) {
                DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(vd.getClassName());
                if (ti != null) {
                    HashSet<String> tiHash = viewFieldHash.get(ti.getName());
                    if (tiHash == null) {
                        tiHash = new HashSet<String>();
                        viewFieldHash.put(ti.getName(), tiHash);
                    }

                    FormViewDef fvd = (FormViewDef) vd;
                    for (FormRowIFace row : fvd.getRows()) {
                        for (FormCellIFace cell : row.getCells()) {
                            if (cell.getType() == FormCellIFace.CellType.panel) {
                                FormCellPanelIFace panelCell = (FormCellPanelIFace) cell;
                                for (String fieldName : panelCell.getFieldNames()) {
                                    tiHash.add(fieldName);
                                }

                            } else if (cell.getType() == FormCellIFace.CellType.field
                                    || cell.getType() == FormCellIFace.CellType.subview) {
                                String fieldName = cell.getName();
                                if (!cell.isIgnoreSetGet() && !fieldName.equals("this")) {
                                    DBFieldInfo fi = ti.getFieldByName(fieldName);
                                    if (fi != null) {
                                        //System.err.println("Form Field["+fieldName+"] is in schema.");
                                        tiHash.add(fieldName);
                                    } else {
                                        DBRelationshipInfo ri = ti.getRelationshipByName(fieldName);
                                        if (ri == null) {
                                            //System.err.println("Form Field["+fieldName+"] not in table.");
                                        } else {
                                            tiHash.add(fieldName);
                                        }
                                    }
                                } else if (cell instanceof FormCellFieldIFace) {
                                    FormCellFieldIFace fcf = (FormCellFieldIFace) cell;
                                    if (fcf.getUiType() == FormCellFieldIFace.FieldType.plugin) {
                                        String pluginName = fcf.getProperty("name");
                                        if (StringUtils.isNotEmpty(pluginName)) {
                                            checkPluginForNames(fcf, pluginName, tiHash);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    for (DBTableInfo ti : DBTableIdMgr.getInstance().getTables()) {
        int cnt = 0;

        HashSet<String> tiHash = viewFieldHash.get(ti.getName());
        if (tiHash != null) {
            tblTitle2Name.put(ti.getTitle(), ti.getName());

            //System.err.println(ti.getName() + " ----------------------");
            for (DBFieldInfo fi : ti.getFields()) {
                Boolean isInForm = tiHash.contains(fi.getName());
                modelList.add(
                        createRow(ti.getTitle(), fi.getName(), fi.getTitle(), isInForm, fi.isHidden(), cnt++));
            }

            for (DBRelationshipInfo ri : ti.getRelationships()) {
                Boolean isInForm = tiHash.contains(ri.getName());
                modelList.add(
                        createRow(ti.getTitle(), ri.getName(), ri.getTitle(), isInForm, ri.isHidden(), cnt++));
            }
        }
    }

    viewModel = new ViewModel();
    JTable table = new JTable(viewModel);

    sorter = new TableRowSorter<TableModel>(viewModel);
    searchTF = new JAutoCompTextField(20);

    table.setRowSorter(sorter);

    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g", "p,4px,f:p:g,2px,p:g"));
    SearchBox searchBox = new SearchBox(searchTF, null);

    filterCBX = UIHelper.createComboBox(new String[] { "None", "Not On Form, Not Hidden", "On Form, Hidden" });

    PanelBuilder searchPB = new PanelBuilder(new FormLayout("p,2px,p, f:p:g, p,2px,p", "p"));
    searchPB.add(UIHelper.createI18NFormLabel("SEARCH"), cc.xy(1, 1));
    searchPB.add(searchBox, cc.xy(3, 1));
    searchPB.add(UIHelper.createI18NFormLabel("Filter"), cc.xy(5, 1));
    searchPB.add(filterCBX, cc.xy(7, 1));

    JLabel legend = UIHelper.createLabel(
            "<HTML><li><font color=\"red\">Red</font> - Not on form and not hidden</li><li><font color=\"magenta\">Magenta</font> - On the form , but is hidden</li><li>Black - Correct</li>");
    legend.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
    PanelBuilder legPB = new PanelBuilder(new FormLayout("p,f:p:g", "p"));
    legPB.add(legend, cc.xy(1, 1));

    pb.add(searchPB.getPanel(), cc.xy(1, 1));
    pb.add(UIHelper.createScrollPane(table), cc.xy(1, 3));
    pb.add(legPB.getPanel(), cc.xy(1, 5));
    pb.setDefaultDialogBorder();

    sorter.setRowFilter(null);

    searchTF.getDocument().addDocumentListener(new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent e) {
            SwingUtilities.invokeLater(new Runnable() {

                /* (non-Javadoc)
                 * @see java.lang.Runnable#run()
                 */
                @Override
                public void run() {
                    if (filterCBX.getSelectedIndex() > 0) {
                        blockCBXUpdate = true;
                        filterCBX.setSelectedIndex(-1);
                        blockCBXUpdate = false;
                    }
                    String text = searchTF.getText();
                    sorter.setRowFilter(text.isEmpty() ? null : RowFilter.regexFilter("^(?i)" + text, 0, 1));
                }
            });
        }
    });

    filterCBX.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    if (!blockCBXUpdate) {
                        RowFilter<TableModel, Integer> filter = null;
                        int inx = filterCBX.getSelectedIndex();
                        if (inx > 0) {
                            filter = filterCBX.getSelectedIndex() == 1 ? new NotOnFormNotHiddenRowFilter()
                                    : new OnFormIsHiddenRowFilter();
                        }
                        sorter.setRowFilter(filter);
                    }
                }
            });
        }
    });

    table.setDefaultRenderer(String.class, new BiColorTableCellRenderer(false));
    table.setDefaultRenderer(Boolean.class, new BiColorBooleanTableCellRenderer());
    table.getColumnModel().getColumn(0).setCellRenderer(new TitleCellFadeRenderer());
    table.getColumnModel().getColumn(3).setCellRenderer(new BiColorTableCellRenderer(true));
    table.getColumnModel().getColumn(2).setCellRenderer(new BiColorTableCellRenderer(false) {
        @SuppressWarnings("unchecked")
        @Override
        public Component getTableCellRendererComponent(JTable tableArg, Object value, boolean isSelected,
                boolean hasFocus, int row, int column) {
            JLabel lbl = (JLabel) super.getTableCellRendererComponent(tableArg, value, isSelected, hasFocus,
                    row, column);

            /*if (sorter.getRowFilter() != null)
            {
            System.out.println(" getRowCount:"+sorter.getModel().getRowCount());
            Pair<String, Integer> col1Pair = (Pair<String, Integer>)sorter.getModel().getValueAt(row, 0);
            rowData = modelList.get(col1Pair.second);
                    
            } else
            {
            rowData = modelList.get(row);
            }*/

            //System.out.println(" R2:"+row+"  "+rowData[0]+"/"+rowData[1]+" - "+rowData[3]+"|"+rowData[4]);
            if (value instanceof TableInfo) {
                TableInfo pair = (TableInfo) value;
                Object[] rowData = modelList.get(pair.getSecond());
                lbl.setText(rowData[0].toString());

            } else if (value instanceof Pair<?, ?>) {
                Pair<String, Integer> pair = (Pair<String, Integer>) value;
                Object[] rowData = modelList.get(pair.getSecond());

                boolean isOnForm = rowData[3] instanceof Boolean ? (Boolean) rowData[3]
                        : ((String) rowData[3]).equals("Yes");
                boolean isHidden = rowData[4] instanceof Boolean ? (Boolean) rowData[4]
                        : ((String) rowData[4]).equals("true");

                if (!isOnForm && !isHidden) {
                    lbl.setForeground(Color.RED);

                } else if (isOnForm && isHidden) {
                    lbl.setForeground(Color.MAGENTA);
                } else {
                    lbl.setForeground(Color.BLACK);
                }
                lbl.setText(pair.getFirst());
            } else {
                lbl.setText(value.toString());
            }
            return lbl;
        }

    });

    //UIHelper.makeTableHeadersCentered(table, false);
    UIHelper.calcColumnWidths(table, null);

    //Removing fix all button because fix() method is broken (bug #8087)...

    /*CustomDialog dlg = new CustomDialog((Frame)UIRegistry.getTopWindow(), "", true, CustomDialog.OKCANCELAPPLY, pb.getPanel()) 
    {
    @Override
    protected void applyButtonPressed()
    {
        fix(this);
    }
    };
    dlg.setApplyLabel("Fix All");*/

    CustomDialog dlg = new CustomDialog((Frame) UIRegistry.getTopWindow(), "", true, CustomDialog.OKCANCEL,
            pb.getPanel());

    //... end removing fix all button

    dlg.setVisible(true);

    if (!dlg.isCancelled()) {
        updateSchema();
    }
}

From source file:ffx.ui.MainPanel.java

/**
 * <p>//w  w w .jav a  2  s  . c o  m
 * about</p>
 */
public void about() {
    if (aboutDialog == null) {
        aboutDialog = new JDialog(frame, "About... ", true);
        URL ffxURL = getClass().getClassLoader().getResource("ffx/ui/icons/splash.png");
        ImageIcon logoIcon = new ImageIcon(ffxURL);
        JLabel logoLabel = new JLabel(logoIcon);
        logoLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
        Container contentpane = aboutDialog.getContentPane();
        contentpane.setLayout(new BorderLayout());
        initAbout();
        contentpane.add(aboutTextArea, BorderLayout.SOUTH);
        contentpane.add(logoLabel, BorderLayout.CENTER);
        aboutDialog.pack();
        Dimension dim = getToolkit().getScreenSize();
        Dimension ddim = aboutDialog.getSize();
        aboutDialog.setLocation((dim.width - ddim.width) / 2, (dim.height - ddim.height) / 2);
        aboutDialog.setResizable(false);
    }
    aboutDialog.setVisible(true);
}

From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java

private JPanel getJPanel4() {
    if (jPanel4 == null) {
        jPanel4 = new JPanel();
        TableLayout jPanel4Layout = new TableLayout(
                new double[][] { { TableLayout.FILL, TableLayout.FILL, TableLayout.FILL, TableLayout.FILL },
                        { TableLayout.FILL, TableLayout.FILL } });
        jPanel4Layout.setHGap(5);//ww w. j  a va 2  s. c o m
        jPanel4Layout.setVGap(5);
        jPanel4.setLayout(jPanel4Layout);
        {
            jcbTodos = new javax.swing.JComboBox();
            jPanel4.add(jcbTodos, "0,1,3,1,f,f");
            jPanel4.add(getJlblTodoList(), "0,0,f,b");
            jcbTodos.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
            jcbTodos.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent evt) {
                    jcbTodosItemStateChanged(evt);
                }
            });
        }
    }
    return jPanel4;
}

From source file:userinterface.graph.Histogram.java

/**
 * Generates the property dialog for a Histogram. Allows the user to select either a new or an exisitng Histogram
 * to plot data on/*  w  ww .  j a v a  2 s  . com*/
 * 
 * @param defaultSeriesName
 * @param handler instance of {@link GUIGraphHandler}
 * @param minVal the min value in data cache
 * @param maxVal the max value in data cache
 * @return Either a new instance of a Histogram or an old one depending on what the user selects
 */

public static Pair<Histogram, SeriesKey> showPropertiesDialog(String defaultSeriesName, GUIGraphHandler handler,
        double minVal, double maxVal) {

    // make sure that the probabilities are valid
    if (maxVal > 1.0)
        maxVal = 1.0;
    if (minVal < 0.0)
        minVal = 0.0;

    // set properties for the dialog
    JDialog dialog = new JDialog(GUIPrism.getGUI(), "Histogram properties", true);
    dialog.setLayout(new BorderLayout());

    JPanel p1 = new JPanel(new FlowLayout());
    p1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
            "Number of buckets"));

    JPanel p2 = new JPanel(new FlowLayout());
    p2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED),
            "Series name"));

    JSpinner buckets = new JSpinner(new SpinnerNumberModel(10, 5, Integer.MAX_VALUE, 1));
    buckets.setToolTipText("Select the number of buckets for this Histogram");

    // provides the ability to select a new or an old histogram to plot the series on
    JTextField seriesName = new JTextField(defaultSeriesName);
    JRadioButton newSeries = new JRadioButton("New Histogram");
    JRadioButton existing = new JRadioButton("Existing Histogram");
    newSeries.setSelected(true);
    JPanel seriesSelectPanel = new JPanel();
    seriesSelectPanel.setLayout(new BoxLayout(seriesSelectPanel, BoxLayout.Y_AXIS));
    JPanel seriesTypeSelect = new JPanel(new FlowLayout());
    JPanel seriesOptionsPanel = new JPanel(new FlowLayout());
    seriesTypeSelect.add(newSeries);
    seriesTypeSelect.add(existing);
    JComboBox<String> seriesOptions = new JComboBox<>();
    seriesOptionsPanel.add(seriesOptions);
    seriesSelectPanel.add(seriesTypeSelect);
    seriesSelectPanel.add(seriesOptionsPanel);
    seriesSelectPanel.setBorder(BorderFactory
            .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Add series to"));

    // provides ability to select the min/max range of the plot
    JLabel minValsLabel = new JLabel("Min range:");
    JSpinner minVals = new JSpinner(new SpinnerNumberModel(0.0, 0.0, minVal, 0.01));
    minVals.setToolTipText("Does not allow value more than the min value in the probabilities");
    JLabel maxValsLabel = new JLabel("Max range:");
    JSpinner maxVals = new JSpinner(new SpinnerNumberModel(1.0, maxVal, 1.0, 0.01));
    maxVals.setToolTipText("Does not allow value less than the max value in the probabilities");
    JPanel minMaxPanel = new JPanel();
    minMaxPanel.setLayout(new BoxLayout(minMaxPanel, BoxLayout.X_AXIS));
    JPanel leftValsPanel = new JPanel(new BorderLayout());
    JPanel rightValsPanel = new JPanel(new BorderLayout());
    minMaxPanel.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Range"));
    leftValsPanel.add(minValsLabel, BorderLayout.WEST);
    leftValsPanel.add(minVals, BorderLayout.CENTER);
    rightValsPanel.add(maxValsLabel, BorderLayout.WEST);
    rightValsPanel.add(maxVals, BorderLayout.CENTER);
    minMaxPanel.add(leftValsPanel);
    minMaxPanel.add(rightValsPanel);

    // fill the old histograms in the property dialog

    boolean found = false;
    for (int i = 0; i < handler.getNumModels(); i++) {

        if (handler.getModel(i) instanceof Histogram) {

            seriesOptions.addItem(handler.getGraphName(i));
            found = true;
        }

    }

    existing.setEnabled(found);
    seriesOptions.setEnabled(false);

    // the bottom panel
    JPanel options = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton ok = new JButton("Plot");
    JButton cancel = new JButton("Cancel");

    // bind keyboard keys to plot and cancel buttons to improve usability

    ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok");
    ok.getActionMap().put("ok", new AbstractAction() {

        private static final long serialVersionUID = -7324877661936685228L;

        @Override
        public void actionPerformed(ActionEvent e) {

            ok.doClick();

        }
    });

    cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            "ok");
    cancel.getActionMap().put("ok", new AbstractAction() {

        private static final long serialVersionUID = 2642213543774356676L;

        @Override
        public void actionPerformed(ActionEvent e) {

            cancel.doClick();

        }
    });

    //Action listener for the new series radio button
    newSeries.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (newSeries.isSelected()) {

                existing.setSelected(false);
                seriesOptions.setEnabled(false);
                buckets.setEnabled(true);
                buckets.setToolTipText("Select the number of buckets for this Histogram");
                minVals.setEnabled(true);
                maxVals.setEnabled(true);
            }
        }
    });

    //Action listener for the existing series radio button
    existing.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            if (existing.isSelected()) {

                newSeries.setSelected(false);
                seriesOptions.setEnabled(true);
                buckets.setEnabled(false);
                minVals.setEnabled(false);
                maxVals.setEnabled(false);
                buckets.setToolTipText("Number of buckets can't be changed on an existing Histogram");
            }

        }
    });

    //Action listener for the plot button
    ok.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {

            dialog.dispose();

            if (newSeries.isSelected()) {

                hist = new Histogram();
                hist.setNumOfBuckets((int) buckets.getValue());
                hist.setIsNew(true);

            } else if (existing.isSelected()) {

                String HistName = (String) seriesOptions.getSelectedItem();
                hist = (Histogram) handler.getModel(HistName);
                hist.setIsNew(false);

            }

            key = hist.addSeries(seriesName.getText());

            if (minVals.isEnabled() && maxVals.isEnabled()) {

                hist.setMinProb((double) minVals.getValue());
                hist.setMaxProb((double) maxVals.getValue());

            }
        }
    });

    //Action listener for the cancel button
    cancel.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
            hist = null;
        }
    });

    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {

            hist = null;
        }
    });

    p1.add(buckets, BorderLayout.CENTER);

    p2.add(seriesName, BorderLayout.CENTER);

    options.add(ok);
    options.add(cancel);

    // add everything to the main panel of the dialog
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(seriesSelectPanel);
    mainPanel.add(p1);
    mainPanel.add(p2);
    mainPanel.add(minMaxPanel);

    // add main panel to the dialog
    dialog.add(mainPanel, BorderLayout.CENTER);
    dialog.add(options, BorderLayout.SOUTH);

    // set dialog properties
    dialog.setSize(320, 290);
    dialog.setLocationRelativeTo(GUIPrism.getGUI());
    dialog.setVisible(true);

    // return the user selected Histogram with the properties set
    return new Pair<Histogram, SeriesKey>(hist, key);
}

From source file:com.jwmsolutions.timeCheck.gui.TodoForm.java

private JComboBox getJcbListsObject() {
    if (jcbLists == null) {
        ComboBoxModel jcbListModel = new DefaultComboBoxModel(new String[] { "Item One", "Item Two" });
        jcbListModel.setSelectedItem("");
        jcbLists = new JComboBox();
        jcbLists.setModel(jcbListModel);
        jcbLists.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
        jcbLists.setAutoscrolls(true);//from w w w.  j  av a2s  .co m
        jcbLists.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent evt) {
                jcbListsItemStateChanged(evt);
            }
        });
    }
    return jcbLists;
}