Example usage for javax.swing JFormattedTextField JFormattedTextField

List of usage examples for javax.swing JFormattedTextField JFormattedTextField

Introduction

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

Prototype

public JFormattedTextField() 

Source Link

Document

Creates a JFormattedTextField with no AbstractFormatterFactory.

Usage

From source file:com.mgmtp.perfload.loadprofiles.ui.component.IntegerCellEditor.java

public IntegerCellEditor() {
    super(new JFormattedTextField());
    ((JTextField) getComponent()).setHorizontalAlignment(SwingConstants.RIGHT);
}

From source file:com.mycompany.listBoxer.panel.ListBoxerForm.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.ja v  a 2s .  c  o m*/
 * 
 * @throws ParseException
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
// <editor-fold defaultstate="collapsed"
// desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() throws ParseException {

    buttonGroup1 = new javax.swing.ButtonGroup();
    buttonGroup2 = new javax.swing.ButtonGroup();
    RangeComboBox = new javax.swing.JComboBox();
    jLabel1 = new javax.swing.JLabel();
    jTextField1 = new JFormattedTextField();
    AddButton = new javax.swing.JButton();
    AscendingRadioButton = new javax.swing.JRadioButton();
    DescendingRadioButton = new javax.swing.JRadioButton();
    jTextField2 = new JTextArea();
    ClearButton = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    RecordsLabel = new javax.swing.JLabel();
    TotalLabel = new javax.swing.JLabel();
    AlphabeticCheckBox = new javax.swing.JCheckBox();
    NumericCheckBox = new javax.swing.JCheckBox();
    CombinedCheckBox = new javax.swing.JCheckBox();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    MainMenu = new javax.swing.JMenuBar();
    FileMenuItem = new javax.swing.JMenu();
    OpenItem = new javax.swing.JMenuItem();
    SaveItem = new javax.swing.JMenuItem();
    ExitItem = new javax.swing.JMenuItem();
    EditMenuItem = new javax.swing.JMenu();
    UndoItem = new javax.swing.JMenuItem();
    jSeparator2 = new javax.swing.JPopupMenu.Separator();
    CutItem = new javax.swing.JMenuItem();
    CopyItem = new javax.swing.JMenuItem();
    PasteItem = new javax.swing.JMenuItem();
    HelpMenuItem = new javax.swing.JMenu();
    AboutItem = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    List<String> rangeList = RangeType.getStringValue();
    String[] arrays = new String[rangeList.size()];
    RangeComboBox.setModel(new javax.swing.DefaultComboBoxModel(rangeList.toArray(arrays)));
    RangeComboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            justDoIt();
        }

        private void justDoIt() {
            if (NumericCheckBox.isSelected()) {

            } else if (AlphabeticCheckBox.isSelected()) {

            } else {

            }
        }
    });

    jLabel1.setText("Range");

    jTextField1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField1ActionPerformed(evt);
        }
    });

    jTextField2.setEditable(Boolean.FALSE);

    AddButton.setText("Add to list");
    AddButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            AddButtonActionPerformed(evt);
        }
    });

    buttonGroup1.add(AscendingRadioButton);
    AscendingRadioButton.setText("Ascending");
    AscendingRadioButton.setBorder(javax.swing.BorderFactory.createTitledBorder("Sort Order"));
    AscendingRadioButton.setName("Sort Order"); // NOI18N

    buttonGroup1.add(DescendingRadioButton);
    DescendingRadioButton.setText("Descending");
    DescendingRadioButton.setBorder(javax.swing.BorderFactory.createTitledBorder("Sort Order"));
    DescendingRadioButton.setName("Sort Order"); // NOI18N

    ClearButton.setText("Clear list");
    ClearButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            ClearButtonActionPerformed(event);
        }
    });

    jLabel2.setText("Records in list : ");

    jLabel3.setText("Total records : ");

    RecordsLabel.setText("0");

    TotalLabel.setText("0");

    buttonGroup2.add(AlphabeticCheckBox);
    AlphabeticCheckBox.setText("Alphabetic");
    AlphabeticCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            AlphabeticCheckBoxActionPerformed(evt);
        }
    });

    buttonGroup2.add(NumericCheckBox);
    NumericCheckBox.setText("Numeric");
    NumericCheckBox.addActionListener(new ActionListener() {

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

    buttonGroup2.add(CombinedCheckBox);
    CombinedCheckBox.setText("Combined");
    CombinedCheckBox.addActionListener(new ActionListener() {

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

    jLabel6.setText("Symbols :");

    jLabel7.setText("Sort order :");

    MainMenu.setName(""); // NOI18N
    MainMenu.setRequestFocusEnabled(false);

    FileMenuItem.setText("File");

    OpenItem.setText("Open");
    FileMenuItem.add(OpenItem);

    SaveItem.setText("Save as");
    FileMenuItem.add(SaveItem);

    ExitItem.setText("Exit");
    FileMenuItem.add(ExitItem);

    MainMenu.add(FileMenuItem);

    EditMenuItem.setText("Edit");

    UndoItem.setText("Undo");
    EditMenuItem.add(UndoItem);
    EditMenuItem.add(jSeparator2);

    CutItem.setText("Cut");
    EditMenuItem.add(CutItem);

    CopyItem.setText("Copy");
    EditMenuItem.add(CopyItem);

    PasteItem.setText("Paste");
    EditMenuItem.add(PasteItem);

    MainMenu.add(EditMenuItem);

    HelpMenuItem.setText("Help");

    AboutItem.setText("About ListBoxer");
    HelpMenuItem.add(AboutItem);

    MainMenu.add(HelpMenuItem);

    setJMenuBar(MainMenu);
    MainMenu.getAccessibleContext().setAccessibleName("");

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup().addComponent(jLabel1).addGap(22, 22, 22)
                                    .addComponent(RangeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(AlphabeticCheckBox).addComponent(NumericCheckBox)
                            .addComponent(CombinedCheckBox).addComponent(jLabel6).addComponent(jLabel7)))
                    .addComponent(AscendingRadioButton).addComponent(DescendingRadioButton,
                            javax.swing.GroupLayout.PREFERRED_SIZE, 136,
                            javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 198,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 198,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(44, 44, 44)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                            javax.swing.GroupLayout.Alignment.TRAILING,
                            layout.createSequentialGroup().addGroup(layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(layout.createSequentialGroup().addComponent(jLabel3).addGap(0, 53,
                                            Short.MAX_VALUE))
                                    .addGroup(layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                                    false)
                                            .addComponent(AddButton, javax.swing.GroupLayout.DEFAULT_SIZE, 101,
                                                    Short.MAX_VALUE)
                                            .addComponent(ClearButton, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                                    .addGap(21, 21, 21))
                            .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(TotalLabel)
                                            .addGroup(layout.createSequentialGroup().addComponent(jLabel2)
                                                    .addGap(18, 18, 18).addComponent(RecordsLabel)))
                                    .addContainerGap(26, Short.MAX_VALUE)))));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addGap(19, 19, 19).addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(RangeComboBox, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 31,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(AddButton, javax.swing.GroupLayout.PREFERRED_SIZE, 31,
                            javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(32, 32, 32)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(ClearButton, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addGroup(layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jLabel2).addComponent(RecordsLabel))
                                    .addGap(18, 18, 18)
                                    .addGroup(layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jLabel3).addComponent(TotalLabel))
                                    .addGap(38, 38, 38))
                            .addGroup(layout.createSequentialGroup().addGroup(layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup().addGap(17, 17, 17)
                                            .addComponent(jLabel7).addGap(1, 1, 1)
                                            .addComponent(AscendingRadioButton,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 23,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(DescendingRadioButton,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(69, 69, 69).addComponent(jLabel6)
                                            .addPreferredGap(
                                                    javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(AlphabeticCheckBox)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(NumericCheckBox)
                                            .addPreferredGap(
                                                    javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(CombinedCheckBox)))
                                    .addGap(0, 22, Short.MAX_VALUE)))));

    pack();
}

