Example usage for javax.swing SpinnerNumberModel SpinnerNumberModel

List of usage examples for javax.swing SpinnerNumberModel SpinnerNumberModel

Introduction

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

Prototype

public SpinnerNumberModel(double value, double minimum, double maximum, double stepSize) 

Source Link

Document

Constructs a SpinnerNumberModel with the specified value, minimum/maximum bounds, and stepSize.

Usage

From source file:cgpanalyser.gui.MainWindow.java

/**
 * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of
 * this method is always regenerated by the Form Editor.
 *///from ww w.  j av a  2 s  .co  m
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    btnCompare = new javax.swing.JButton();
    btnNextGraph = new javax.swing.JButton();
    btnZoomInGraph = new javax.swing.JButton();
    btnPrevGraph = new javax.swing.JButton();
    btnZoomOutGraph = new javax.swing.JButton();
    jSplitPane1 = new javax.swing.JSplitPane();
    panelMain = new cgpanalyser.gui.MainPanel(dVars, gateFuncsAll, this);
    xYChartPanel = new cgpanalyser.gui.chart.XYChartPanel(jFreeChart, panelMain);
    checkBoxGreyUnused = new javax.swing.JCheckBox();
    checkBoxColorsFF = new javax.swing.JCheckBox();
    spinnerFitDeltaThreshold = new javax.swing.JSpinner(new SpinnerNumberModel(0, 0, 9999, 1));
    btnResample = new javax.swing.JButton();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    menuOpenEvo = new javax.swing.JMenuItem();
    menuOpenFF = new javax.swing.JMenuItem();
    menuDefaultFF = new javax.swing.JMenuItem();
    menuGateUsage = new javax.swing.JMenuItem();
    jMenu2 = new javax.swing.JMenu();
    menuAbout = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("CGP Analyser");

    btnCompare.setText("Compare");
    btnCompare.setToolTipText("Compare selected chromosomes (with left and right mouse button).");
    btnCompare.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnCompareActionPerformed(evt);
        }
    });

    btnNextGraph.setText(">");
    btnNextGraph.setToolTipText("Graph next.");
    btnNextGraph.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnNextGraphActionPerformed(evt);
        }
    });

    btnZoomInGraph.setText("Zoom In");
    btnZoomInGraph.setToolTipText("Graph zoom in selected area.");
    btnZoomInGraph.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnZoomInGraphActionPerformed(evt);
        }
    });

    btnPrevGraph.setText("<");
    btnPrevGraph.setToolTipText("Graph previous.");
    btnPrevGraph.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnPrevGraphActionPerformed(evt);
        }
    });

    btnZoomOutGraph.setText("Zoom Out");
    btnZoomOutGraph.setToolTipText("Graph zoom out.");
    btnZoomOutGraph.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnZoomOutGraphActionPerformed(evt);
        }
    });

    jSplitPane1.setBorder(null);
    jSplitPane1.setDividerSize(6);
    jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
    jSplitPane1.setResizeWeight(0.5);

    javax.swing.GroupLayout panelMainLayout = new javax.swing.GroupLayout(panelMain);
    panelMain.setLayout(panelMainLayout);
    panelMainLayout.setHorizontalGroup(panelMainLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 0, Short.MAX_VALUE));
    panelMainLayout.setVerticalGroup(panelMainLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 369, Short.MAX_VALUE));

    jSplitPane1.setRightComponent(panelMain);

    xYChartPanel.setPreferredSize(new java.awt.Dimension(680, 280));
    xYChartPanel.setLayout(null);
    jSplitPane1.setLeftComponent(xYChartPanel);

    checkBoxGreyUnused.setSelected(true);
    checkBoxGreyUnused.setText("Grey Unused");
    checkBoxGreyUnused.setToolTipText("Gery unused elements.");
    checkBoxGreyUnused.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            checkBoxGreyUnusedActionPerformed(evt);
        }
    });

    checkBoxColorsFF.setSelected(true);
    checkBoxColorsFF.setText("Function colors");
    checkBoxColorsFF.setToolTipText("Use colors from function file.");
    checkBoxColorsFF.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            checkBoxColorsFFActionPerformed(evt);
        }
    });

    spinnerFitDeltaThreshold
            .setToolTipText("Fitness delta threshold for graph sampling - higher threshold, less samples.");
    spinnerFitDeltaThreshold.setPreferredSize(new java.awt.Dimension(29, 23));

    btnResample.setText("Resample");
    btnResample.setToolTipText(
            "Sample graph data again with new threshold. Too low threshold may cause performance or memory issues.");
    btnResample.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnResampleActionPerformed(evt);
        }
    });

    jMenu1.setText("File");

    menuOpenEvo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
            java.awt.event.InputEvent.CTRL_MASK));
    menuOpenEvo.setText("Open Evolution");
    menuOpenEvo.setToolTipText("Open evolution record file.");
    menuOpenEvo.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuOpenEvoActionPerformed(evt);
        }
    });
    jMenu1.add(menuOpenEvo);

    menuOpenFF.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
            java.awt.event.InputEvent.CTRL_MASK));
    menuOpenFF.setText("Open Function File");
    menuOpenFF.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuOpenFFActionPerformed(evt);
        }
    });
    jMenu1.add(menuOpenFF);

    menuDefaultFF.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P,
            java.awt.event.InputEvent.CTRL_MASK));
    menuDefaultFF.setText("Create Default FF");
    menuDefaultFF.setToolTipText("Creates default function file in current working directory.");
    menuDefaultFF.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuDefaultFFActionPerformed(evt);
        }
    });
    jMenu1.add(menuDefaultFF);

    menuGateUsage.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U,
            java.awt.event.InputEvent.CTRL_MASK));
    menuGateUsage.setText("Gate Usage");
    menuGateUsage.setToolTipText("Swot stats of used function in whole evolution (best chromosomes only).");
    menuGateUsage.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuGateUsageActionPerformed(evt);
        }
    });
    jMenu1.add(menuGateUsage);

    jMenuBar1.add(jMenu1);

    jMenu2.setText("Help");

    menuAbout.setText("About");
    menuAbout.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            menuAboutActionPerformed(evt);
        }
    });
    jMenu2.add(menuAbout);

    jMenuBar1.add(jMenu2);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup().addGap(0, 0, 0).addComponent(btnCompare)
                            .addGap(12, 12, 12).addComponent(btnZoomOutGraph).addGap(6, 6, 6)
                            .addComponent(btnZoomInGraph).addGap(12, 12, 12).addComponent(btnPrevGraph)
                            .addGap(6, 6, 6).addComponent(btnNextGraph).addGap(12, 12, 12)
                            .addComponent(checkBoxGreyUnused).addGap(6, 6, 6).addComponent(checkBoxColorsFF)
                            .addGap(12, 12, 12)
                            .addComponent(spinnerFitDeltaThreshold, javax.swing.GroupLayout.PREFERRED_SIZE, 65,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(6, 6, 6).addComponent(btnResample).addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 1216, Short.MAX_VALUE))
                    .addContainerGap()));

    layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { btnZoomInGraph, btnZoomOutGraph });

    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGap(6, 6, 6)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnCompare).addComponent(btnNextGraph).addComponent(btnZoomInGraph)
                            .addComponent(btnPrevGraph).addComponent(btnZoomOutGraph)
                            .addComponent(checkBoxGreyUnused).addComponent(checkBoxColorsFF)
                            .addComponent(spinnerFitDeltaThreshold, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnResample))
                    .addGap(6, 6, 6)
                    .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
                    .addGap(12, 12, 12)));

    pack();
}

