Example usage for javax.swing Box createRigidArea

List of usage examples for javax.swing Box createRigidArea

Introduction

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

Prototype

public static Component createRigidArea(Dimension d) 

Source Link

Document

Creates an invisible component that's always the specified size.

Usage

From source file:com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.java

@SuppressWarnings("serial")
@Override//w w  w  .j a  v  a  2  s  .  c o m
public void installComponents(VFSJFileChooser fc) {
    AbstractVFSFileSystemView fsv = fc.getFileSystemView();

    fc.setBorder(new EmptyBorder(12, 12, 11, 11));
    fc.setLayout(new BorderLayout(0, 11));

    filePane = new VFSFilePane(new MetalVFSFileChooserUIAccessor());
    fc.addPropertyChangeListener(filePane);

    updateUseShellFolder();

    // ********************************* //
    // **** Construct the top panel **** //
    // ********************************* //

    // Directory manipulation buttons
    JPanel topPanel = new JPanel(new BorderLayout(11, 0));
    topButtonPanel = new JPanel();
    topButtonPanel.setLayout(new BoxLayout(topButtonPanel, BoxLayout.LINE_AXIS));
    topPanel.add(topButtonPanel, BorderLayout.AFTER_LINE_ENDS);

    // Add the top panel to the fileChooser
    fc.add(topPanel, BorderLayout.NORTH);

    // ComboBox Label
    lookInLabel = new JLabel(lookInLabelText);
    topPanel.add(lookInLabel, BorderLayout.BEFORE_LINE_BEGINS);

    // CurrentDir ComboBox
    directoryComboBox = new JComboBox() {
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            // Must be small enough to not affect total width.
            d.width = 150;

            return d;
        }
    };
    directoryComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, lookInLabelText);
    directoryComboBox.putClientProperty("JComboBox.isTableCellEditor", Boolean.TRUE);
    lookInLabel.setLabelFor(directoryComboBox);
    directoryComboBoxModel = createDirectoryComboBoxModel(fc);
    directoryComboBox.setModel(directoryComboBoxModel);
    directoryComboBox.addActionListener(directoryComboBoxAction);
    directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
    directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    directoryComboBox.setAlignmentY(JComponent.TOP_ALIGNMENT);
    directoryComboBox.setMaximumRowCount(8);

    topPanel.add(directoryComboBox, BorderLayout.CENTER);

    // Up Button
    upFolderButton = new JButton(getChangeToParentDirectoryAction());
    upFolderButton.setText(null);
    upFolderButton.setIcon(upFolderIcon);
    upFolderButton.setToolTipText(upFolderToolTipText);
    upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, upFolderAccessibleName);
    upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    upFolderButton.setMargin(shrinkwrap);

    topButtonPanel.add(upFolderButton);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // Home Button
    FileObject homeDir = fsv.getHomeDirectory();
    String toolTipText = homeFolderToolTipText;

    if (fsv.isRoot(homeDir)) {
        toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
    }

    JButton b = new JButton(homeFolderIcon);
    b.setToolTipText(toolTipText);
    b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, homeFolderAccessibleName);
    b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    b.setMargin(shrinkwrap);

    b.addActionListener(getGoHomeAction());
    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // New Directory Button
    if (!UIManager.getBoolean("FileChooser.readOnly")) {
        b = new JButton(filePane.getNewFolderAction());
        b.setText(null);
        b.setIcon(newFolderIcon);
        b.setToolTipText(newFolderToolTipText);
        b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, newFolderAccessibleName);
        b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
        b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
        b.setMargin(shrinkwrap);
    }

    topButtonPanel.add(b);
    topButtonPanel.add(Box.createRigidArea(hstrut5));

    // View button group
    ButtonGroup viewButtonGroup = new ButtonGroup();

    // List Button
    listViewButton = new JToggleButton(listViewIcon);
    listViewButton.setToolTipText(listViewButtonToolTipText);
    listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, listViewButtonAccessibleName);
    listViewButton.setSelected(true);
    listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    listViewButton.setMargin(shrinkwrap);
    listViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_LIST));
    topButtonPanel.add(listViewButton);
    viewButtonGroup.add(listViewButton);

    // Details Button
    detailsViewButton = new JToggleButton(detailsViewIcon);
    detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
    detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
            detailsViewButtonAccessibleName);
    detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
    detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
    detailsViewButton.setMargin(shrinkwrap);
    detailsViewButton.addActionListener(filePane.getViewTypeAction(VFSFilePane.VIEWTYPE_DETAILS));
    topButtonPanel.add(detailsViewButton);
    viewButtonGroup.add(detailsViewButton);
    filePane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            if ("viewType".equals(e.getPropertyName())) {
                final int viewType = filePane.getViewType();

                if (viewType == VFSFilePane.VIEWTYPE_LIST) {
                    listViewButton.setSelected(true);
                } else if (viewType == VFSFilePane.VIEWTYPE_DETAILS) {
                    detailsViewButton.setSelected(true);
                }
            }
        }
    });

    // ************************************** //
    // ******* Add the directory pane ******* //
    // ************************************** //
    fc.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);

    JComponent accessory = fc.getAccessory();

    if (accessory != null) {
        getAccessoryPanel().add(accessory);
    }

    filePane.setPreferredSize(LIST_PREF_SIZE);
    fc.add(filePane, BorderLayout.CENTER);

    // ********************************** //
    // **** Construct the bottom panel ** //
    // ********************************** //
    bottomPanel = getBottomPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.Y_AXIS));
    fc.add(bottomPanel, BorderLayout.SOUTH);

    // FileName label and textfield
    JPanel fileNamePanel = new JPanel();
    fileNamePanel.setLayout(new BoxLayout(fileNamePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(fileNamePanel);
    bottomPanel.add(Box.createRigidArea(vstrut5));

    fileNameLabel = new AlignedLabel();
    populateFileNameLabel();
    fileNamePanel.add(fileNameLabel);

    fileNameTextField = new JTextField(35) {
        @Override
        public Dimension getMaximumSize() {
            return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
        }
    };

    PopupHandler.installDefaultMouseListener(fileNameTextField);

    fileNamePanel.add(fileNameTextField);
    fileNameLabel.setLabelFor(fileNameTextField);
    fileNameTextField.addFocusListener(new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            if (!getFileChooser().isMultiSelectionEnabled()) {
                filePane.clearSelection();
            }
        }
    });

    if (fc.isMultiSelectionEnabled()) {
        setFileName(fileNameString(fc.getSelectedFileObjects()));
    } else {
        setFileName(fileNameString(fc.getSelectedFileObject()));
    }

    // Filetype label and combobox
    JPanel filesOfTypePanel = new JPanel();
    filesOfTypePanel.setLayout(new BoxLayout(filesOfTypePanel, BoxLayout.LINE_AXIS));
    bottomPanel.add(filesOfTypePanel);

    AlignedLabel filesOfTypeLabel = new AlignedLabel(filesOfTypeLabelText);
    filesOfTypePanel.add(filesOfTypeLabel);

    filterComboBoxModel = createFilterComboBoxModel();
    fc.addPropertyChangeListener(filterComboBoxModel);
    filterComboBox = new JComboBox(filterComboBoxModel);
    filterComboBox.putClientProperty(AccessibleContext.ACCESSIBLE_DESCRIPTION_PROPERTY, filesOfTypeLabelText);
    filesOfTypeLabel.setLabelFor(filterComboBox);
    filterComboBox.setRenderer(createFilterComboBoxRenderer());
    filesOfTypePanel.add(filterComboBox);

    // buttons
    getButtonPanel().setLayout(new ButtonAreaLayout());

    approveButton = new JButton(getApproveButtonText(fc));
    // Note: Metal does not use mnemonics for approve and cancel
    approveButton.addActionListener(getApproveSelectionAction());
    fileNameTextField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                getApproveSelectionAction().actionPerformed(null);
            } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
                getFileChooser().cancelSelection();
            }
        }
    });
    approveButton.setToolTipText(getApproveButtonToolTipText(fc));
    getButtonPanel().add(approveButton);

    cancelButton = new JButton(cancelButtonText);
    cancelButton.setToolTipText(cancelButtonToolTipText);
    cancelButton.addActionListener(getCancelSelectionAction());
    getButtonPanel().add(cancelButton);

    if (fc.getControlButtonsAreShown()) {
        addControlButtons();
    }

    groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
}