From source file:components.IntegerEditor.java

public IntegerEditor(int min, int max) {
    super(new JFormattedTextField());
    ftf = (JFormattedTextField) getComponent();
    minimum = new Integer(min);
    maximum = new Integer(max);

    //Set up the editor for the integer cells.
    integerFormat = NumberFormat.getIntegerInstance();
    NumberFormatter intFormatter = new NumberFormatter(integerFormat);
    intFormatter.setFormat(integerFormat);
    intFormatter.setMinimum(minimum);/*from w w  w .j  a va2 s. c om*/
    intFormatter.setMaximum(maximum);

    ftf.setFormatterFactory(new DefaultFormatterFactory(intFormatter));
    ftf.setValue(minimum);
    ftf.setHorizontalAlignment(JTextField.TRAILING);
    ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);

    //React when the user presses Enter while the editor is
    //active.  (Tab is handled as specified by
    //JFormattedTextField's focusLostBehavior property.)
    ftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
    ftf.getActionMap().put("check", new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (!ftf.isEditValid()) { //The text is invalid.
                if (userSaysRevert()) { //reverted
                    ftf.postActionEvent(); //inform the editor
                }
            } else
                try { //The text is valid,
                    ftf.commitEdit(); //so use it.
                    ftf.postActionEvent(); //stop editing
                } catch (java.text.ParseException exc) {
                }
        }
    });
}