From source file:filterviewplugin.FilterViewSettingsTab.java

public JPanel createSettingsPanel() {
    final EnhancedPanelBuilder panelBuilder = new EnhancedPanelBuilder(FormFactory.RELATED_GAP_COLSPEC.encode()
            + ',' + FormFactory.PREF_COLSPEC.encode() + ',' + FormFactory.RELATED_GAP_COLSPEC.encode() + ','
            + FormFactory.PREF_COLSPEC.encode() + ", fill:default:grow");
    final CellConstraints cc = new CellConstraints();

    final JLabel label = new JLabel(mLocalizer.msg("daysToShow", "Days to show"));

    panelBuilder.addRow();/*from  w  w  w.ja  v a2s  .c  o  m*/
    panelBuilder.add(label, cc.xy(2, panelBuilder.getRow()));

    final SpinnerNumberModel model = new SpinnerNumberModel(3, 1, 7, 1);
    mSpinner = new JSpinner(model);
    mSpinner.setValue(mSettings.getDays());
    panelBuilder.add(mSpinner, cc.xy(4, panelBuilder.getRow()));

    panelBuilder.addParagraph(mLocalizer.msg("filters", "Filters to show"));

    mFilterList = new SelectableItemList(mSettings.getActiveFilterNames(),
            FilterViewSettings.getAvailableFilterNames());
    mIcons.clear();
    for (String filterName : FilterViewSettings.getAvailableFilterNames()) {
        mIcons.put(filterName, mSettings.getFilterIconName(mSettings.getFilter(filterName)));
    }
    mFilterList.addCenterRendererComponent(String.class, new SelectableItemRendererCenterComponentIf() {
        private DefaultListCellRenderer mRenderer = new DefaultListCellRenderer();

        public void calculateSize(JList list, int index, JPanel contentPane) {
        }

        public JPanel createCenterPanel(JList list, Object value, int index, boolean isSelected,
                boolean isEnabled, JScrollPane parentScrollPane, int leftColumnWidth) {
            DefaultListCellRenderer label = (DefaultListCellRenderer) mRenderer
                    .getListCellRendererComponent(list, value, index, isSelected, false);
            String filterName = value.toString();
            String iconFileName = mIcons.get(filterName);
            Icon icon = null;
            if (!StringUtils.isEmpty(iconFileName)) {
                try {
                    icon = FilterViewPlugin.getInstance().getIcon(
                            FilterViewSettings.getIconDirectoryName() + File.separatorChar + iconFileName);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                label.setIcon(icon);
            }
            String text = filterName;
            if (icon == null) {
                text += " (" + mLocalizer.msg("noIcon", "no icon") + ')';
            }
            label.setText(text);
            label.setHorizontalAlignment(SwingConstants.LEADING);
            label.setVerticalAlignment(SwingConstants.CENTER);
            label.setOpaque(false);

            JPanel panel = new JPanel(new BorderLayout());
            if (isSelected && isEnabled) {
                panel.setOpaque(true);
                panel.setForeground(list.getSelectionForeground());
                panel.setBackground(list.getSelectionBackground());
            } else {
                panel.setOpaque(false);
                panel.setForeground(list.getForeground());
                panel.setBackground(list.getBackground());
            }
            panel.add(label, BorderLayout.WEST);
            return panel;
        }
    });

    panelBuilder.addGrowingRow();
    panelBuilder.add(mFilterList, cc.xyw(2, panelBuilder.getRow(), panelBuilder.getColumnCount() - 1));

    panelBuilder.addRow();
    mFilterButton = new JButton(mLocalizer.msg("changeIcon", "Change icon"));
    mFilterButton.setEnabled(false);
    panelBuilder.add(mFilterButton, cc.xyw(2, panelBuilder.getRow(), 1));

    mRemoveButton = new JButton(mLocalizer.msg("deleteIcon", "Remove icon"));
    mRemoveButton.setEnabled(false);
    panelBuilder.add(mRemoveButton, cc.xyw(4, panelBuilder.getRow(), 1));

    mFilterButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SelectableItem item = (SelectableItem) mFilterList.getSelectedValue();
            String filterName = (String) item.getItem();
            chooseIcon(filterName);
        }
    });

    mFilterList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            mFilterButton.setEnabled(mFilterList.getSelectedValue() != null);
            mRemoveButton.setEnabled(mFilterButton.isEnabled());
        }
    });

    mRemoveButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SelectableItem item = (SelectableItem) mFilterList.getSelectedValue();
            String filterName = (String) item.getItem();
            mIcons.put(filterName, "");
            mFilterList.updateUI();
        }
    });

    return panelBuilder.getPanel();
}