From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java

private JComponent makeButtons() {
    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
    p.add(convertBtn);//from w w w . ja v  a 2  s  .co  m
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(validateBtn);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(convertAndValidateBtn);
    p.add(Box.createRigidArea(new Dimension(0, 10)));
    p.add(convertEdmBtn);
    return p;
}

From source file:net.java.sip.communicator.gui.AuthenticationSplash.java

/**
 *
 * We use dynamic layout managers, so that layout is dynamic and will
 * adapt properly to user-customized fonts and localized text. The
 * GridBagLayout makes it easy to line up components of varying
 * sizes along invisible vertical and horizontal grid lines. It
 * is important to sketch the layout of the interface and decide
 * on the grid before writing the layout code.
 *
 * Here we actually use/* w  w  w .  j  a  v a2s  .  c  om*/
 * our own subclass of GridBagLayout called StringGridBagLayout,
 * which allows us to use strings to specify constraints, rather
 * than having to create GridBagConstraints objects manually.
 *
 *
 * We use the JLabel.setLabelFor() method to connect
 * labels to what they are labeling. This allows mnemonics to work
 * and assistive to technologies used by persons with disabilities
 * to provide much more useful information to the user.
 */

private void initComponents(final Frame parent) {
    Container contents = getContentPane();
    contents.setLayout(new BorderLayout());

    String title = Utils.getProperty("net.java.sip.communicator.gui.AUTH_WIN_TITLE");

    if (title == null)
        title = "Login Manager";

    setTitle(title);
    setResizable(false);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent event) {
            dialogDone(CMD_CANCEL, parent);
        }
    });

    // Accessibility -- all frames, dialogs, and applets should
    // have a description
    getAccessibleContext().setAccessibleDescription("Authentication Splash");

    String authPromptLabelValue = Utils.getProperty("net.java.sip.communicator.gui.AUTHENTICATION_PROMPT");

    if (authPromptLabelValue == null)
        authPromptLabelValue = "Please register to the service or enter your credentials to log in:";

    JLabel splashLabel = new JLabel(authPromptLabelValue);
    splashLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    splashLabel.setHorizontalAlignment(SwingConstants.CENTER);
    splashLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    contents.add(splashLabel, BorderLayout.NORTH);

    JPanel centerPane = new JPanel();
    centerPane.setLayout(new GridBagLayout());

    userNameTextField = new JTextField(); // needed below

    // user name label
    JLabel userNameLabel = new JLabel();
    userNameLabel.setDisplayedMnemonic('U');
    // setLabelFor() allows the mnemonic to work
    userNameLabel.setLabelFor(userNameTextField);

    String userNameLabelValue = Utils.getProperty("net.java.sip.communicator.gui.USER_NAME_LABEL");

    if (userNameLabelValue == null)
        userNameLabelValue = "Username";

    int gridy = 0;

    userNameLabel.setText(userNameLabelValue);
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(12, 12, 0, 0);
    centerPane.add(userNameLabel, c);

    // user name text
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(12, 7, 0, 11);
    centerPane.add(userNameTextField, c);

    passwordTextField = new JPasswordField(); //needed below

    // password label
    JLabel passwordLabel = new JLabel();
    passwordLabel.setDisplayedMnemonic('P');
    passwordLabel.setLabelFor(passwordTextField);
    String pLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.PASSWORD_LABEL");

    if (pLabelStr == null)
        pLabelStr = "Password";

    passwordLabel.setText(pLabelStr);
    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = gridy;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(11, 12, 0, 0);

    centerPane.add(passwordLabel, c);

    // password text
    passwordTextField.setEchoChar('\u2022');
    c = new GridBagConstraints();
    c.gridx = 1;
    c.gridy = gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(11, 7, 0, 11);
    centerPane.add(passwordTextField, c);

    //Set a relevant realm value
    //Bug report by Steven Lass (sltemp at comcast.net)
    //JLabel realmValueLabel = new JLabel("SipPhone.com"); // needed below

    // realm label

    JLabel realmLabel = new JLabel();
    realmLabel.setDisplayedMnemonic('R');
    realmLabel.setLabelFor(realmValueLabel);
    realmLabel.setText("Realm");
    realmValueLabel = new JLabel();

    // Buttons along bottom of window
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, 0));
    loginButton = new JButton();
    loginButton.setText("Login");
    loginButton.setActionCommand(CMD_LOGIN);
    loginButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dialogDone(event, parent);
        }
    });
    buttonPanel.add(loginButton);

    // space
    buttonPanel.add(Box.createRigidArea(new Dimension(5, 0)));

    registerButton = new JButton();
    registerButton.setMnemonic('G');
    registerButton.setText("Register");
    registerButton.setActionCommand(CMD_REGISTER);
    registerButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dialogDone(event, parent);
        }
    });
    buttonPanel.add(registerButton);

    buttonPanel.add(Box.createRigidArea(new Dimension(5, 0)));

    cancelButton = new JButton();
    cancelButton.setText("Cancel");
    cancelButton.setActionCommand(CMD_CANCEL);
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dialogDone(event, parent);
        }
    });
    buttonPanel.add(cancelButton);

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    c.insets = new Insets(11, 12, 11, 11);

    centerPane.add(buttonPanel, c);

    contents.add(centerPane, BorderLayout.CENTER);
    getRootPane().setDefaultButton(loginButton);
    equalizeButtonSizes();

    setFocusTraversalPolicy(new FocusTraversalPol());

}