From source file:br.com.itfox.utils.Utils.java

public static String formatCpfCnpj(String value) {
    String maskCpf = "###.###.###-##";
    String maskCnpj = "##.###.###/####-##";
    String maskCep = "##.###-###";
    String mask = "";
    if (value == null) {
        return "";
    }//from w ww  .j a  va2s  .  c  om
    if (value.length() == 14) {
        mask = maskCnpj;
    } else if (value.length() == 11) {
        mask = maskCpf;
    } else if (value.length() == 8) {
        mask = maskCep;
    }
    try {
        MaskFormatter formatter = new MaskFormatter(mask);
        JFormattedTextField textField = new JFormattedTextField();
        formatter.install(textField);
        textField.setText(value);
        value = textField.getText();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return value;
}

From source file:br.com.itfox.utils.Utils.java

public static String formatTelephone(String value) {
    String maskTel = "####-####";
    String maskCel = "#####-####";
    String maskDDD = "(##) ";
    String mask = "";
    if (value == null) {
        return "";
    }/*from  w  ww.  j  a  v a  2s  . c  o m*/
    if (value.length() == 9) {
        mask = maskCel;
    } else if (value.length() == 8) {
        mask = maskTel;
    } else if (value.length() == 2) {
        mask = maskDDD;
    }

    try {
        MaskFormatter formatter = new MaskFormatter(mask);
        JFormattedTextField textField = new JFormattedTextField();
        formatter.install(textField);
        textField.setText(value);
        value = textField.getText();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return value;
}

From source file:gda.gui.beans.BeanBase.java

protected JTextField getTxtValue() {
    if (txtValue == null) {
        txtValue = new JFormattedTextField();
        // When the text box loses focus, keep the edited value. This will be reverted eventually by the
        // main update loop
        //TODO this will cause the text to revert from 1700 to 1,700 . We need to set the formatter to simple or do not use this box at all.
        //Currently we handle the comma in the txtValueActionPerformed
        txtValue.setFocusLostBehavior(JFormattedTextField.PERSIST);

        txtValue.setValue(new Double(100));
        txtValue.setText("position");
        txtValue.setHorizontalAlignment(SwingConstants.RIGHT);
        txtValue.setPreferredSize(new java.awt.Dimension(60, 19));
        txtValue.setMinimumSize(new java.awt.Dimension(60, 19));
        txtValue.addActionListener(new ActionListener() {
            @Override/*w  ww  .  jav  a2s . c  om*/
            public void actionPerformed(ActionEvent evt) {

                // Remove focus from the text field, so it updates as the motor moves
                requestFocus();

                // do this in a new thread that's not the event thread.
                uk.ac.gda.util.ThreadManager.getThread(new Runnable() {
                    @Override
                    public void run() {
                        manualUpdate = true;
                        txtValueActionPerformed();
                    }
                }).start();
            }
        });
    }
    return txtValue;
}

From source file:eu.crisis_economics.abm.dashboard.Page_Parameters.java

private Container initContainer() {
    JPanel containerPanel = new JPanel(new CardLayout());
    JLabel loadingModelLabel = new JLabel("Loading model...");
    loadingModelLabel.setHorizontalAlignment(SwingConstants.CENTER);
    containerPanel.add(loadingModelLabel, LOADING_MODEL_ID);
    tabbedPane = new JTabbedPane();
    containerPanel.add(tabbedPane, PARAMETERS_PANEL_ID);

    // create two number of turns field
    numberOfTurnsField = new JFormattedTextField();
    numberOfTurnsField.setFocusLostBehavior(JFormattedTextField.COMMIT);
    numberOfTurnsField.setInputVerifier(new InputVerifier() {

        @Override//from w w w.jav  a2  s  .  c o m
        public boolean verify(final JComponent input) {
            if (!checkNumberOfTurnsField(true)) {
                final PopupFactory popupFactory = PopupFactory.getSharedInstance();
                final Point locationOnScreen = numberOfTurnsField.getLocationOnScreen();
                final JLabel message = new JLabel("Please specify a (possibly floating point) number!");
                message.setBorder(new LineBorder(Color.RED, 2, true));
                if (errorPopup != null)
                    errorPopup.hide();
                errorPopup = popupFactory.getPopup(numberOfTurnsField, message, locationOnScreen.x - 10,
                        locationOnScreen.y - 30);

                errorPopup.show();

                return false;
            } else {
                if (errorPopup != null) {
                    errorPopup.hide();
                    errorPopup = null;
                }
                return true;
            }
        }
    });
    numberOfTurnsField.setText(String.valueOf(Dashboard.NUMBER_OF_TURNS));
    numberOfTurnsField
            .setToolTipText("The turn when the simulation should stop specified as an integer value.");
    numberOfTurnsField.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            wizard.clickDefaultButton();
        }
    });

    numberOfTurnsFieldPSW = new JFormattedTextField();
    numberOfTurnsFieldPSW.setFocusLostBehavior(JFormattedTextField.COMMIT);
    numberOfTurnsFieldPSW.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(final JComponent input) {
            if (!checkNumberOfTurnsField(false)) {
                final PopupFactory popupFactory = PopupFactory.getSharedInstance();
                final Point locationOnScreen = numberOfTurnsFieldPSW.getLocationOnScreen();
                final JLabel message = new JLabel("Please specify a (possibly floating point) number!");
                message.setBorder(new LineBorder(Color.RED, 2, true));
                if (errorPopup != null)
                    errorPopup.hide();
                errorPopup = popupFactory.getPopup(numberOfTurnsFieldPSW, message, locationOnScreen.x - 10,
                        locationOnScreen.y - 30);

                errorPopup.show();

                return false;
            } else {
                if (errorPopup != null) {
                    errorPopup.hide();
                    errorPopup = null;
                }
                return true;
            }
        }
    });
    numberOfTurnsFieldPSW.setText(String.valueOf(Dashboard.NUMBER_OF_TURNS));
    numberOfTurnsFieldPSW
            .setToolTipText("The turn when the simulation should stop specified as an integer value.");
    numberOfTurnsFieldPSW.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            wizard.clickDefaultButton();
        }
    });

    // create two number of time-steps to ignore field
    numberTimestepsIgnored = new JFormattedTextField();
    numberTimestepsIgnored.setFocusLostBehavior(JFormattedTextField.COMMIT);
    numberTimestepsIgnored.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(final JComponent input) {
            if (!checkNumberTimestepsIgnored(true)) {
                final PopupFactory popupFactory = PopupFactory.getSharedInstance();
                final Point locationOnScreen = numberTimestepsIgnored.getLocationOnScreen();
                final JLabel message = new JLabel("Please specify an integer number!");
                message.setBorder(new LineBorder(Color.RED, 2, true));
                if (errorPopup != null)
                    errorPopup.hide();
                errorPopup = popupFactory.getPopup(numberTimestepsIgnored, message, locationOnScreen.x - 10,
                        locationOnScreen.y - 30);

                errorPopup.show();

                return false;
            } else {
                if (errorPopup != null) {
                    errorPopup.hide();
                    errorPopup = null;
                }
                return true;
            }
        }
    });
    numberTimestepsIgnored.setText(String.valueOf(Dashboard.NUMBER_OF_TIMESTEPS_TO_IGNORE));
    numberTimestepsIgnored.setToolTipText(
            "The turn when the simulation should start charting specified as an integer value.");
    numberTimestepsIgnored.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            wizard.clickDefaultButton();
        }
    });

    numberTimestepsIgnoredPSW = new JFormattedTextField();
    numberTimestepsIgnoredPSW.setFocusLostBehavior(JFormattedTextField.COMMIT);
    numberTimestepsIgnoredPSW.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(final JComponent input) {
            if (!checkNumberTimestepsIgnored(false)) {
                final PopupFactory popupFactory = PopupFactory.getSharedInstance();
                final Point locationOnScreen = numberTimestepsIgnoredPSW.getLocationOnScreen();
                final JLabel message = new JLabel("Please specify an integer number!");
                message.setBorder(new LineBorder(Color.RED, 2, true));
                if (errorPopup != null)
                    errorPopup.hide();
                errorPopup = popupFactory.getPopup(numberTimestepsIgnoredPSW, message, locationOnScreen.x - 10,
                        locationOnScreen.y - 30);

                errorPopup.show();

                return false;
            } else {
                if (errorPopup != null) {
                    errorPopup.hide();
                    errorPopup = null;
                }
                return true;
            }
        }
    });
    numberTimestepsIgnoredPSW.setText(String.valueOf(Dashboard.NUMBER_OF_TIMESTEPS_TO_IGNORE));
    numberTimestepsIgnoredPSW.setToolTipText(
            "The turn when the simulation should start charting specified as an integer value.");
    numberTimestepsIgnoredPSW.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(final ActionEvent e) {
            wizard.clickDefaultButton();
        }
    });

    onLineChartsCheckBox = new JCheckBox();
    //      onLineChartsCheckBoxPSW = new JCheckBox();
    advancedChartsCheckBox = new JCheckBox();
    advancedChartsCheckBox.setSelected(true);

    // create the scroll pane for the simple parameter setting page
    JLabel label = null;
    label = new JLabel(new ImageIcon(new ImageIcon(getClass().getResource(DECORATION_IMAGE)).getImage()
            .getScaledInstance(DECORATION_IMAGE_WIDTH, -1, Image.SCALE_SMOOTH)));
    Style.registerCssClasses(label, Dashboard.CSS_CLASS_COMMON_PANEL);
    parametersScrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    parametersScrollPane.setBorder(null);
    parametersScrollPane.setViewportBorder(null);

    breadcrumb = new Breadcrumb();
    Style.registerCssClasses(breadcrumb, CSS_ID_BREADCRUMB);

    singleRunParametersPanel = new ScrollableJPanel(new SizeProvider() {

        @Override
        public int getHeight() {
            Component component = tabbedPane.getSelectedComponent();
            if (component == null) {
                return 0;
            }
            JScrollBar scrollBar = parametersScrollPane.getHorizontalScrollBar();
            return component.getSize().height - breadcrumb.getHeight()
                    - (scrollBar.isVisible() ? scrollBar.getPreferredSize().height : 0);
        }

        @Override
        public int getWidth() {
            final int hScrollBarWidth = parametersScrollPane.getHorizontalScrollBar().getPreferredSize().width;
            final int width = dashboard.getSize().width - Page_Parameters.DECORATION_IMAGE_WIDTH
                    - hScrollBarWidth;
            return width;
        }
    });
    BoxLayout boxLayout = new BoxLayout(singleRunParametersPanel, BoxLayout.X_AXIS);
    singleRunParametersPanel.setLayout(boxLayout);
    parametersScrollPane.setViewportView(singleRunParametersPanel);

    JPanel breadcrumbPanel = new JPanel(new BorderLayout());
    breadcrumbPanel.add(breadcrumb, BorderLayout.NORTH);
    breadcrumbPanel.add(parametersScrollPane, BorderLayout.CENTER);

    final JPanel simpleForm = FormsUtils.build("p ~ p:g", "01 t:p", label, breadcrumbPanel).getPanel();
    Style.registerCssClasses(simpleForm, Dashboard.CSS_CLASS_COMMON_PANEL);

    tabbedPane.add("Single run", simpleForm);

    // create the form for the parameter sweep setting page
    tabbedPane.add("Parameter sweep", createParamsweepGUI());

    gaSearchHandler = new GASearchHandler(currentModelHandler);
    gaSearchPanel = new GASearchPanel(gaSearchHandler, this);
    tabbedPane.add("Genetic Algorithm Search", gaSearchPanel);

    return containerPanel;
}