From source file:com.kbotpro.ui.FieldWatcher.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    label2 = new JLabel();
    updateRateSpinner = new JSpinner();
    label3 = new JLabel();
    scrollPane1 = new JScrollPane();
    infoLabel = new JLabel();

    //======== this ========
    setTitle("Field Watch");
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();

    //---- label2 ----
    label2.setText("Update rate:");
    label2.setLabelFor(updateRateSpinner);

    //---- updateRateSpinner ----
    updateRateSpinner.setModel(new SpinnerNumberModel(1.0, 0.1, null, 0.5));

    //---- label3 ----
    label3.setText("Times per second");

    //======== scrollPane1 ========
    {/* w  w  w.  ja v a 2 s  . c om*/

        //---- infoLabel ----
        infoLabel.setText("Field info");
        infoLabel.setVerticalAlignment(SwingConstants.TOP);
        scrollPane1.setViewportView(infoLabel);
    }

    GroupLayout contentPaneLayout = new GroupLayout(contentPane);
    contentPane.setLayout(contentPaneLayout);
    contentPaneLayout.setHorizontalGroup(contentPaneLayout.createParallelGroup()
            .add(contentPaneLayout.createSequentialGroup().addContainerGap().add(contentPaneLayout
                    .createParallelGroup().add(scrollPane1, GroupLayout.DEFAULT_SIZE, 527, Short.MAX_VALUE)
                    .add(contentPaneLayout.createSequentialGroup().add(label2)
                            .addPreferredGap(LayoutStyle.RELATED)
                            .add(updateRateSpinner, GroupLayout.PREFERRED_SIZE, 83, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.RELATED).add(label3)))
                    .addContainerGap()));
    contentPaneLayout
            .setVerticalGroup(contentPaneLayout.createParallelGroup().add(GroupLayout.TRAILING,
                    contentPaneLayout.createSequentialGroup().addContainerGap()
                            .add(scrollPane1, GroupLayout.DEFAULT_SIZE, 351, Short.MAX_VALUE)
                            .addPreferredGap(LayoutStyle.RELATED)
                            .add(contentPaneLayout.createParallelGroup(GroupLayout.BASELINE).add(label2)
                                    .add(updateRateSpinner, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .add(label3))
                            .addContainerGap()));
    pack();
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:components.SpinnerDemo3.java

public SpinnerDemo3(boolean cycleMonths) {
    super(new SpringLayout());

    String[] labels = { "Month: ", "Year: ", "Another Date: " };
    int numPairs = labels.length;
    calendar = Calendar.getInstance();
    JFormattedTextField ftf = null;

    //Add the first label-spinner pair.
    String[] monthStrings = getMonthStrings(); //get month names
    SpinnerListModel monthModel = null;
    if (cycleMonths) { //use custom model
        monthModel = new CyclingSpinnerListModel(monthStrings);
    } else { //use standard model
        monthModel = new SpinnerListModel(monthStrings);
    }/*from   w  ww. ja  v a2 s. c o  m*/
    JSpinner spinner = addLabeledSpinner(this, labels[0], monthModel);
    //Tweak the spinner's formatted text field.
    ftf = getTextField(spinner);
    if (ftf != null) {
        ftf.setColumns(8); //specify more width than we need
        ftf.setHorizontalAlignment(JTextField.RIGHT);
    }

    //Add second label-spinner pair.
    int currentYear = calendar.get(Calendar.YEAR);
    SpinnerModel yearModel = new SpinnerNumberModel(currentYear, //initial value
            currentYear - 100, //min
            currentYear + 100, //max
            1); //step
    //If we're cycling, hook this model up to the month model.
    if (monthModel instanceof CyclingSpinnerListModel) {
        ((CyclingSpinnerListModel) monthModel).setLinkedModel(yearModel);
    }
    spinner = addLabeledSpinner(this, labels[1], yearModel);
    //Make the year be formatted without a thousands separator.
    spinner.setEditor(new JSpinner.NumberEditor(spinner, "#"));

    //Add the third label-spinner pair.
    Date initDate = calendar.getTime();
    calendar.add(Calendar.YEAR, -100);
    Date earliestDate = calendar.getTime();
    calendar.add(Calendar.YEAR, 200);
    Date latestDate = calendar.getTime();
    SpinnerDateModel dateModel = new SpinnerDateModel(initDate, earliestDate, latestDate, Calendar.YEAR);//ignored for user input
    dateSpinner = spinner = addLabeledSpinner(this, labels[2], dateModel);
    spinner.setEditor(new JSpinner.DateEditor(spinner, "MM/yyyy"));
    //Tweak the spinner's formatted text field.
    ftf = getTextField(spinner);
    if (ftf != null) {
        ftf.setHorizontalAlignment(JTextField.RIGHT);
        ftf.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 3));
    }
    spinner.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
    //XXX: No easy way to get to the buttons and change their border.
    setSeasonalColor(dateModel.getDate()); //initialize color

    //Listen for changes on the date spinner.
    dateSpinner.addChangeListener(this);

    //Lay out the panel.
    SpringUtilities.makeCompactGrid(this, numPairs, 2, //rows, cols
            10, 10, //initX, initY
            6, 10); //xPad, yPad
}