From source file:org.n52.ifgicopter.spf.gui.SPFMainFrame.java

/**
 * the gui representation of the framework
 *///  w ww  .j a v a 2s.  co  m
public SPFMainFrame() {

    /*
     * handled by worker thread.
     */
    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    this.setTitle("Sensor Platform Framework");

    this.menu = new JMenuBar();

    try {
        File f = new File("img/icon.png");
        InputStream in;
        if (!f.exists()) {
            in = ImageMapMarker.class.getResourceAsStream("/img/icon.png");
        } else {
            in = new FileInputStream(f);
        }

        this.setIconImage(ImageIO.read(in));
    } catch (IOException e) {
        this.log.warn(e.getMessage(), e);
    }

    /*
     * simple menu bar
     */
    JMenu file = new JMenu("File");
    JMenuItem exit = new JMenuItem("Exit");

    /*
     * shutdown the engine if closed
     */
    exit.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            shutdownFrame();
        }
    });

    this.pnp = new JCheckBoxMenuItem("Plug'n'Play mode");
    this.pnp.setSelected(false);

    /*
     * switch the pnp mode
     */
    this.pnp.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean flag = SPFMainFrame.this.pnp.isSelected();

            if (flag && !SPFMainFrame.this.dontShow) {
                JCheckBox checkbox = new JCheckBox("Do not show this message again.");
                String message = "During Plug'n'Play mode the output generation is blocked.";
                Object[] params = { message, checkbox };
                JOptionPane.showMessageDialog(SPFMainFrame.this, params);
                SPFMainFrame.this.dontShow = checkbox.isSelected();
            }

            /*
             * check if we need to restart the output plugins
             */
            if (!flag && SPFMainFrame.this.inputChanged) {
                SPFRegistry.getInstance().restartOutputPlugins();
            }

            SPFRegistry.getInstance().setPNPMode(flag);
        }
    });

    JMenuItem restart = new JMenuItem("Restart");
    restart.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            shutdownFrame(RESTART_CODE);
        }
    });

    JMenuItem managePlugins = new JMenuItem("Manage available Plugins");
    managePlugins.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            PluginRegistrationDialog prd = new PluginRegistrationDialog(SPFMainFrame.this);

            if (prd.isCanceled())
                return;

            updateConfigurationFile(prd.getSelectedNewPlugins(), prd.getSelectedOldPlugins());

            int ret = JOptionPane.showConfirmDialog(SPFMainFrame.this,
                    "<html><body><div>" + "Changes will have effect after restart of the application. "
                            + "</div><div>A restart is highly recommended due to memory usage."
                            + "</div><div><br />Restart now?</div></body></html>",
                    "Restart application", JOptionPane.YES_NO_OPTION);

            if (ret == 0) {
                shutdownFrame(RESTART_CODE);
            }
        }
    });
    file.add(managePlugins);

    file.add(this.pnp);
    file.add(new FixedSeparator());
    file.add(restart);
    file.add(new FixedSeparator());
    file.add(exit);
    this.menu.add(file);
    this.inputPluginMenu = new JMenu("InputPlugins");
    this.outputPluginMenu = new JMenu("OutputPlugins");
    this.menu.add(this.inputPluginMenu);
    this.menu.add(this.outputPluginMenu);

    /*
     * help
     */
    this.aboutDialog = new AboutDialog(SPFMainFrame.this);
    JMenu help = new JMenu("Help");
    JMenuItem about = new JMenuItem("About");
    about.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SPFMainFrame.this.aboutDialog.showSelf(SPFMainFrame.this);
        }
    });

    help.add(about);
    this.menu.add(help);
    this.setJMenuBar(this.menu);

    /*
     * the tabbed pane. every tab represents a input plugin
     */
    this.pane = new JTabbedPane();
    this.pane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);

    /*
     * shutdown the engine if closed
     */
    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            SPFMainFrame.this.shutdownFrame();
        }

    });

    /*
     * the framework core tab
     */
    this.corePanel = new FrameworkCorePanel();
    this.addTab(this.corePanel, "Framework Core", BLUE_IMAGE);

    /*
     * the map panel
     */
    if (Boolean.parseBoolean(SPFRegistry.getInstance().getConfigProperty(SPFRegistry.OVERVIEW_MAP_ENABLED))) {
        this.mapPanel = new MapPanel();
        this.addTab(this.mapPanel, "Overview Map", BLUE_IMAGE);
    }

    /*
     * other stuff
     */
    this.getContentPane().add(this.pane);

    JPanel statusBar = new JPanel();
    statusBar.setLayout(new BorderLayout());
    statusBar.setPreferredSize(new Dimension(200, 25));
    JPanel statusBarWrapper = new JPanel(new BorderLayout());
    statusBarWrapper.add(Box.createRigidArea(new Dimension(3, 3)), BorderLayout.WEST);
    statusBarWrapper.add(statusBar);
    statusBarWrapper.add(Box.createRigidArea(new Dimension(3, 3)), BorderLayout.EAST);

    this.statusLabel = new JLabel("SPFramework startup finished.");
    statusBar.add(this.statusLabel, BorderLayout.EAST);

    this.outputLabel = new JLabel("(no output yet)");
    statusBar.add(this.outputLabel, BorderLayout.WEST);

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

    this.getContentPane().setBackground(this.pane.getBackground());

    this.setPreferredSize(new Dimension(1280, 720));
    this.pack();

    /*
     * full screen?
     */
    if (Boolean.parseBoolean(SPFRegistry.getInstance().getConfigProperty(SPFRegistry.MAXIMIZED))) {
        this.setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);
    }

    this.setLocationRelativeTo(null);
}