From source file:org.jcurl.demo.tactics.TacticsApp.java

public TacticsApp() {
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            TacticsApp.this.cmdExit();
        }/*from  www  .ja v  a  2  s .com*/
    });
    master = new RockEditDisplay();
    master.setPos(mod_locations);
    master.setSpeed(mod_speeds);
    final PositionDisplay pnl2 = new PositionDisplay();
    pnl2.setPos(mod_locations);
    pnl2.setZoom(Zoomer.HOG2HACK);

    final Container con = getContentPane();
    {
        final JPanel p = new JPanel(new BorderLayout());
        p.add(new SumWaitDisplay(mod_locations), "West");
        p.add(master, "Center");
        p.add(new SumShotDisplay(mod_locations), "East");
        con.add(p, "Center");
    }
    // con.add(new SumWaitDisplay(mod_locations), "West");
    con.add(new SumOutDisplay(mod_locations), "West");
    {
        final Box b1 = Box.createHorizontalBox();
        b1.add(Box.createRigidArea(new Dimension(0, 75)));
        b1.add(pnl2);
        con.add(b1, "South");
    }
    final JTabbedPane t = new JTabbedPane();
    con.add(t, "East");
    {
        final Box b0 = Box.createHorizontalBox();
        t.add("Rock", b0);
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            final Box b2 = Box.createVerticalBox();
            b2.add(new JComboBox(new String[] { "Dark", "Light" }));
            b2.add(new JLabel("Broom", SwingConstants.LEFT));
            b1.add(b2, "North");
            JSlider s = new JSlider(-2000, 2000, 0);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(1000);
            s.setMinorTickSpacing(100);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final Box b3 = Box.createHorizontalBox();
            b3.add(new JFormattedTextField());
            b3.add(new JLabel("mm", SwingConstants.LEFT));
            b1.add(b3, "South");
            b0.add(b1);
        }
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            final Box b2 = Box.createVerticalBox();
            b2.add(new JComboBox(new String[] { "1", "2", "3", "4", "5", "6", "7", "8" }));
            b2.add(new JLabel("Splittime", SwingConstants.LEFT));
            b1.add(b2, "North");
            JSlider s = new JSlider(500, 2500, 1500);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(1000);
            s.setMinorTickSpacing(100);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final Box b3 = Box.createHorizontalBox();
            b3.add(new JSpinner());
            b3.add(new JLabel("ms", SwingConstants.LEFT));
            b1.add(b3, "South");
            b0.add(b1);
        }
    }
    {
        final Box b0 = Box.createHorizontalBox();
        t.add("Ice", b0);
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            b1.add(new JLabel("Curl"), "North");
            JSlider s = new JSlider(0, 5000, 0);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(1000);
            s.setMinorTickSpacing(100);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final JSpinner s1 = new JSpinner();
            b1.add(s1, "South");
            b0.add(b1);
        }
        {
            final JPanel b1 = new JPanel(new BorderLayout());
            b1.add(new JLabel("DrawToTee"), "North");
            JSlider s = new JSlider(15000, 30000, 25000);
            s.setOrientation(SwingConstants.VERTICAL);
            s.setMajorTickSpacing(5000);
            s.setMinorTickSpacing(1000);
            s.setPaintLabels(true);
            s.setPaintTicks(true);
            b1.add(s, "Center");

            final JSpinner s1 = new JSpinner();
            b1.add(s1, "South");
            b0.add(b1);
        }
    }
    setJMenuBar(createMenu());
    refreshTitle();
    this.setSize(900, 400);

    new SpeedController(mod_locations, mod_speeds, master);
    new LocationController(mod_locations, pnl2);
    lastSaved = mod_locations.getLastChanged();
}