From source file:edu.ku.brc.af.ui.forms.validation.ValSpinner.java

/**
 * Sets a new Model with a new Min,Max range.
 * @param min the min value // w w  w .j  a  va  2  s .  com
 * @param max the max value
 * @param val the initial value
 */
public void setRange(final int minVal, final int maxVal, final int val) {
    this.minValue = minVal;
    this.maxValue = maxVal;

    setModel(new SpinnerNumberModel(val, // initial value
            minVal, // min
            maxVal, // max
            1));
}

From source file:brainflow.app.presentation.controls.FileObjectGroupSelector.java

public FileObjectGroupSelector(FileObject root) throws FileSystemException {
    if (root.getType() != FileType.FOLDER) {
        throw new IllegalArgumentException("root file must be a directory");
    }//from  w  w w  . j  ava2  s . co  m

    rootFolder = root;
    explorer = new FileExplorer(rootFolder);
    explorer.getJTree().setRootVisible(false);
    explorer.getJTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);

    setLayout(new BorderLayout());

    Box topPanel = new Box(BoxLayout.X_AXIS);
    topPanel.setBorder(BorderFactory.createEmptyBorder(8, 12, 8, 8));
    topPanel.add(regexLabel);
    topPanel.add(regexField);
    topPanel.add(Box.createHorizontalStrut(4));
    topPanel.add(searchType);
    add(topPanel, BorderLayout.NORTH);

    //JPanel mainPanel = new JPanel();
    //MigLayout layout = new MigLayout("");
    // mainPanel.setLayout(layout);

    //add(regexLabel);
    //add(regexField, "gap left 0, growx");
    //add(findButton, "align right, wrap");

    //add(searchType, "wrap");

    //add(createSplitPane(), "span 3, grow, wrap");
    add(createSplitPane(), BorderLayout.CENTER);

    depthSpinner.setMaximumSize(new Dimension(50, 200));
    depthSpinner.setModel(new SpinnerNumberModel(recursiveDepth, 0, 5, 1));

    JPanel bottomPanel = new JPanel();
    MigLayout layout = new MigLayout("", "[][grow]", "[][]");
    bottomPanel.setLayout(layout);

    //bottomPanel.setBorder(BorderFactory.createEmptyBorder(4,12,8,8));
    bottomPanel.add(new JLabel("Root Folder: "));
    rootField.setEditable(false);
    rootField.setText(root.getName().getBaseName());
    bottomPanel.add(rootField, "wrap, width 150:150:150");
    bottomPanel.add(new JLabel("Search Depth: "), "gap top 8");

    bottomPanel.add(depthSpinner, "width 35:45:55, wrap");
    add(bottomPanel, BorderLayout.SOUTH);

    explorer.addTreeSelectionListener(new TreeSelectionListener() {
        @Override
        public void valueChanged(TreeSelectionEvent e) {
            TreePath path = e.getPath();
            Object[] obj = path.getPath();
            Object lastNode = obj[obj.length - 1];
            if (lastNode instanceof FileExplorer.FileObjectNode) {
                FileExplorer.FileObjectNode fnode = (FileExplorer.FileObjectNode) lastNode;
                try {
                    if (fnode.getFileObject().getType() == FileType.FOLDER) {
                        rootField.setText(fnode.getFileObject().getName().getBaseName());
                        rootFolder = fnode.getFileObject();
                        updateFileList();
                    }
                } catch (FileSystemException ex) {
                    throw new RuntimeException(ex);
                }

            }
        }
    });

    depthSpinner.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            recursiveDepth = ((Number) depthSpinner.getValue()).intValue();

            updateFileList();
        }
    });

    regexField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateFileList();
            System.out.println(Arrays.toString(explorer.getSelectedNodes().toArray()));
        }
    });

}