From source file:ru.medved.json.wssoap.WebServiceSamplerGui.java

private final JPanel createTopPanel() {
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new VerticalLayout(5, VerticalLayout.BOTH));

    JPanel wsdlHelper = new JPanel();
    wsdlHelper.setLayout(new BoxLayout(wsdlHelper, BoxLayout.Y_AXIS));
    wsdlHelper.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            JMeterUtils.getResString("webservice_configuration_wizard"))); // $NON-NLS-1$

    // Button for browsing webservice wsdl
    JPanel wsdlEntry = new JPanel();
    wsdlEntry.setLayout(new BoxLayout(wsdlEntry, BoxLayout.X_AXIS));
    Border margin = new EmptyBorder(0, 5, 0, 5);
    wsdlEntry.setBorder(margin);//from ww  w.j  ava  2s .co  m
    wsdlHelper.add(wsdlEntry);
    wsdlEntry.add(wsdlField);
    wsdlEntry.add(wsdlButton);
    wsdlButton.addActionListener(this);

    // Web Methods
    JPanel listPanel = new JPanel();
    listPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    JLabel selectLabel = new JLabel(JMeterUtils.getResString("webservice_methods")); // $NON-NLS-1$
    wsdlMethods = new JLabeledChoice();
    wsdlHelper.add(listPanel);
    listPanel.add(selectLabel);
    listPanel.add(wsdlMethods);
    listPanel.add(selectButton);
    selectButton.addActionListener(this);

    topPanel.add(wsdlHelper);

    JPanel urlPane = new JPanel();
    urlPane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
    urlPane.add(protocol);
    urlPane.add(Box.createRigidArea(new Dimension(5, 0)));
    urlPane.add(domain);
    urlPane.add(Box.createRigidArea(new Dimension(5, 0)));
    urlPane.add(port);
    urlPane.add(Box.createRigidArea(new Dimension(5, 0)));
    urlPane.add(connectTimeout);
    topPanel.add(urlPane);

    topPanel.add(path);
    topPanel.add(soapAction);

    topPanel.add(jsonConfigFile);
    topPanel.add(configSection);
    return topPanel;
}

