Example usage for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED

List of usage examples for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED

Introduction

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

Prototype

int VERTICAL_SCROLLBAR_AS_NEEDED

To view the source code for javax.swing ScrollPaneConstants VERTICAL_SCROLLBAR_AS_NEEDED.

Click Source Link

Document

Used to set the vertical scroll bar policy so that vertical scrollbars are displayed only when needed.

Usage

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

private void initGUI() {
    try {//w w  w . j av  a 2  s  .  c  om
        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.pms.newgui.LooksFrame.java

/**
 * Constructs a <code>DemoFrame</code>, configures the UI,
 * and builds the content.//from w ww  .  jav  a2  s. co m
 */
public LooksFrame(AutoUpdater autoUpdater, @Nonnull PmsConfiguration configuration,
        @Nonnull WindowPropertiesConfiguration windowConfiguration) {
    super(windowConfiguration.getGraphicsConfiguration());
    if (configuration == null) {
        throw new IllegalArgumentException("configuration can't be null");
    }
    setResizable(true);
    windowProperties = new WindowProperties(this, STANDARD_SIZE, MINIMUM_SIZE, windowConfiguration);
    this.autoUpdater = autoUpdater;
    this.configuration = configuration;
    assert this.configuration != null;
    setMinimumSize(MINIMUM_SIZE);
    Options.setDefaultIconSize(new Dimension(18, 18));
    Options.setUseNarrowButtons(true);

    // Set view level, can be omitted if ViewLevel is implemented in configuration
    // by setting the view level as variable initialization
    if (configuration.isHideAdvancedOptions()) {
        viewLevel = ViewLevel.NORMAL;
    } else {
        viewLevel = ViewLevel.ADVANCED;
    }

    // Global options
    Options.setTabIconsEnabled(true);
    UIManager.put(Options.POPUP_DROP_SHADOW_ENABLED_KEY, null);

    // Swing Settings
    initializeLookAndFeel();

    // wait till the look and feel has been initialized before (possibly) displaying the update notification dialog
    if (autoUpdater != null) {
        autoUpdater.addObserver(this);
        autoUpdater.pollServer();
    }

    // Shared Fonts
    final Integer twelve = Integer.valueOf(12);
    final Integer fontPlain = Integer.valueOf(Font.PLAIN);
    final Integer fontBold = Integer.valueOf(Font.BOLD);

    LazyValue dialogPlain12 = new LazyValue() {
        @Override
        public Object createValue(UIDefaults t) {
            return new FontUIResource(Font.DIALOG, fontPlain, twelve);
        }
    };

    LazyValue sansSerifPlain12 = new LazyValue() {
        @Override
        public Object createValue(UIDefaults t) {
            return new FontUIResource(Font.SANS_SERIF, fontPlain, twelve);
        }
    };

    LazyValue monospacedPlain12 = new LazyValue() {
        @Override
        public Object createValue(UIDefaults t) {
            return new FontUIResource(Font.MONOSPACED, fontPlain, twelve);
        }
    };

    LazyValue dialogBold12 = new LazyValue() {
        @Override
        public Object createValue(UIDefaults t) {
            return new FontUIResource(Font.DIALOG, fontBold, twelve);
        }
    };

    Object MenuFont = dialogPlain12;
    Object FixedControlFont = monospacedPlain12;
    Object ControlFont = dialogPlain12;
    Object MessageFont = dialogPlain12;
    Object WindowFont = dialogBold12;
    Object ToolTipFont = sansSerifPlain12;
    Object IconFont = ControlFont;

    // Override our fonts with a unicode font for languages with special characters
    final String language = configuration.getLanguageTag();
    if (language != null && (language.equals("ja") || language.startsWith("zh") || language.equals("ko"))) {
        // http://propedit.sourceforge.jp/propertieseditor.jnlp
        MenuFont = sansSerifPlain12;
        FixedControlFont = sansSerifPlain12;
        ControlFont = sansSerifPlain12;
        MessageFont = sansSerifPlain12;
        WindowFont = sansSerifPlain12;
        IconFont = sansSerifPlain12;
    }

    UIManager.put("Button.font", ControlFont);
    UIManager.put("CheckBox.font", ControlFont);
    UIManager.put("CheckBoxMenuItem.font", MenuFont);
    UIManager.put("ComboBox.font", ControlFont);
    UIManager.put("EditorPane.font", ControlFont);
    UIManager.put("FileChooser.listFont", IconFont);
    UIManager.put("FormattedTextField.font", ControlFont);
    UIManager.put("InternalFrame.titleFont", WindowFont);
    UIManager.put("Label.font", ControlFont);
    UIManager.put("List.font", ControlFont);
    UIManager.put("PopupMenu.font", MenuFont);
    UIManager.put("Menu.font", MenuFont);
    UIManager.put("MenuBar.font", MenuFont);
    UIManager.put("MenuItem.font", MenuFont);
    UIManager.put("MenuItem.acceleratorFont", MenuFont);
    UIManager.put("RadioButton.font", ControlFont);
    UIManager.put("RadioButtonMenuItem.font", MenuFont);
    UIManager.put("OptionPane.font", MessageFont);
    UIManager.put("OptionPane.messageFont", MessageFont);
    UIManager.put("OptionPane.buttonFont", MessageFont);
    UIManager.put("Panel.font", ControlFont);
    UIManager.put("PasswordField.font", ControlFont);
    UIManager.put("ProgressBar.font", ControlFont);
    UIManager.put("ScrollPane.font", ControlFont);
    UIManager.put("Slider.font", ControlFont);
    UIManager.put("Spinner.font", ControlFont);
    UIManager.put("TabbedPane.font", ControlFont);
    UIManager.put("Table.font", ControlFont);
    UIManager.put("TableHeader.font", ControlFont);
    UIManager.put("TextArea.font", FixedControlFont);
    UIManager.put("TextField.font", ControlFont);
    UIManager.put("TextPane.font", ControlFont);
    UIManager.put("TitledBorder.font", ControlFont);
    UIManager.put("ToggleButton.font", ControlFont);
    UIManager.put("ToolBar.font", MenuFont);
    UIManager.put("ToolTip.font", ToolTipFont);
    UIManager.put("Tree.font", ControlFont);
    UIManager.put("Viewport.font", ControlFont);

    setTitle("Test");
    setIconImage(readImageIcon("icon-32.png").getImage());

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JComponent jp = buildContent();
    String showScrollbars = System.getProperty("scrollbars", "").toLowerCase();

    /**
     * Handle scrollbars:
     *
     * 1) forced scrollbars (-Dscrollbars=true): always display them
     * 2) optional scrollbars (-Dscrollbars=optional): display them as needed
     * 3) otherwise (default): don't display them
     */
    switch (showScrollbars) {
    case "true":
        setContentPane(new JScrollPane(jp, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS));
        break;
    case "optional":
        setContentPane(new JScrollPane(jp, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED));
        break;
    default:
        setContentPane(jp);
        break;
    }

    String projectName = PropertiesUtil.getProjectProperties().get("project.name");
    String projectVersion = PropertiesUtil.getProjectProperties().get("project.version");
    String title = projectName + " " + projectVersion;

    // If the version contains a "-" (e.g. "1.50.1-SNAPSHOT" or "1.50.1-beta1"), add a warning message
    if (projectVersion.indexOf('-') > -1) {
        title = title + " - " + Messages.getString("LooksFrame.26");
    }

    if (PMS.getTraceMode() == 2) {
        // Forced trace mode
        title = title + "  [" + Messages.getString("TracesTab.10").toUpperCase() + "]";
    }

    setTitle(title);
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);

    // Display tooltips immediately and for a long time
    ToolTipManager.sharedInstance().setInitialDelay(400);
    ToolTipManager.sharedInstance().setDismissDelay(60000);
    ToolTipManager.sharedInstance().setReshowDelay(400);

    if (!configuration.isMinimized() && System.getProperty(START_SERVICE) == null) {
        setVisible(true);
    }
    BasicSystemUtils.INSTANCE.addSystemTray(this);
}

From source file:edu.ku.brc.specify.ui.AppBase.java

/**
 * Creates a ScrollPane with the text from the log file.
 * @param logFile the file/*from www  . j av  a  2  s . c o  m*/
 * @param doError indicates it should display the error log
 * @return the ScrollPane.
 */
protected static JScrollPane getLogFilePanel(final File logFile, final boolean doError) {
    JTextArea textArea = new JTextArea();
    if (logFile.exists()) {
        try {
            textArea.setText(FileUtils.readFileToString(logFile));

        } catch (Exception ex) {
        } // no catch on purpose

    } else {
        textArea.setText(
                doError ? getResourceString("Specify.LOG_NO_ERRORS") : getResourceString("Specify.LOG_EMPTY")); //$NON-NLS-1$ //$NON-NLS-2$
    }
    textArea.setEditable(false);

    return new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}

From source file:es.ubu.XRayDetector.interfaz.PanelAplicacion.java

/**
 * Gets the application log./*w ww.j  a va2  s. com*/
 * 
 * @param panelLog The panel of the log.
 * @return The application log.
 */
private JTextPane getTxtLog(JPanel panelLog) {
    JTextPane textPaneLog = new JTextPane();
    textPaneLog.setBounds(4, 4, 209, 195);
    textPaneLog.setEditable(false);
    panelLog.add(textPaneLog);
    textPaneLog.setContentType("text/html");
    kit = new HTMLEditorKit();
    doc = new HTMLDocument();
    panelLog_1.setLayout(null);
    textPaneLog.setEditorKit(kit);
    textPaneLog.setDocument(doc);

    textPaneLog.setText("<!DOCTYPE html>" + "<html>" + "<head>" + "<style>" + "p.normal {font-weight:normal;}"
            + "p.error {font-weight:bold; color:red}" + "p.exito {font-weight:bold; color:green}"
            + "p.stop {font-weight:bold; color:blue}" + "</style>" + "</head>" + "<body>");
    JScrollPane scroll = new JScrollPane(textPaneLog);
    scroll.setBounds(10, 16, 242, 254);
    scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    panelLog.add(scroll);
    return textPaneLog;
}

From source file:com.rapidminer.gui.properties.OperatorPropertyPanel.java

@Override
public Component getComponent() {
    if (dockableComponent == null) {
        JScrollPane scrollPane = new ExtendedJScrollPane(this);
        scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
        scrollPane.setBorder(null);/*ww  w  .j a  v a  2  s  .  c  o m*/

        dockableComponent = new JPanel(new BorderLayout());

        JPanel toolBarPanel = new JPanel(new BorderLayout());
        ViewToolBar toolBar = new ViewToolBar();
        JToggleButton toggleExpertModeButton = mainFrame.TOGGLE_EXPERT_MODE_ACTION.createToggleButton();
        toggleExpertModeButton.setText(null);
        toolBar.add(toggleExpertModeButton);

        showHelpAction.setSelected(isShowParameterHelp());
        JToggleButton helpToggleButton = showHelpAction.createToggleButton();
        helpToggleButton.setText(null);
        toolBar.add(helpToggleButton);

        Action infoOperatorAction = new InfoOperatorAction() {

            private static final long serialVersionUID = 6758272768665592429L;

            @Override
            protected Operator getOperator() {
                return mainFrame.getFirstSelectedOperator();
            }
        };
        toolBar.add(infoOperatorAction);
        JToggleButton enableOperatorButton = new ToggleActivationItem(mainFrame.getActions())
                .createToggleButton();
        enableOperatorButton.setText(null);
        toolBar.add(enableOperatorButton);
        Action renameOperatorAction = new ResourceAction(true, "rename_in_processrenderer") {

            {
                setCondition(OPERATOR_SELECTED, MANDATORY);
            }

            private static final long serialVersionUID = -3104160320178045540L;

            @Override
            public void actionPerformed(ActionEvent e) {
                Operator operator = mainFrame.getFirstSelectedOperator();
                String name = SwingTools.showInputDialog("rename_operator", operator.getName());
                if (name != null && name.length() > 0) {
                    operator.rename(name);
                }
            }
        };
        toolBar.add(renameOperatorAction);
        toolBar.add(new DeleteOperatorAction());
        breakpointButton.addToToolBar(toolBar);

        // toolBar.add(mainFrame.getActions().MAKE_DIRTY_ACTION);
        toolBarPanel.add(toolBar, BorderLayout.NORTH);

        JPanel headerPanel = new JPanel();
        headerPanel.setBackground(SwingTools.LIGHTEST_BLUE);
        headerPanel.add(headerLabel);
        headerPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, Color.LIGHT_GRAY));
        toolBarPanel.add(headerPanel, BorderLayout.SOUTH);

        dockableComponent.add(toolBarPanel, BorderLayout.NORTH);
        dockableComponent.add(scrollPane, BorderLayout.CENTER);

        // compatibility level and warnings
        JPanel southPanel = new JPanel(new BorderLayout());
        southPanel.add(expertModeHintLabel, BorderLayout.CENTER);
        compatibilityLabel.setLabelFor(compatibilityLevelSpinner);
        compatibilityLevelSpinner.setPreferredSize(
                new Dimension(80, (int) compatibilityLevelSpinner.getPreferredSize().getHeight()));
        compatibilityPanel.add(compatibilityLabel);
        compatibilityPanel.add(compatibilityLevelSpinner);
        southPanel.add(compatibilityPanel, BorderLayout.SOUTH);

        dockableComponent.add(southPanel, BorderLayout.SOUTH);
    }
    return dockableComponent;
}