From source file:jchrest.gui.VisualSearchPane.java

private JPanel constructTrainingOptions() {
    _maxTrainingCycles = new JSpinner(new SpinnerNumberModel(5, 1, 1000, 1));
    _numFixations = new JSpinner(new SpinnerNumberModel(20, 1, 1000, 1));
    _maxNetworkSize = new JSpinner(new SpinnerNumberModel(100000, 1, 10000000, 1));

    JPanel panel = new JPanel();
    panel.setLayout(new SpringLayout());
    Utilities.addLabel(panel, "Domain of scenes:", _domainSelector);
    Utilities.addLabel(panel, "Number of scenes:", new JLabel("" + _scenes.size()));
    Utilities.addLabel(panel, "Maximum training cycles:", _maxTrainingCycles);
    Utilities.addLabel(panel, "Number of fixations per scene:", _numFixations);
    Utilities.addLabel(panel, "Maximum network size:", _maxNetworkSize);

    Utilities.makeCompactGrid(panel, 5, 2, 3, 3, 10, 5);
    panel.setMaximumSize(panel.getPreferredSize());

    JPanel ePanel = new JPanel();
    ePanel.setLayout(new GridLayout(1, 1));
    ePanel.add(panel);//from  ww w .  j  a va 2 s  . co m

    return ePanel;
}