From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java

private JComponent makeCheckboxes() {
    xsltPanel.setLayout(new BoxLayout(xsltPanel, BoxLayout.PAGE_AXIS));
    xsltPanel.add(stylesheetLabel);//from  www .  jav a  2s.  c  o m
    JRadioButton radioButton;
    for (File xsltFile : Utilities.getXsltFiles()) {
        radioButton = new JRadioButton(xsltFile.getName());
        if (xsltFile.getName().equals(retrieveFromDb.retrieveDefaultXsl()))
            radioButton.setSelected(true);
        radioButton.addActionListener(new XsltSelectorListener(dataPreparationToolGUI));
        dataPreparationToolGUI.getGroupXslt().add(radioButton);
        xsltPanel.add(radioButton);
        xsltPanel.add(Box.createRigidArea(new Dimension(0, 10)));
    }
    return xsltPanel;
}

From source file:FileChooserDemo.java

public FileChooserDemo() {
    UIManager.LookAndFeelInfo[] installedLafs = UIManager.getInstalledLookAndFeels();
    for (UIManager.LookAndFeelInfo lafInfo : installedLafs) {
        try {//from   w  w  w. ja v a2  s.  c  om
            Class lnfClass = Class.forName(lafInfo.getClassName());
            LookAndFeel laf = (LookAndFeel) (lnfClass.newInstance());
            if (laf.isSupportedLookAndFeel()) {
                String name = lafInfo.getName();
                supportedLaFs.add(new SupportedLaF(name, laf));
            }
        } catch (Exception e) { // If ANYTHING weird happens, don't add it
            continue;
        }
    }

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    chooser = new JFileChooser();
    previewer = new FilePreviewer(chooser);

    // Create Custom FileView
    fileView = new ExampleFileView();
    //    fileView.putIcon("jpg", new ImageIcon(getClass().getResource("/resources/images/jpgIcon.jpg")));
    //  fileView.putIcon("gif", new ImageIcon(getClass().getResource("/resources/images/gifIcon.gif")));

    // create a radio listener to listen to option changes
    OptionListener optionListener = new OptionListener();

    // Create options
    openRadioButton = new JRadioButton("Open");
    openRadioButton.setSelected(true);
    openRadioButton.addActionListener(optionListener);

    saveRadioButton = new JRadioButton("Save");
    saveRadioButton.addActionListener(optionListener);

    customButton = new JRadioButton("Custom");
    customButton.addActionListener(optionListener);

    customField = new JTextField(8) {
        public Dimension getMaximumSize() {
            return new Dimension(getPreferredSize().width, getPreferredSize().height);
        }
    };
    customField.setText("Doit");
    customField.setAlignmentY(JComponent.TOP_ALIGNMENT);
    customField.setEnabled(false);
    customField.addActionListener(optionListener);

    ButtonGroup group1 = new ButtonGroup();
    group1.add(openRadioButton);
    group1.add(saveRadioButton);
    group1.add(customButton);

    // filter buttons
    showAllFilesFilterCheckBox = new JCheckBox("Show \"All Files\" Filter");
    showAllFilesFilterCheckBox.addActionListener(optionListener);
    showAllFilesFilterCheckBox.setSelected(true);

    showImageFilesFilterCheckBox = new JCheckBox("Show JPG and GIF Filters");
    showImageFilesFilterCheckBox.addActionListener(optionListener);
    showImageFilesFilterCheckBox.setSelected(false);

    accessoryCheckBox = new JCheckBox("Show Preview");
    accessoryCheckBox.addActionListener(optionListener);
    accessoryCheckBox.setSelected(false);

    // more options
    setHiddenCheckBox = new JCheckBox("Show Hidden Files");
    setHiddenCheckBox.addActionListener(optionListener);

    showFullDescriptionCheckBox = new JCheckBox("With File Extensions");
    showFullDescriptionCheckBox.addActionListener(optionListener);
    showFullDescriptionCheckBox.setSelected(true);
    showFullDescriptionCheckBox.setEnabled(false);

    useFileViewCheckBox = new JCheckBox("Use FileView");
    useFileViewCheckBox.addActionListener(optionListener);
    useFileViewCheckBox.setSelected(false);

    useEmbedInWizardCheckBox = new JCheckBox("Embed in Wizard");
    useEmbedInWizardCheckBox.addActionListener(optionListener);
    useEmbedInWizardCheckBox.setSelected(false);

    useControlsCheckBox = new JCheckBox("Show Control Buttons");
    useControlsCheckBox.addActionListener(optionListener);
    useControlsCheckBox.setSelected(true);

    enableDragCheckBox = new JCheckBox("Enable Dragging");
    enableDragCheckBox.addActionListener(optionListener);

    // File or Directory chooser options
    ButtonGroup group3 = new ButtonGroup();
    justFilesRadioButton = new JRadioButton("Just Select Files");
    justFilesRadioButton.setSelected(true);
    group3.add(justFilesRadioButton);
    justFilesRadioButton.addActionListener(optionListener);

    justDirectoriesRadioButton = new JRadioButton("Just Select Directories");
    group3.add(justDirectoriesRadioButton);
    justDirectoriesRadioButton.addActionListener(optionListener);

    bothFilesAndDirectoriesRadioButton = new JRadioButton("Select Files or Directories");
    group3.add(bothFilesAndDirectoriesRadioButton);
    bothFilesAndDirectoriesRadioButton.addActionListener(optionListener);

    singleSelectionRadioButton = new JRadioButton("Single Selection", true);
    singleSelectionRadioButton.addActionListener(optionListener);

    multiSelectionRadioButton = new JRadioButton("Multi Selection");
    multiSelectionRadioButton.addActionListener(optionListener);

    ButtonGroup group4 = new ButtonGroup();
    group4.add(singleSelectionRadioButton);
    group4.add(multiSelectionRadioButton);

    // Create show button
    showButton = new JButton("Show FileChooser");
    showButton.addActionListener(this);
    showButton.setMnemonic('s');

    // Create laf combo box

    lafComboBox = new JComboBox(supportedLaFs);
    lafComboBox.setEditable(false);
    lafComboBox.addActionListener(optionListener);

    // ********************************************************
    // ******************** Dialog Type ***********************
    // ********************************************************
    JPanel control1 = new InsetPanel(insets);
    control1.setBorder(BorderFactory.createTitledBorder("Dialog Type"));

    control1.setLayout(new BoxLayout(control1, BoxLayout.Y_AXIS));
    control1.add(Box.createRigidArea(vpad20));
    control1.add(openRadioButton);
    control1.add(Box.createRigidArea(vpad7));
    control1.add(saveRadioButton);
    control1.add(Box.createRigidArea(vpad7));
    control1.add(customButton);
    control1.add(Box.createRigidArea(vpad4));
    JPanel fieldWrapper = new JPanel();
    fieldWrapper.setLayout(new BoxLayout(fieldWrapper, BoxLayout.X_AXIS));
    fieldWrapper.setAlignmentX(Component.LEFT_ALIGNMENT);
    fieldWrapper.add(Box.createRigidArea(hpad10));
    fieldWrapper.add(Box.createRigidArea(hpad10));
    fieldWrapper.add(customField);
    control1.add(fieldWrapper);
    control1.add(Box.createRigidArea(vpad20));
    control1.add(Box.createGlue());

    // ********************************************************
    // ***************** Filter Controls **********************
    // ********************************************************
    JPanel control2 = new InsetPanel(insets);
    control2.setBorder(BorderFactory.createTitledBorder("Filter Controls"));
    control2.setLayout(new BoxLayout(control2, BoxLayout.Y_AXIS));
    control2.add(Box.createRigidArea(vpad20));
    control2.add(showAllFilesFilterCheckBox);
    control2.add(Box.createRigidArea(vpad7));
    control2.add(showImageFilesFilterCheckBox);
    control2.add(Box.createRigidArea(vpad4));
    JPanel checkWrapper = new JPanel();
    checkWrapper.setLayout(new BoxLayout(checkWrapper, BoxLayout.X_AXIS));
    checkWrapper.setAlignmentX(Component.LEFT_ALIGNMENT);
    checkWrapper.add(Box.createRigidArea(hpad10));
    checkWrapper.add(Box.createRigidArea(hpad10));
    checkWrapper.add(showFullDescriptionCheckBox);
    control2.add(checkWrapper);
    control2.add(Box.createRigidArea(vpad20));
    control2.add(Box.createGlue());

    // ********************************************************
    // ****************** Display Options *********************
    // ********************************************************
    JPanel control3 = new InsetPanel(insets);
    control3.setBorder(BorderFactory.createTitledBorder("Display Options"));
    control3.setLayout(new BoxLayout(control3, BoxLayout.Y_AXIS));
    control3.add(Box.createRigidArea(vpad20));
    control3.add(setHiddenCheckBox);
    control3.add(Box.createRigidArea(vpad7));
    control3.add(useFileViewCheckBox);
    control3.add(Box.createRigidArea(vpad7));
    control3.add(accessoryCheckBox);
    control3.add(Box.createRigidArea(vpad7));
    control3.add(useEmbedInWizardCheckBox);
    control3.add(Box.createRigidArea(vpad7));
    control3.add(useControlsCheckBox);
    control3.add(Box.createRigidArea(vpad7));
    control3.add(enableDragCheckBox);
    control3.add(Box.createRigidArea(vpad20));
    control3.add(Box.createGlue());

    // ********************************************************
    // ************* File & Directory Options *****************
    // ********************************************************
    JPanel control4 = new InsetPanel(insets);
    control4.setBorder(BorderFactory.createTitledBorder("File and Directory Options"));
    control4.setLayout(new BoxLayout(control4, BoxLayout.Y_AXIS));
    control4.add(Box.createRigidArea(vpad20));
    control4.add(justFilesRadioButton);
    control4.add(Box.createRigidArea(vpad7));
    control4.add(justDirectoriesRadioButton);
    control4.add(Box.createRigidArea(vpad7));
    control4.add(bothFilesAndDirectoriesRadioButton);
    control4.add(Box.createRigidArea(vpad20));
    control4.add(singleSelectionRadioButton);
    control4.add(Box.createRigidArea(vpad7));
    control4.add(multiSelectionRadioButton);
    control4.add(Box.createRigidArea(vpad20));
    control4.add(Box.createGlue());

    // ********************************************************
    // **************** Look & Feel Switch ********************
    // ********************************************************
    JPanel panel = new JPanel();
    panel.add(new JLabel("Look and Feel: "));
    panel.add(lafComboBox);
    panel.add(showButton);

    // ********************************************************
    // ****************** Wrap 'em all up *********************
    // ********************************************************
    JPanel wrapper = new JPanel();
    wrapper.setLayout(new BoxLayout(wrapper, BoxLayout.X_AXIS));

    add(Box.createRigidArea(vpad20));

    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(control1);
    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(control2);
    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(control3);
    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(control4);
    wrapper.add(Box.createRigidArea(hpad10));
    wrapper.add(Box.createRigidArea(hpad10));

    add(wrapper);
    add(Box.createRigidArea(vpad20));
    add(panel);
    add(Box.createRigidArea(vpad20));
}