From source file:org.pentaho.reporting.libraries.designtime.swing.date.DateCellEditor.java

/**
 * Constructs a new <code>DatePickerParameterComponent</code>.
 *///  w ww.j  a va  2s.c  om
public DateCellEditor(final Class dateType) {
    this.listeners = new EventListenerList();
    this.dateType = dateType;
    if (this.dateType.isArray()) {
        this.dateType = this.dateType.getComponentType();
    }

    setLayout(new BorderLayout());
    dateField = new JFormattedTextField();
    dateField.setColumns(20);
    dateField.setEditable(true);

    pickDateButton = new EllipsisButton(new PickDateListener());

    add(dateField, BorderLayout.CENTER);
    add(pickDateButton, BorderLayout.EAST);
}

From source file:org.zaproxy.zap.extension.viewstate.HttpPanelViewStateView.java

private JPanel getContainerPanel() {
    if (container == null) {
        container = new JPanel();
        container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));
        JScrollPane cScroll = new JScrollPane();
        cScroll.setName(CAPTION_NAME);//  ww w .  java 2  s. c  om
        cScroll.setViewportView(getHexTableBody());
        // Outer scroll size constraints
        container.setPreferredSize(new Dimension(0, 100));
        // Setup text field for ViewState info
        vsInfoTxt = new JFormattedTextField();
        vsInfoTxt.setEditable(false);
        vsInfoTxt.setBackground(Color.decode("#D6D9DF"));
        vsInfoTxt.setFont(FontUtils.getFont("Courier", Font.BOLD));
        // Add to container
        container.add(cScroll);
        container.add(vsInfoTxt);
    }
    return container;
}