From source file:biomine.bmvis2.pipeline.KMedoidsHighlight.java

@Override
public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) {
    Box ret = new Box(BoxLayout.X_AXIS);
    ret.add(new JLabel("k:"));

    final JSpinner spin = new JSpinner(new SpinnerNumberModel(3, 1, 1000, 1));

    spin.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            setK(((Number) spin.getValue()).intValue());
            v.settingsChanged(false);//from  www .  j  ava2 s. com
        }
    });
    ret.add(spin);

    final JCheckBox showClustersBox = new JCheckBox("Color clusters");
    ret.add(showClustersBox);
    showClustersBox.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent arg0) {
            showClusters = showClustersBox.isSelected();
            v.settingsChanged(false);
        }
    });
    return ret;
}

From source file:at.tuwien.ifs.somtoolbox.apps.viewer.controls.DendogramView.java

/**
 * @param t/*from  w ww.  j  a  v  a 2s.com*/
 * @param numClusters2
 */
public void update(ClusteringTree t, int numClusters) {

    frame.setVisible(true);

    frame.getContentPane().removeAll();
    try {
        // create spinner-panel
        clusterPanel = UiUtils.makeBorderedPanel(new FlowLayout(FlowLayout.LEFT, 10, 0), "Clusters");
        spinnerCluster = new JSpinner(new SpinnerNumberModel(1, 1, maxCluster, 1));
        spinnerCluster.setValue(numClusters);
        spinnerCluster.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                if (mMainSpinnerCluster != null) {
                    mMainSpinnerCluster.setValue(((JSpinner) e.getSource()).getValue());
                }
            }
        });
        UiUtils.fillPanel(clusterPanel, new JLabel("#"), spinnerCluster);
        frame.getContentPane().add(clusterPanel, BorderLayout.NORTH);
        // create graph
        VisualizationViewer g = generateGraph(t, numClusters);
        frame.getContentPane().add(g, BorderLayout.CENTER);
        frame.setSize(frame.getWidth() + 1, frame.getHeight() + 1);
        frame.setSize(frame.getWidth() - 1, frame.getHeight() - 1);

    } catch (Exception e) {
        e.printStackTrace();
    }

}