From source file:net.pandoragames.far.ui.swing.FindFilePanel.java

private void initFileNamePatternPanel(SwingConfig config, ComponentRepository componentRepository) {

    JLabel labelPattern = new JLabel(localizer.localize("label.file-name-pattern"));
    labelPattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(labelPattern);

    listPattern = new JComboBox(config.getFileNamePatternListModel());
    listPattern.setEditable(true);//from   ww  w. java 2s.  c om
    listPattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));

    JButton buttonSavePattern = new JButton(localizer.localize("button.save-pattern"));
    buttonSavePattern.setEnabled(false);
    TwoComponentsPanel linePattern = new TwoComponentsPanel(listPattern, buttonSavePattern);
    linePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(linePattern);

    patternFlag = new JCheckBox(localizer.localize("label.regular-expression"));
    patternFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternFlag.setSelected(dataModel.getFileNamePattern().isRegex());
    patternFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.getFileNamePattern().setRegex((ItemEvent.SELECTED == event.getStateChange()));
        }
    });
    patternFlag.addItemListener(componentRepository.getSearchBaseListener());
    browseButtonListener.setRegexCheckBox(patternFlag);
    browseButtonListener.addComponentToBeDisabledForSingleFiles(patternFlag);
    componentRepository.getSearchBaseListener().addToBeEnabled(patternFlag);
    componentRepository.getResetDispatcher().addToBeEnabled(patternFlag);
    listPattern.addActionListener(new PatternListListener(patternFlag, componentRepository.getMessageBox()));
    listPattern.addActionListener(componentRepository.getSearchBaseListener());
    ComboBoxEditor comboBoxEditor = new FileNamePatternEditor(buttonSavePattern);
    listPattern.setEditor(comboBoxEditor);
    browseButtonListener.setComboBox(listPattern);
    browseButtonListener.addComponentToBeDisabledForSingleFiles(listPattern);
    componentRepository.getSearchBaseListener().addToBeEnabled(listPattern);
    componentRepository.getResetDispatcher().addToBeEnabled(listPattern);
    buttonSavePattern.addActionListener(
            new SaveFileNamePatternListener(listPattern, patternFlag, config, componentRepository));
    this.add(patternFlag);

    datePanel = new DateRestrictionPanel(dataModel, componentRepository, config);
    componentRepository.getResetDispatcher().addResetable(datePanel);
    datePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(datePanel);

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    this.add(Box.createVerticalGlue());
}