From source file:net.sf.jabref.gui.entryeditor.EntryEditor.java

private void setupSourcePanel() {
    source = new JTextAreaWithHighlighting();
    panel.getSearchBar().getSearchQueryHighlightObservable()
            .addSearchListener((SearchQueryHighlightListener) source);

    source.setEditable(true);//w  w  w .  j a  v a  2 s .  c om
    source.setLineWrap(true);
    source.setTabSize(Globals.prefs.getInt(JabRefPreferences.INDENT));
    source.addFocusListener(new FieldEditorFocusListener());
    // Add the global focus listener, so a menu item can see if this field was focused when an action was called.
    source.addFocusListener(Globals.getFocusListener());
    source.setFont(new Font("Monospaced", Font.PLAIN, Globals.prefs.getInt(JabRefPreferences.FONT_SIZE)));
    setupJTextComponent(source);
    updateSource();

    JScrollPane scrollPane = new JScrollPane(source, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    srcPanel.setLayout(new BorderLayout());
    srcPanel.add(scrollPane, BorderLayout.CENTER);
}

From source file:ucar.unidata.idv.control.chart.ChartWrapper.java

/**
 * Create the properties contents//  w  ww .j  a  v  a 2  s.  c  o  m
 *
 * @param comps  List of components
 * @param tabIdx Which tab
 */
protected void getPropertiesComponents(List comps, int tabIdx) {
    super.getPropertiesComponents(comps, tabIdx);
    if (tabIdx != 0) {
        return;
    }

    if (canDoResolution()) {
        comps.add(GuiUtils.rLabel("Resolution: "));
        resolutionSlider = new JSlider(0, 100, (int) (100 * resolution));
        comps.add(GuiUtils.vbox(resolutionSlider,
                GuiUtils.leftRight(GuiUtils.lLabel("Low"), GuiUtils.rLabel("High"))));
    }

    /*
    if(canDoMinMaxDate() && minOk(dataMinDate) && maxOk(dataMaxDate)) {
    LocaleSpecificResources.setHourFormat(LocaleSpecificResources.HOUR_FORMAT_24);
            
    GregorianCalendar minCal = getMinCalendar();
    GregorianCalendar maxCal = getMaxCalendar();
    ActionListener listener = new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                dateTimeChanged();
            }
        };
            
    minPicker = new DateTimePicker(minCal, "dd-MMM-yyyy HH:mm:ss z");
    minPicker.setDisplayTodayButton(false);
    minPicker.addActionListener(listener);
    minPicker.setMaxSelectableTime(maxCal);
    minPicker.setMinSelectableTime(getCalendar(new Date((long)dataMinDate)));
            
            
    maxPicker = new DateTimePicker(maxCal, "dd-MMM-yyyy HH:mm:ss z");
    maxPicker.setDisplayTodayButton(false);
    maxPicker.addActionListener(listener);
    maxPicker.setMinSelectableTime(minCal);
    maxPicker.setMaxSelectableTime(getCalendar(new Date((long)dataMaxDate)));
            
            
    JPanel datePanel = GuiUtils.hbox(minPicker, new JLabel(" to "), maxPicker);
    comps.add(GuiUtils.rLabel("Date Range: "));
    comps.add(GuiUtils.left(datePanel));
    }*/

    if (canDoJython()) {
        comps.add(GuiUtils.rLabel("Jython: "));
        jythonFld = new JTextField(jython, 40);
        comps.add(GuiUtils.centerRight(jythonFld, GuiUtils.makeButton("Apply", this, "applyJython")));
    }

    if (canDoDataChoiceList()) {
        chartOrderChanged = false;

        fieldProperties = new ArrayList();
        for (int paramIdx = 0; paramIdx < dataChoiceWrappers.size(); paramIdx++) {
            DataChoiceWrapper wrapper = (DataChoiceWrapper) dataChoiceWrappers.get(paramIdx);
            XmlObjectStore store;
            if (getDisplayControl() != null) {
                store = getDisplayControl().getControlContext().getIdv().getStore();
            } else {
                store = McIDASV.getStaticMcv().getStore();
            }
            fieldProperties.add(new FieldProperties(store, wrapper));
        }
        wrapperPanel = new JPanel();

        updateWrapperPanel();

        JScrollPane sp = new JScrollPane(GuiUtils.left(wrapperPanel),
                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

        sp.getVerticalScrollBar().setUnitIncrement(10);

        JViewport vp = sp.getViewport();
        sp.setPreferredSize(new Dimension(600, 200));

        comps.add(GuiUtils.top(GuiUtils.rLabel("Fields:")));
        comps.add(sp);
    }

}

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//w w w . ja v a2s .co  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:eu.crisis_economics.abm.dashboard.Page_Parameters.java

@SuppressWarnings("serial")
private JPanel createParamsweepGUI() {

    // left/* w  w  w .  jav  a 2 s.  co m*/
    parameterList = new JList();
    parameterList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    new ListAction(parameterList, new AbstractAction() {
        public void actionPerformed(final ActionEvent event) {
            final AvailableParameter selectedParameter = (AvailableParameter) parameterList.getSelectedValue();
            addParameterToTree(new AvailableParameter[] { selectedParameter }, parameterTreeBranches.get(0));
            enableDisableParameterCombinationButtons();
        }
    });
    parameterList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!parameterList.isSelectionEmpty()) {
                boolean success = true;
                if (editedNode != null)
                    success = modify();

                if (success) {
                    cancelAllSelectionBut(parameterList);
                    resetSettings();
                    updateDescriptionField(parameterList.getSelectedValues());
                    enableDisableParameterCombinationButtons();
                } else
                    parameterList.clearSelection();
            }
        }
    });

    final JScrollPane parameterListPane = new JScrollPane(parameterList);
    parameterListPane.setBorder(BorderFactory.createTitledBorder("")); // for rounded border
    parameterListPane.setPreferredSize(new Dimension(300, 300));

    final JPanel parametersPanel = FormsUtils.build("p ' p:g", "[DialogBorder]00||" + "12||" + "34||" +
    //                                          "56||" + 
            "55||" + "66 f:p:g", new FormsUtils.Separator("<html><b>General parameters</b></html>"),
            NUMBER_OF_TURNS_LABEL_TEXT, numberOfTurnsFieldPSW, NUMBER_OF_TIMESTEPS_TO_IGNORE_LABEL_TEXT,
            numberTimestepsIgnoredPSW,
            //                                          UPDATE_CHARTS_LABEL_TEXT,onLineChartsCheckBoxPSW,
            new FormsUtils.Separator("<html><b>Model parameters</b></html>"), parameterListPane).getPanel();

    combinationsPanel = new JPanel(new GridLayout(0, 1, 5, 5));
    combinationsScrPane = new JScrollPane(combinationsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    combinationsScrPane.setBorder(null);
    combinationsScrPane.setPreferredSize(new Dimension(550, 500));

    parameterDescriptionLabel = new JXLabel();
    parameterDescriptionLabel.setLineWrap(true);
    parameterDescriptionLabel.setVerticalAlignment(SwingConstants.TOP);
    final JScrollPane descriptionScrollPane = new JScrollPane(parameterDescriptionLabel);
    descriptionScrollPane.setBorder(BorderFactory.createTitledBorder(null, "Description", TitledBorder.LEADING,
            TitledBorder.BELOW_TOP));
    descriptionScrollPane.setPreferredSize(
            new Dimension(PARAMETER_DESCRIPTION_LABEL_WIDTH, PARAMETER_DESCRIPTION_LABEL_HEIGHT));
    descriptionScrollPane.setViewportBorder(null);

    final JButton addNewBoxButton = new JButton("Add new combination");
    addNewBoxButton.setActionCommand(ACTIONCOMMAND_ADD_BOX);

    final JPanel left = FormsUtils.build("p ~ f:p:g ~ p", "011 f:p:g ||" + "0_2 p", parametersPanel,
            combinationsScrPane, addNewBoxButton).getPanel();
    left.setBorder(BorderFactory.createTitledBorder(null, "Specify parameter combinations",
            TitledBorder.LEADING, TitledBorder.BELOW_TOP));
    Style.registerCssClasses(left, Dashboard.CSS_CLASS_COMMON_PANEL);

    final JPanel leftAndDesc = new JPanel(new BorderLayout());
    leftAndDesc.add(left, BorderLayout.CENTER);
    leftAndDesc.add(descriptionScrollPane, BorderLayout.SOUTH);
    Style.registerCssClasses(leftAndDesc, Dashboard.CSS_CLASS_COMMON_PANEL);

    // right
    editedParameterText = new JLabel(ORIGINAL_TEXT);
    editedParameterText.setPreferredSize(new Dimension(280, 40));
    constDef = new JRadioButton("Constant");
    listDef = new JRadioButton("List");
    incrDef = new JRadioButton("Increment");

    final JPanel rightTop = FormsUtils.build("p:g", "[DialogBorder]0||" + "1||" + "2||" + "3",
            editedParameterText, constDef, listDef, incrDef).getPanel();

    Style.registerCssClasses(rightTop, Dashboard.CSS_CLASS_COMMON_PANEL);

    constDefField = new JTextField();
    final JPanel constDefPanel = FormsUtils
            .build("p ~ p:g", "[DialogBorder]01 p", "Constant value: ", CellConstraints.TOP, constDefField)
            .getPanel();

    listDefArea = new JTextArea();
    final JScrollPane listDefScr = new JScrollPane(listDefArea,
            ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    final JPanel listDefPanel = FormsUtils.build("p ~ p:g", "[DialogBorder]01|" + "_1 f:p:g||" + "_2 p",
            "Value list: ", listDefScr, "(Separate values with spaces!)").getPanel();

    incrStartValueField = new JTextField();
    incrEndValueField = new JTextField();
    incrStepField = new JTextField();

    final JPanel incrDefPanel = FormsUtils.build("p ~ p:g", "[DialogBorder]01||" + "23||" + "45",
            "Start value: ", incrStartValueField, "End value: ", incrEndValueField, "Step: ", incrStepField)
            .getPanel();

    enumDefBox = new JComboBox(new DefaultComboBoxModel());
    final JPanel enumDefPanel = FormsUtils
            .build("p ~ p:g", "[DialogBorder]01 p", "Constant value:", CellConstraints.TOP, enumDefBox)
            .getPanel();

    submodelTypeBox = new JComboBox();
    final JPanel submodelTypePanel = FormsUtils
            .build("p ~ p:g", "[DialogBorder]01", "Constant value:", CellConstraints.TOP, submodelTypeBox)
            .getPanel();

    fileTextField = new JTextField();
    fileTextField.addKeyListener(new KeyAdapter() {
        public void keyTyped(final KeyEvent e) {
            final char character = e.getKeyChar();
            final File file = new File(Character.isISOControl(character) ? fileTextField.getText()
                    : fileTextField.getText() + character);
            fileTextField.setToolTipText(file.getAbsolutePath());
        }
    });
    fileBrowseButton = new JButton(BROWSE_BUTTON_TEXT);
    fileBrowseButton.setActionCommand(ACTIONCOMMAND_BROWSE);
    final JPanel fileDefPanel = FormsUtils
            .build("p ~ p:g ~p", "[DialogBorder]012", "File:", fileTextField, fileBrowseButton).getPanel();

    constDefPanel.setName("CONST");
    listDefPanel.setName("LIST");
    incrDefPanel.setName("INCREMENT");
    enumDefPanel.setName("ENUM");
    submodelTypePanel.setName("SUBMODEL");
    fileDefPanel.setName("FILE");

    Style.registerCssClasses(constDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(listDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(incrDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(enumDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(submodelTypePanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    Style.registerCssClasses(fileDefPanel, Dashboard.CSS_CLASS_COMMON_PANEL);

    rightMiddle = new JPanel(new CardLayout());
    Style.registerCssClasses(rightMiddle, Dashboard.CSS_CLASS_COMMON_PANEL);
    rightMiddle.add(constDefPanel, constDefPanel.getName());
    rightMiddle.add(listDefPanel, listDefPanel.getName());
    rightMiddle.add(incrDefPanel, incrDefPanel.getName());
    rightMiddle.add(enumDefPanel, enumDefPanel.getName());
    rightMiddle.add(submodelTypePanel, submodelTypePanel.getName());
    rightMiddle.add(fileDefPanel, fileDefPanel.getName());

    modifyButton = new JButton("Modify");
    cancelButton = new JButton("Cancel");

    final JPanel rightBottom = FormsUtils
            .build("p:g p ~ p ~ p:g", "[DialogBorder]_01_ p", modifyButton, cancelButton).getPanel();

    Style.registerCssClasses(rightBottom, Dashboard.CSS_CLASS_COMMON_PANEL);

    final JPanel right = new JPanel(new BorderLayout());
    right.add(rightTop, BorderLayout.NORTH);
    right.add(rightMiddle, BorderLayout.CENTER);
    right.add(rightBottom, BorderLayout.SOUTH);
    right.setBorder(BorderFactory.createTitledBorder(null, "Parameter settings", TitledBorder.LEADING,
            TitledBorder.BELOW_TOP));

    Style.registerCssClasses(right, Dashboard.CSS_CLASS_COMMON_PANEL);

    // the whole paramsweep panel

    final JPanel content = FormsUtils.build("p:g p", "01 f:p:g", leftAndDesc, right).getPanel();
    Style.registerCssClasses(content, Dashboard.CSS_CLASS_COMMON_PANEL);

    sweepPanel = new JPanel();
    Style.registerCssClasses(sweepPanel, Dashboard.CSS_CLASS_COMMON_PANEL);
    sweepPanel.setLayout(new BorderLayout());
    final JScrollPane sp = new JScrollPane(content);
    sp.setBorder(null);
    sp.setViewportBorder(null);
    sweepPanel.add(sp, BorderLayout.CENTER);

    GUIUtils.createButtonGroup(constDef, listDef, incrDef);
    constDef.setSelected(true);
    constDef.setActionCommand("CONST");
    listDef.setActionCommand("LIST");
    incrDef.setActionCommand("INCREMENT");

    constDefField.setActionCommand("CONST_FIELD");
    incrStartValueField.setActionCommand("START_FIELD");
    incrEndValueField.setActionCommand("END_FIELD");
    incrStepField.setActionCommand("STEP_FIELD");

    modifyButton.setActionCommand("EDIT");
    cancelButton.setActionCommand("CANCEL");

    listDefArea.setLineWrap(true);
    listDefArea.setWrapStyleWord(true);
    listDefScr.setPreferredSize(new Dimension(100, 200));

    GUIUtils.addActionListener(this, modifyButton, cancelButton, constDef, listDef, incrDef, constDefField,
            incrStartValueField, incrEndValueField, incrStepField, addNewBoxButton, submodelTypeBox,
            fileBrowseButton);

    return sweepPanel;
}

From source file:com.rapidminer.gui.new_plotter.gui.ColorSchemeDialog.java

/**
 * @return/*from w w  w .j  a v  a 2s  . c om*/
 */
private JPanel createColorCategoriesPanel() {
    JPanel categoryColorsConfigurationPanel = new JPanel(new GridBagLayout());
    categoryColorsConfigurationPanel.setPreferredSize(new Dimension(180, 200));

    GridBagConstraints itemConstraint = new GridBagConstraints();

    JLabel categoryColorsLabel = new ResourceLabel(
            "plotter.configuration_dialog.color_scheme_dialog.category_colors");
    {

        itemConstraint.fill = GridBagConstraints.HORIZONTAL;
        itemConstraint.anchor = GridBagConstraints.WEST;
        itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
        itemConstraint.insets = new Insets(0, 5, 5, 5);
        itemConstraint.weightx = 1.0;

        categoryColorsConfigurationPanel.add(categoryColorsLabel, itemConstraint);
    }

    // add button panel
    {
        JPanel buttonPanel = new JPanel(new GridBagLayout());

        // remove scheme button
        {
            removeCategoryColorButton = new JButton(new ResourceAction(true,
                    "plotter.configuration_dialog.color_scheme_dialog.remove_category_color_button") {

                private static final long serialVersionUID = 1L;

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

            });

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;
            itemConstraint.fill = GridBagConstraints.NONE;

            buttonPanel.add(removeCategoryColorButton, itemConstraint);
        }

        {
            addCategoryButton = new JButton(new ResourceAction(true,
                    "plotter.configuration_dialog.color_scheme_dialog.add_category_color_button") {

                private static final long serialVersionUID = 1L;

                @Override
                public void actionPerformed(ActionEvent e) {
                    Color oldColor = Color.white;
                    Color newSchemeColor = createColorDialog(oldColor);
                    if (newSchemeColor != null && !newSchemeColor.equals(oldColor)) {
                        addColorAction(newSchemeColor);
                    }
                }

            });

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
            itemConstraint.fill = GridBagConstraints.NONE;

            buttonPanel.add(addCategoryButton, itemConstraint);

        }

        itemConstraint = new GridBagConstraints();
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.fill = GridBagConstraints.NONE;
        itemConstraint.anchor = GridBagConstraints.EAST;
        itemConstraint.insets = new Insets(0, 5, 5, 5);

        categoryColorsConfigurationPanel.add(buttonPanel, itemConstraint);
    }

    {

        JPanel categoryListPanel = new JPanel(new GridBagLayout());

        // add list of categorie colors
        {

            colorList = new JList<Color>(nominalColorListModel);
            categoryColorsLabel.setLabelFor(colorList);
            colorList.setCellRenderer(new ColorListCellRenderer());
            colorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

            MouseAdapter ma = new MouseAdapter() {

                private void myPopupEvent(MouseEvent e) {
                    int x = e.getX();
                    int y = e.getY();
                    JList<?> list = (JList<?>) e.getSource();
                    list.setSelectedIndex(list.locationToIndex(e.getPoint()));
                    Color selectedColor = (Color) list.getSelectedValue();
                    if (selectedColor == null) {
                        return;
                    }

                    removeMenuItem.setEnabled(nominalColorListModel.getSize() > 2);

                    popupMenu.show(list, x, y);
                }

                @Override
                public void mousePressed(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        myPopupEvent(e);
                    }
                }

                @Override
                public void mouseReleased(MouseEvent e) {
                    if (e.isPopupTrigger()) {
                        myPopupEvent(e);
                    }
                }
            };

            colorList.addMouseListener(ma);
            colorList.addKeyListener(new KeyListener() {

                @Override
                public void keyTyped(KeyEvent e) {
                    return; // Nothing to be done
                }

                @Override
                public void keyReleased(KeyEvent e) {
                    return; // Nothing to be done
                }

                @Override
                public void keyPressed(KeyEvent e) {
                    int key = e.getKeyCode();
                    if (key == KeyEvent.VK_DELETE) {
                        if (nominalColorListModel.getSize() > 2) {
                            removeSelectedColorAction();
                        }
                    }
                    if (key == KeyEvent.VK_F2) {
                        replaceSelectedColorAction();
                    }
                    if (key == KeyEvent.VK_UP && SwingTools.isControlOrMetaDown(e)) {
                        moveSelectedColorUpAction();
                    }
                    if (key == KeyEvent.VK_DOWN && SwingTools.isControlOrMetaDown(e)) {
                        moveSelectedColorDownAction();
                    }
                }
            });

            colorListScrollPane = new JScrollPane(colorList);
            colorListScrollPane.setPreferredSize(new Dimension(170, 200));
            colorListScrollPane.setMaximumSize(new Dimension(170, 200));
            colorListScrollPane.setMinimumSize(new Dimension(170, 180));
            colorListScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            colorListScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

            itemConstraint = new GridBagConstraints();
            itemConstraint.fill = GridBagConstraints.BOTH;
            itemConstraint.weightx = 0.0;
            itemConstraint.weighty = 0.5;
            itemConstraint.gridwidth = GridBagConstraints.RELATIVE;

            categoryListPanel.add(colorListScrollPane, itemConstraint);
        }

        // add up/down button panel
        {

            JPanel upAndDownButtonPanel = new JPanel(new GridBagLayout());

            // add up button
            {
                JButton upButton = new JButton(
                        new ResourceAction(true, "plotter.configuration_dialog.move_color_up") {

                            private static final long serialVersionUID = 1L;

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

                itemConstraint = new GridBagConstraints();
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 0;
                itemConstraint.fill = GridBagConstraints.NONE;
                itemConstraint.insets = new Insets(0, 2, 0, 12);

                upAndDownButtonPanel.add(upButton, itemConstraint);
            }

            // add down button
            {
                JButton downButton = new JButton(
                        new ResourceAction(true, "plotter.configuration_dialog.move_color_down") {

                            private static final long serialVersionUID = 1L;

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

                itemConstraint = new GridBagConstraints();
                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 0;
                itemConstraint.fill = GridBagConstraints.NONE;
                itemConstraint.insets = new Insets(0, 2, 0, 12);

                upAndDownButtonPanel.add(downButton, itemConstraint);
            }

            // add spacer panel
            {
                JPanel spacer = new JPanel();

                itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
                itemConstraint.weightx = 0;
                itemConstraint.weighty = 1;
                itemConstraint.fill = GridBagConstraints.VERTICAL;

                upAndDownButtonPanel.add(spacer, itemConstraint);

            }

            itemConstraint = new GridBagConstraints();
            itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
            itemConstraint.weightx = 1;
            itemConstraint.weighty = 1;
            itemConstraint.fill = GridBagConstraints.VERTICAL;

            categoryListPanel.add(upAndDownButtonPanel, itemConstraint);

        }

        itemConstraint = new GridBagConstraints();
        itemConstraint.gridwidth = GridBagConstraints.REMAINDER;
        itemConstraint.weightx = 1;
        itemConstraint.weighty = 1;
        itemConstraint.fill = GridBagConstraints.BOTH;

        categoryColorsConfigurationPanel.add(categoryListPanel, itemConstraint);
    }

    return categoryColorsConfigurationPanel;
}