From source file:e3fraud.gui.MainWindow.java

public MainWindow() {
    super(new BorderLayout(5, 5));

    extended = false;//from  w w  w  . j a v a2 s  . co  m

    //Create the log first, because the action listeners
    //need to refer to it.
    log = new JTextArea(10, 50);
    log.setMargin(new Insets(5, 5, 5, 5));
    log.setEditable(false);
    logScrollPane = new JScrollPane(log);
    DefaultCaret caret = (DefaultCaret) log.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

    //        create the progress bar
    progressBar = new JProgressBar(0, 100);
    progressBar.setValue(progressBar.getMinimum());
    progressBar.setVisible(false);
    progressBar.setStringPainted(true);
    //Create the settings pane
    generationSettingLabel = new JLabel("Generate:");
    SpinnerModel collusionsSpinnerModel = new SpinnerNumberModel(1, 0, 3, 1);
    collusionSettingsPanel = new JPanel(new FlowLayout()) {
        @Override
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    // collusionSettingsPanel.setLayout(new BoxLayout(collusionSettingsPanel, BoxLayout.X_AXIS));
    collusionsButton = new JSpinner(collusionsSpinnerModel);
    collusionsLabel = new JLabel("collusion(s)");
    collusionSettingsPanel.add(collusionsButton);
    collusionSettingsPanel.add(collusionsLabel);

    rankingSettingLabel = new JLabel("Rank by:");
    lossButton = new JRadioButton("loss");
    lossButton.setToolTipText("Sort sub-ideal models based on loss for Target of Assessment (high -> low)");
    gainButton = new JRadioButton("gain");
    gainButton.setToolTipText(
            "Sort sub-ideal models based on gain of any actor except Target of Assessment (high -> low)");
    lossGainButton = new JRadioButton("loss + gain");
    lossGainButton.setToolTipText(
            "Sort sub-ideal models based on loss for Target of Assessment and, if equal, on gain of any actor except Target of Assessment");
    //gainLossButton = new JRadioButton("gain + loss");
    lossGainButton.setSelected(true);
    rankingGroup = new ButtonGroup();
    rankingGroup.add(lossButton);
    rankingGroup.add(gainButton);
    rankingGroup.add(lossGainButton);
    //rankingGroup.add(gainLossButton);
    groupingSettingLabel = new JLabel("Group by:");
    groupingButton = new JCheckBox("collusion");
    groupingButton.setToolTipText(
            "Groups sub-ideal models based on the pair of actors colluding before ranking them");
    groupingButton.setSelected(false);
    refreshButton = new JButton("Refresh");
    refreshButton.addActionListener(this);

    settingsPanel = new JPanel();
    settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS));
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(generationSettingLabel);
    collusionSettingsPanel.setAlignmentX(LEFT_ALIGNMENT);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(collusionSettingsPanel);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    rankingSettingLabel.setAlignmentY(TOP_ALIGNMENT);
    settingsPanel.add(rankingSettingLabel);
    settingsPanel.add(lossButton);
    settingsPanel.add(gainButton);
    settingsPanel.add(lossGainButton);
    //settingsPanel.add(gainLossButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(groupingSettingLabel);
    settingsPanel.add(groupingButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    settingsPanel.add(refreshButton);
    settingsPanel.add(Box.createRigidArea(new Dimension(0, 20)));
    progressBar.setPreferredSize(
            new Dimension(settingsPanel.getSize().width, progressBar.getPreferredSize().height));
    settingsPanel.add(progressBar);

    //Create the result tree
    root = new DefaultMutableTreeNode("No models to display");
    treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel);
    //tree.setUI(new CustomTreeUI());
    tree.setCellRenderer(new CustomTreeCellRenderer(tree));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setLargeModel(true);
    resultScrollPane = new JScrollPane(tree);
    tree.addTreeSelectionListener(treeSelectionListener);

    //tree.setShowsRootHandles(true);
    //Create a file chooser for saving
    sfc = new JFileChooser();
    FileFilter jpegFilter = new FileNameExtensionFilter("JPEG image", new String[] { "jpg", "jpeg" });
    sfc.addChoosableFileFilter(jpegFilter);
    sfc.setFileFilter(jpegFilter);

    //Create a file chooser for loading
    fc = new JFileChooser();
    FileFilter rdfFilter = new FileNameExtensionFilter("RDF file", "RDF");
    fc.addChoosableFileFilter(rdfFilter);
    fc.setFileFilter(rdfFilter);

    //Create the open button.  
    openButton = new JButton("Load model", createImageIcon("images/Open24.png"));
    openButton.addActionListener(this);
    openButton.setToolTipText("Load a e3value model");

    //Create the ideal graph button. 
    idealGraphButton = new JButton("Show ideal graph", createImageIcon("images/Plot.png"));
    idealGraphButton.setToolTipText("Display ideal profitability graph");
    idealGraphButton.addActionListener(this);

    Dimension thinButtonDimension = new Dimension(15, 420);

    //Create the expand subideal graph button. 
    expandButton = new JButton(">");
    expandButton.setPreferredSize(thinButtonDimension);
    expandButton.setMargin(new Insets(0, 0, 0, 0));
    expandButton.setToolTipText("Expand to show non-ideal profitability graph for selected model");
    expandButton.addActionListener(this);

    //Create the collapse sub-ideal graph button. 
    collapseButton = new JButton("<");
    collapseButton.setPreferredSize(thinButtonDimension);
    collapseButton.setMargin(new Insets(0, 0, 0, 0));
    collapseButton.setToolTipText("Collapse non-ideal profitability graph for selected model");
    collapseButton.addActionListener(this);

    //Create the generation button. 
    generateButton = new JButton("Generate sub-ideal models", createImageIcon("images/generate.png"));
    generateButton.addActionListener(this);
    generateButton.setToolTipText("Generate sub-ideal models for the e3value model currently loaded");

    //Create the chart panel
    chartPane = new JPanel();
    chartPane.setLayout(new FlowLayout(FlowLayout.LEFT));
    chartPane.add(expandButton);

    //For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(openButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(20, 0)));
    buttonPanel.add(generateButton);
    buttonPanel.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPanel.add(idealGraphButton);

    //Add the buttons, the ranking options, the result list and the log to this panel.
    add(buttonPanel, BorderLayout.PAGE_START);
    add(settingsPanel, BorderLayout.LINE_START);
    add(resultScrollPane, BorderLayout.CENTER);

    add(logScrollPane, BorderLayout.PAGE_END);
    add(chartPane, BorderLayout.LINE_END);
    //and make a nice border around it
    setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10));
}