From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication.java

private void initSliders() {
    sliderPanel = new JPanel();

    JPanel rPanel = new JPanel();
    JPanel rPanel2 = new JPanel();
    rSliders = new FloatSlider[numStocks];
    R = new double[numStocks];
    double[] r = { 0.0064, 0.0022, 0.02117, 0.01, 0.0134 };

    JPanel matrixPanel = new JPanel();
    mSliders = new FloatSlider[15];
    CORR = new double[numStocks][numStocks];
    double[] m = { 0.0101, 0.0045, 0.0122, 0.0041, 0.0026, 0.0119, 0.0012, 0.0011, 0.0015, 0.0141, 0.0043,
            0.0022, 0.0058, 0.005, 0.0144 };

    rPanel.setLayout(new GridBagLayout());
    rPanel.add(new JLabel("Expected Return:"));
    for (int i = 0; i < numStocks; i++) {
        R[i] = r[i];//from   w  w  w .j av  a  2  s.  com
        rSliders[i] = new edu.ucla.stat.SOCR.util.FloatSlider("E(R" + (i + 1) + ")", -0.1, 0.1, r[i], false);
        rSliders[i].setPreferredSize(new Dimension(CHART_SIZE_X / 3, 80));
        rSliders[i]
                .setToolTipText("Slider for adjusting the value of expected return for stock " + (i + 1) + ".");
        newMSlider(1, i, rSliders[i], r[i], rPanel);

    }

    rPanel2.setLayout(new GridBagLayout());
    rPanel2.add(new JLabel("Covariance:"));
    for (int i = 0; i < numStocks; i++) {
        R[i] = r[i];
        mSliders[i] = new edu.ucla.stat.SOCR.util.FloatSlider("VAR(R" + (i + 1) + ")", 0, 0.5);
        mSliders[i].setPreferredSize(new Dimension(CHART_SIZE_X / 3, 80));
        mSliders[i].setToolTipText("Slider for adjusting the value of covariance " + (i + 1) + ".");
        newMSlider(1, i, mSliders[i], m[i], rPanel2);
    }

    matrixPanel.setLayout(new GridBagLayout());
    matrixPanel.add(new JLabel("Correlation Matrix:"));
    int k = 0;
    for (int i = 0; i < numStocks; i++)
        for (int j = 0; j <= i; j++) {
            CORR[i][j] = m[k];
            if (i == j) {
                mSliders[k] = new edu.ucla.stat.SOCR.util.FloatSlider("VAR(R" + (i + 1) + ")", 0, 0.5);
                //   newMSlider(i,j,mSliders[k],m[k],matrixPanel);
            } else {
                mSliders[k] = new edu.ucla.stat.SOCR.util.FloatSlider("COV" + (j + 1) + (i + 1), 0, 0.5);
                mSliders[k].setPreferredSize(new Dimension(CHART_SIZE_X * 5 / 12, 80));
                mSliders[k].setToolTipText("Slider for adjusting the value of covariance matrix (" + (j + 1)
                        + "," + (i + 1) + ").");
                newMSlider(i, j, mSliders[k], m[k], matrixPanel);
            }
            k++;
        }

    sliderPanel.setLayout(new BoxLayout(sliderPanel, BoxLayout.PAGE_AXIS));
    /*Box box = Box.createVerticalBox();
    box.add(rPanel);
    box.add(rPanel2);
    box.add(new JLabel("Correlation Matrix:"));
    box.add(matrixPanel);
    sliderPanel.add(box);*/
    rPanel.setAlignmentX(LEFT_ALIGNMENT);
    rPanel2.setAlignmentX(LEFT_ALIGNMENT);
    matrixPanel.setAlignmentX(LEFT_ALIGNMENT);
    sliderPanel.add(rPanel);
    sliderPanel.add(rPanel2);
    sliderPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    sliderPanel.add(matrixPanel);
    sliderPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    //sliderPanel.setBackground(Color.white);
}

From source file:net.pandoragames.far.ui.swing.FindFilePanel.java

private void initContentSearchPanel(SwingConfig config, ComponentRepository componentRepository) {

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    String title = localizer.localize("label.content-pattern");
    contentSearchPanel = new ContentSearchPanel(title, dataModel, config, componentRepository);
    contentSearchPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    browseButtonListener.addComponentToBeDisabledForSingleFiles(contentSearchPanel);
    componentRepository.getSearchBaseListener().addToBeEnabled(contentSearchPanel);
    componentRepository.getResetDispatcher().addToBeEnabled(contentSearchPanel);
    this.add(contentSearchPanel);

    inversionFlag = new JCheckBox(localizer.localize("label.exclude-matches"));
    inversionFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    inversionFlag.setSelected(dataModel.isInvertContentFilter());
    inversionFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setInvertContentFilter((ItemEvent.SELECTED == event.getStateChange()));
        }/*from  ww  w.  jav  a2s . c o  m*/
    });
    browseButtonListener.addComponentToBeDisabledForSingleFiles(inversionFlag);
    componentRepository.getSearchBaseListener().addToBeEnabled(inversionFlag);
    componentRepository.getResetDispatcher().addToBeEnabled(inversionFlag);
    contentSearchPanel.addFlag(inversionFlag);

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    this.add(Box.createVerticalGlue());

}