Example usage for javax.swing BoxLayout PAGE_AXIS

List of usage examples for javax.swing BoxLayout PAGE_AXIS

Introduction

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

Prototype

int PAGE_AXIS

To view the source code for javax.swing BoxLayout PAGE_AXIS.

Click Source Link

Document

Specifies that components should be laid out in the direction that lines flow across a page as determined by the target container's ComponentOrientation property.

Usage

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private void createMainSector() {

    JPanel topContainer = new JPanel();
    topContainer.setLayout(new BoxLayout(topContainer, BoxLayout.PAGE_AXIS));
    topContainer.setBackground(UIHelper.BG_COLOR);

    // add logo to the top
    topContainer.add(createMenu());//w w  w . j  av a  2  s  .c  o m

    JPanel headerImagePanel = new JPanel(new GridLayout(1, 2));
    headerImagePanel.setOpaque(false);

    JLabel logo = new JLabel("");
    logo.setOpaque(false);

    headerImagePanel.add(logo);

    tableInformationDisplay = UIHelper.createLabel("", UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR,
            SwingConstants.RIGHT);
    tableInformationDisplay.setVerticalAlignment(SwingConstants.TOP);
    tableInformationDisplay.setHorizontalAlignment(SwingConstants.RIGHT);

    headerImagePanel.add(UIHelper.wrapComponentInPanel(tableInformationDisplay));

    topContainer.add(headerImagePanel);
    topContainer.add(Box.createVerticalStrut(10));

    add(topContainer, BorderLayout.NORTH);

    // create central console with majority of content!
    createNavigationPanel();

    JPanel bottomContainer = new JPanel();
    bottomContainer.setLayout(new BoxLayout(bottomContainer, BoxLayout.PAGE_AXIS));
    bottomContainer.setBackground(UIHelper.BG_COLOR);

    add(bottomContainer, BorderLayout.SOUTH);

}

From source file:net.technicpack.launcher.ui.LauncherFrame.java

private void initComponents() {
    BorderLayout layout = new BorderLayout();
    setLayout(layout);/*from   www. ja  v a  2 s.com*/

    /////////////////////////////////////////////////////////////
    //HEADER
    /////////////////////////////////////////////////////////////
    JPanel header = new JPanel();
    header.setLayout(new BoxLayout(header, BoxLayout.LINE_AXIS));
    header.setBackground(COLOR_BLUE);
    header.setForeground(COLOR_WHITE_TEXT);
    header.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 10));
    this.add(header, BorderLayout.PAGE_START);

    ImageIcon headerIcon = resources.getIcon("platform_icon_title.png");
    JButton headerLabel = new JButton(headerIcon);
    headerLabel.setBorder(BorderFactory.createEmptyBorder(5, 8, 5, 0));
    headerLabel.setContentAreaFilled(false);
    headerLabel.setFocusPainted(false);
    headerLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    headerLabel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            DesktopUtils.browseUrl("http://beta.technicpack.net/");
        }
    });
    header.add(headerLabel);

    header.add(Box.createRigidArea(new Dimension(6, 0)));

    ActionListener tabListener = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            selectTab(e.getActionCommand());
        }
    };

    discoverTab = new HeaderTab(resources.getString("launcher.title.discover"), resources);
    header.add(discoverTab);
    discoverTab.setActionCommand(TAB_DISCOVER);
    discoverTab.addActionListener(tabListener);

    modpacksTab = new HeaderTab(resources.getString("launcher.title.modpacks"), resources);
    modpacksTab.setIsActive(true);
    modpacksTab.setHorizontalTextPosition(SwingConstants.LEADING);
    modpacksTab.addActionListener(tabListener);
    modpacksTab.setActionCommand(TAB_MODPACKS);
    header.add(modpacksTab);

    newsTab = new HeaderTab(resources.getString("launcher.title.news"), resources);
    newsTab.setLayout(null);
    newsTab.addActionListener(tabListener);
    newsTab.setActionCommand(TAB_NEWS);
    header.add(newsTab);

    CountCircle newsCircle = new CountCircle();
    newsCircle.setBackground(COLOR_RED);
    newsCircle.setForeground(COLOR_WHITE_TEXT);
    newsCircle.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS_BOLD, 14));
    newsTab.add(newsCircle);
    newsCircle.setBounds(10, 17, 25, 25);

    header.add(Box.createHorizontalGlue());

    JPanel rightHeaderPanel = new JPanel();
    rightHeaderPanel.setOpaque(false);
    rightHeaderPanel.setLayout(new BoxLayout(rightHeaderPanel, BoxLayout.PAGE_AXIS));
    rightHeaderPanel.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0));

    JPanel windowGadgetPanel = new JPanel();
    windowGadgetPanel.setOpaque(false);
    windowGadgetPanel.setLayout(new BoxLayout(windowGadgetPanel, BoxLayout.LINE_AXIS));
    windowGadgetPanel.setAlignmentX(RIGHT_ALIGNMENT);

    ImageIcon minimizeIcon = resources.getIcon("minimize.png");
    JButton minimizeButton = new JButton(minimizeIcon);
    minimizeButton.setBorder(BorderFactory.createEmptyBorder());
    minimizeButton.setContentAreaFilled(false);
    minimizeButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    minimizeButton.setFocusable(false);
    minimizeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            minimizeWindow();
        }
    });
    windowGadgetPanel.add(minimizeButton);

    ImageIcon closeIcon = resources.getIcon("close.png");
    JButton closeButton = new JButton(closeIcon);
    closeButton.setBorder(BorderFactory.createEmptyBorder());
    closeButton.setContentAreaFilled(false);
    closeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            closeWindow();
        }
    });
    closeButton.setCursor(new Cursor(Cursor.HAND_CURSOR));
    closeButton.setFocusable(false);
    windowGadgetPanel.add(closeButton);

    rightHeaderPanel.add(windowGadgetPanel);
    rightHeaderPanel.add(Box.createVerticalGlue());

    JButton launcherOptionsLabel = new JButton(resources.getString("launcher.title.options"));
    launcherOptionsLabel.setIcon(resources.getIcon("options_cog.png"));
    launcherOptionsLabel.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 14));
    launcherOptionsLabel.setForeground(COLOR_WHITE_TEXT);
    launcherOptionsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
    launcherOptionsLabel.setHorizontalTextPosition(SwingConstants.LEADING);
    launcherOptionsLabel.setAlignmentX(RIGHT_ALIGNMENT);
    launcherOptionsLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    launcherOptionsLabel.setBorder(BorderFactory.createEmptyBorder());
    launcherOptionsLabel.setContentAreaFilled(false);
    launcherOptionsLabel.setFocusPainted(false);
    launcherOptionsLabel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            openLauncherOptions();
        }
    });
    rightHeaderPanel.add(launcherOptionsLabel);

    header.add(rightHeaderPanel);

    /////////////////////////////////////////////////////////////
    // CENTRAL AREA
    /////////////////////////////////////////////////////////////
    centralPanel = new TintablePanel();
    centralPanel.setBackground(COLOR_CHARCOAL);
    centralPanel.setForeground(COLOR_WHITE_TEXT);
    centralPanel.setTintColor(COLOR_CENTRAL_BACK);
    this.add(centralPanel, BorderLayout.CENTER);
    centralPanel.setLayout(new BorderLayout());

    modpackPanel = new ModpackInfoPanel(resources, iconRepo, logoRepo, backgroundRepo, avatarRepo,
            new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    openModpackOptions((ModpackModel) e.getSource());
                }
            }, new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    refreshModpackOptions((ModpackModel) e.getSource());
                }
            });
    modpackSelector.setInfoPanel(modpackPanel);
    playButton = modpackPanel.getPlayButton();
    playButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() instanceof ModpackModel) {
                setupPlayButtonText((ModpackModel) e.getSource(), userModel.getCurrentUser());
            } else if (installer.isCurrentlyRunning()) {
                installer.cancel();
                setupPlayButtonText(modpackSelector.getSelectedPack(), userModel.getCurrentUser());
            } else {
                launchModpack();
            }
        }
    });

    modpackPanel.getDeleteButton().addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (JOptionPane.showConfirmDialog(LauncherFrame.this,
                    resources.getString("modpackoptions.delete.confirmtext"),
                    resources.getString("modpackoptions.delete.confirmtitle"),
                    JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
                modpackSelector.getSelectedPack().delete();
                modpackSelector.forceRefresh();
            }
        }
    });

    infoSwap = new JPanel();
    infoLayout = new CardLayout();
    infoSwap.setLayout(infoLayout);
    infoSwap.setOpaque(false);
    newsInfoPanel = new NewsInfoPanel(resources, avatarRepo);
    infoSwap.add(discoverInfoPanel, "discover");

    JPanel newsHost = new JPanel();
    infoSwap.add(newsHost, "news");
    JPanel modpackHost = new JPanel();
    infoSwap.add(modpackHost, "modpacks");
    centralPanel.add(infoSwap, BorderLayout.CENTER);

    newsSelector = new NewsSelector(resources, newsInfoPanel, platformApi, avatarRepo, newsCircle, settings);
    newsHost.setLayout(new BorderLayout());
    newsHost.add(newsInfoPanel, BorderLayout.CENTER);
    newsHost.add(newsSelector, BorderLayout.WEST);

    modpackHost.setLayout(new BorderLayout());
    modpackHost.add(modpackPanel, BorderLayout.CENTER);
    modpackHost.add(modpackSelector, BorderLayout.WEST);

    footer = new TintablePanel();
    footer.setTintColor(COLOR_CENTRAL_BACK);
    footer.setBackground(COLOR_FOOTER);
    footer.setLayout(new BoxLayout(footer, BoxLayout.LINE_AXIS));
    footer.setForeground(COLOR_WHITE_TEXT);
    footer.setBorder(BorderFactory.createEmptyBorder(3, 6, 3, 12));

    userWidget = new UserWidget(resources, skinRepository);
    userWidget.setMaximumSize(userWidget.getPreferredSize());
    footer.add(userWidget);

    JLabel dashText = new JLabel("| ");
    dashText.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    dashText.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15));
    footer.add(dashText);

    JButton logout = new JButton(resources.getString("launcher.user.logout"));
    logout.setBorder(BorderFactory.createEmptyBorder());
    logout.setContentAreaFilled(false);
    logout.setFocusable(false);
    logout.setForeground(LauncherFrame.COLOR_WHITE_TEXT);
    logout.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    logout.setFont(resources.getFont(ResourceLoader.FONT_RALEWAY, 15));
    logout.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            logout();
        }
    });
    footer.add(logout);

    installProgress = new ProgressBar();
    installProgress.setForeground(Color.white);
    installProgress.setBackground(LauncherFrame.COLOR_GREEN);
    installProgress.setBorder(BorderFactory.createEmptyBorder(5, 45, 4, 45));
    installProgress.setIcon(resources.getIcon("download_icon.png"));
    installProgress.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 12));
    installProgress.setVisible(false);
    footer.add(installProgress);

    installProgressPlaceholder = Box.createHorizontalGlue();
    footer.add(installProgressPlaceholder);

    JLabel buildCtrl = new JLabel(resources.getString("launcher.build.text", resources.getLauncherBuild(),
            resources.getString("launcher.build." + settings.getBuildStream())));
    buildCtrl.setForeground(COLOR_WHITE_TEXT);
    buildCtrl.setFont(resources.getFont(ResourceLoader.FONT_OPENSANS, 14));
    buildCtrl.setHorizontalTextPosition(SwingConstants.RIGHT);
    buildCtrl.setHorizontalAlignment(SwingConstants.RIGHT);
    footer.add(buildCtrl);

    this.add(footer, BorderLayout.PAGE_END);
}

From source file:pt.lsts.neptus.plugins.sunfish.awareness.SituationAwareness.java

@Override
public void mouseClicked(MouseEvent event, final StateRenderer2D source) {

    if (event.getButton() == MouseEvent.BUTTON3) {
        final LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType();
        JPopupMenu popup = new JPopupMenu();
        for (String type : positions.keySet()) {
            JMenu menu = new JMenu(type + "s");
            for (final AssetPosition p : positions.get(type)) {

                if (p.getTimestamp() < oldestTimestampSelection || p.getTimestamp() > newestTimestampSelection)
                    continue;

                Color c = cmap.getColor(1 - (p.getAge() / (7200000.0)));
                String htmlColor = String.format("#%02X%02X%02X", c.getRed(), c.getGreen(), c.getBlue());
                menu.add("<html><b>" + p.getAssetName() + "</b> <font color=" + htmlColor + ">" + getAge(p)
                        + "</font>").addActionListener(new ActionListener() {
                            @Override
                            public void actionPerformed(ActionEvent e) {
                                source.focusLocation(p.getLoc());
                            }/*w  w w. j  a va  2 s . c  o  m*/
                        });
            }
            popup.add(menu);
        }

        popup.addSeparator();
        popup.add("Settings").addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                PluginUtils.editPluginProperties(SituationAwareness.this, true);
            }
        });

        popup.add("Fetch asset properties").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //                    for (AssetTrack track : assets.values()) {
                //                        track.setColor(new Color(random.nextInt(255), random.nextInt(255), random.nextInt(255)));
                //                    }
                fetchAssetProperties();
            }
        });

        popup.add("Select location sources").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                JPanel p = new JPanel();
                p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

                for (ILocationProvider l : localizers) {
                    JCheckBox check = new JCheckBox(l.getName());
                    check.setSelected(true);
                    p.add(check);
                    check.setSelected(updateMethodNames.contains(l.getName()));
                }

                int op = JOptionPane.showConfirmDialog(getConsole(), p, "Location update sources",
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (op == JOptionPane.CANCEL_OPTION)
                    return;

                Vector<String> methods = new Vector<String>();
                for (int i = 0; i < p.getComponentCount(); i++) {

                    if (p.getComponent(i) instanceof JCheckBox) {
                        JCheckBox sel = (JCheckBox) p.getComponent(i);
                        if (sel.isSelected())
                            methods.add(sel.getText());
                    }
                }
                updateMethods = StringUtils.join(methods, ", ");
                propertiesChanged();
            }
        });

        popup.add("Select hidden positions types").addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {

                JPanel p = new JPanel();
                p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));

                for (String type : positions.keySet()) {
                    JCheckBox check = new JCheckBox(type);
                    check.setSelected(true);
                    p.add(check);
                    check.setSelected(hiddenPosTypes.contains(type));
                }

                int op = JOptionPane.showConfirmDialog(getConsole(), p, "Position types to be hidden",
                        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
                if (op == JOptionPane.CANCEL_OPTION)
                    return;

                Vector<String> types = new Vector<String>();
                for (int i = 0; i < p.getComponentCount(); i++) {

                    if (p.getComponent(i) instanceof JCheckBox) {
                        JCheckBox sel = (JCheckBox) p.getComponent(i);
                        if (sel.isSelected())
                            types.add(sel.getText());
                    }
                }
                hiddenTypes = StringUtils.join(types, ", ");
                propertiesChanged();
            }
        });

        popup.addSeparator();
        popup.add("Decision Support").addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (dialogDecisionSupport == null) {
                    dialogDecisionSupport = new JDialog(getConsole());
                    dialogDecisionSupport.setModal(false);
                    dialogDecisionSupport.setAlwaysOnTop(true);
                    dialogDecisionSupport.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
                }
                ArrayList<AssetPosition> tags = new ArrayList<AssetPosition>();
                LinkedHashMap<String, Vector<AssetPosition>> positions = positionsByType();
                Vector<AssetPosition> spots = positions.get("SPOT Tag");
                Vector<AssetPosition> argos = positions.get("Argos Tag");
                if (spots != null)
                    tags.addAll(spots);
                if (argos != null)
                    tags.addAll(argos);
                if (!assets.containsKey(getConsole().getMainSystem())) {
                    GuiUtils.errorMessage(getConsole(), "Decision Support", "UUV asset position is unknown");
                    return;
                }
                supportTable.setAssets(assets.get(getConsole().getMainSystem()).getLatest(), tags);
                JXTable table = new JXTable(supportTable);
                dialogDecisionSupport.setContentPane(new JScrollPane(table));
                dialogDecisionSupport.invalidate();
                dialogDecisionSupport.validate();
                dialogDecisionSupport.setSize(600, 300);
                dialogDecisionSupport.setTitle("Decision Support Table");
                dialogDecisionSupport.setVisible(true);
                dialogDecisionSupport.toFront();
                GuiUtils.centerOnScreen(dialogDecisionSupport);
            }
        });
        popup.show(source, event.getX(), event.getY());
    }
    super.mouseClicked(event, source);
}

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private JPanel createTableListPanel() {

    JPanel container = new JPanel();
    container.setBackground(UIHelper.BG_COLOR);
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    JLabel lab = new JLabel(tableListTitle);

    container.add(UIHelper.wrapComponentInPanel(lab));
    container.add(Box.createVerticalStrut(5));

    tableModel = new DefaultListModel();
    tableList = new JList(tableModel);
    tableList.setCellRenderer(new TableListRenderer());
    tableList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    tableList.setBackground(UIHelper.BG_COLOR);
    tableList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            try {
                saveCurrentField(false, false);
            } catch (DataNotCompleteException dce) {
                showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE);
            }//from w ww.jav a2  s .  co  m

            MappingObject currentlyEditedTable = getCurrentlySelectedTable();
            ApplicationManager.setCurrentMappingObject(currentlyEditedTable);

            // update the view error button visibility depending on selected tables error state.
            viewErrorsButton.setVisible(areThereErrorsInThisCurrentObject());

            updateTableInfoDisplay(currentlyEditedTable);
            reformFieldList(currentlyEditedTable);
        }
    });

    JScrollPane listScroller = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    listScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    listScroller.setBorder(null);
    listScroller.setPreferredSize(new Dimension(((int) (WIDTH * 0.25)), ((int) (HEIGHT * 0.75))));

    IAppWidgetFactory.makeIAppScrollPane(listScroller);

    container.add(listScroller);
    container.add(Box.createVerticalStrut(5));

    tableCountInfo = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR);
    container.add(UIHelper.wrapComponentInPanel(tableCountInfo));
    container.add(Box.createVerticalStrut(5));

    // create button panel to add and remove tables
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.setBackground(UIHelper.BG_COLOR);

    final JLabel addTableButton = new JLabel(addTable, JLabel.LEFT);
    UIHelper.renderComponent(addTableButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    addTableButton.setOpaque(false);

    addTableButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            addTableButton.setIcon(addTableOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            addTableButton.setIcon(addTable);
        }

        public void mousePressed(MouseEvent event) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    addTableButton.setIcon(addTable);
                    applicationContainer.showJDialogAsSheet(addTableUI);
                }
            });

        }

    });

    addTableButton.setToolTipText("<html><b>Add table</b><p>Add a new table definition.</p></html>");

    final JLabel removeTableButton = new JLabel(removeTable, JLabel.LEFT);
    UIHelper.renderComponent(removeTableButton, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    removeTableButton.setOpaque(false);

    removeTableButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            removeTableButton.setIcon(removeTableOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            removeTableButton.setIcon(removeTable);
        }

        public void mousePressed(MouseEvent event) {
            removeTableButton.setIcon(removeTable);
            if (tableList.getSelectedValue() != null) {
                String selectedTable = tableList.getSelectedValue().toString();
                MappingObject toRemove = null;
                for (MappingObject mo : tableFields.keySet()) {
                    if (mo.getAssayName().equals(selectedTable)) {
                        toRemove = mo;
                        break;
                    }
                }

                if (toRemove != null) {
                    tableFields.remove(toRemove);
                    reformTableList();
                }
            }
        }

    });

    removeTableButton.setToolTipText("<html><b>Remove table</b><p>Remove table from definitions?</p></html>");

    viewErrorsButton = new JLabel(viewErrorsIcon);
    viewErrorsButton.setVisible(false);
    viewErrorsButton.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent mouseEvent) {
            viewErrorsButton.setIcon(viewErrorsIcon);
            // show error pane for current table only.

            Validator validator = new Validator();
            validateFormOrTable(validator, ApplicationManager.getCurrentMappingObject());

            ValidationReport report = validator.getReport();

            ConfigurationValidationUI validationUI = new ConfigurationValidationUI(tableFields.keySet(),
                    report);
            validationUI.createGUI();
            validationUI.setLocationRelativeTo(getApplicationContainer());
            validationUI.setAlwaysOnTop(true);
            validationUI.setVisible(true);
        }

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            viewErrorsButton.setIcon(viewErrorsIconOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            viewErrorsButton.setIcon(viewErrorsIcon);
        }
    });

    buttonPanel.add(addTableButton);
    buttonPanel.add(removeTableButton);
    buttonPanel.add(viewErrorsButton);
    buttonPanel.add(Box.createHorizontalGlue());

    container.add(buttonPanel);

    container.add(Box.createVerticalGlue());

    return container;
}

From source file:Converter.java

ConversionPanel(Converter myController, String myTitle, Unit[] myUnits, ConverterRangeModel myModel) {
    if (MULTICOLORED) {
        setOpaque(true);/*from www . j av  a  2  s. c  o m*/
        setBackground(new Color(0, 255, 255));
    }
    setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(myTitle),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Save arguments in instance variables.
    controller = myController;
    units = myUnits;
    title = myTitle;
    sliderModel = myModel;

    // Create the text field format, and then the text field.
    numberFormat = NumberFormat.getNumberInstance();
    numberFormat.setMaximumFractionDigits(2);
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    formatter.setAllowsInvalid(false);
    formatter.setCommitsOnValidEdit(true);// seems to be a no-op --
    // aha -- it changes the value property but doesn't cause the result to
    // be parsed (that happens on focus loss/return, I think).
    //
    textField = new JFormattedTextField(formatter);
    textField.setColumns(10);
    textField.setValue(new Double(sliderModel.getDoubleValue()));
    textField.addPropertyChangeListener(this);

    // Add the combo box.
    unitChooser = new JComboBox();
    for (int i = 0; i < units.length; i++) { // Populate it.
        unitChooser.addItem(units[i].description);
    }
    unitChooser.setSelectedIndex(0);
    sliderModel.setMultiplier(units[0].multiplier);
    unitChooser.addActionListener(this);

    // Add the slider.
    slider = new JSlider(sliderModel);
    sliderModel.addChangeListener(this);

    // Make the text field/slider group a fixed size
    // to make stacked ConversionPanels nicely aligned.
    JPanel unitGroup = new JPanel() {
        public Dimension getMinimumSize() {
            return getPreferredSize();
        }

        public Dimension getPreferredSize() {
            return new Dimension(150, super.getPreferredSize().height);
        }

        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    unitGroup.setLayout(new BoxLayout(unitGroup, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
        unitGroup.setOpaque(true);
        unitGroup.setBackground(new Color(0, 0, 255));
    }
    unitGroup.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 5));
    unitGroup.add(textField);
    unitGroup.add(slider);

    // Create a subpanel so the combo box isn't too tall
    // and is sufficiently wide.
    JPanel chooserPanel = new JPanel();
    chooserPanel.setLayout(new BoxLayout(chooserPanel, BoxLayout.PAGE_AXIS));
    if (MULTICOLORED) {
        chooserPanel.setOpaque(true);
        chooserPanel.setBackground(new Color(255, 0, 255));
    }
    chooserPanel.add(unitChooser);
    chooserPanel.add(Box.createHorizontalStrut(100));

    // Put everything together.
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
    add(unitGroup);
    add(chooserPanel);
    unitGroup.setAlignmentY(TOP_ALIGNMENT);
    chooserPanel.setAlignmentY(TOP_ALIGNMENT);
}

From source file:lcmc.common.ui.EditableInfo.java

/**
 * Creates panel with border and title for parameters with specified
 * background.//from   w  w  w  . j  av a 2s .c  om
 */
protected final JPanel getParamPanel(final String title, final Color background) {
    final JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.setBackground(background);
    final TitledBorder titleBorder = Tools.getBorder(title);
    panel.setBorder(titleBorder);
    return panel;
}

From source file:jp.massbank.spectrumsearch.SearchPage.java

/**
 * ?/*  w  ww.  j  av a  2  s . com*/
 */
private void createWindow() {

    // ??
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.setInitialDelay(50);
    ttm.setDismissDelay(8000);

    // Search?
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(),
            new EmptyBorder(1, 1, 1, 1));
    mainPanel.setBorder(border);

    // *********************************************************************
    // User File Query
    // *********************************************************************
    DefaultTableModel fileDm = new DefaultTableModel();
    fileSorter = new TableSorter(fileDm, TABLE_QUERY_FILE);
    queryFileTable = new JTable(fileSorter) {
        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    queryFileTable.addMouseListener(new TblMouseListener());
    fileSorter.setTableHeader(queryFileTable.getTableHeader());
    queryFileTable.setRowSelectionAllowed(true);
    queryFileTable.setColumnSelectionAllowed(false);
    queryFileTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col = { COL_LABEL_NO, COL_LABEL_NAME, COL_LABEL_ID };
    ((DefaultTableModel) fileSorter.getTableModel()).setColumnIdentifiers(col);
    (queryFileTable.getColumn(queryFileTable.getColumnName(0))).setPreferredWidth(44);
    (queryFileTable.getColumn(queryFileTable.getColumnName(1))).setPreferredWidth(LEFT_PANEL_WIDTH - 44);
    (queryFileTable.getColumn(queryFileTable.getColumnName(2))).setPreferredWidth(70);

    ListSelectionModel lm = queryFileTable.getSelectionModel();
    lm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lm.addListSelectionListener(new LmFileListener());
    queryFilePane = new JScrollPane(queryFileTable);
    queryFilePane.addMouseListener(new PaneMouseListener());
    queryFilePane.setPreferredSize(new Dimension(300, 300));

    // *********************************************************************
    // Result
    // *********************************************************************
    DefaultTableModel resultDm = new DefaultTableModel();
    resultSorter = new TableSorter(resultDm, TABLE_RESULT);
    resultTable = new JTable(resultSorter) {
        @Override
        public String getToolTipText(MouseEvent me) {
            //            super.getToolTipText(me);
            // ?????
            Point pt = me.getPoint();
            int row = rowAtPoint(pt);
            if (row < 0) {
                return null;
            } else {
                int nameCol = getColumnModel().getColumnIndex(COL_LABEL_NAME);
                return " " + getValueAt(row, nameCol) + " ";
            }
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    resultTable.addMouseListener(new TblMouseListener());
    resultSorter.setTableHeader(resultTable.getTableHeader());

    JPanel dbPanel = new JPanel();
    dbPanel.setLayout(new BorderLayout());
    resultPane = new JScrollPane(resultTable);
    resultPane.addMouseListener(new PaneMouseListener());

    resultTable.setRowSelectionAllowed(true);
    resultTable.setColumnSelectionAllowed(false);
    resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col2 = { COL_LABEL_NAME, COL_LABEL_SCORE, COL_LABEL_HIT, COL_LABEL_ID, COL_LABEL_ION,
            COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };

    resultDm.setColumnIdentifiers(col2);
    (resultTable.getColumn(resultTable.getColumnName(0))).setPreferredWidth(LEFT_PANEL_WIDTH - 180);
    (resultTable.getColumn(resultTable.getColumnName(1))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(2))).setPreferredWidth(20);
    (resultTable.getColumn(resultTable.getColumnName(3))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(4))).setPreferredWidth(20);
    (resultTable.getColumn(resultTable.getColumnName(5))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(6))).setPreferredWidth(50);

    ListSelectionModel lm2 = resultTable.getSelectionModel();
    lm2.addListSelectionListener(new LmResultListener());

    resultPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, 200));
    dbPanel.add(resultPane, BorderLayout.CENTER);

    // *********************************************************************
    // DB Query
    // *********************************************************************
    DefaultTableModel dbDm = new DefaultTableModel();
    querySorter = new TableSorter(dbDm, TABLE_QUERY_DB);
    queryDbTable = new JTable(querySorter) {
        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    queryDbTable.addMouseListener(new TblMouseListener());
    querySorter.setTableHeader(queryDbTable.getTableHeader());
    queryDbPane = new JScrollPane(queryDbTable);
    queryDbPane.addMouseListener(new PaneMouseListener());

    int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
    queryDbPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, h));
    queryDbTable.setRowSelectionAllowed(true);
    queryDbTable.setColumnSelectionAllowed(false);
    queryDbTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col3 = { COL_LABEL_ID, COL_LABEL_NAME, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };
    DefaultTableModel model = (DefaultTableModel) querySorter.getTableModel();
    model.setColumnIdentifiers(col3);

    // 
    queryDbTable.getColumn(queryDbTable.getColumnName(0)).setPreferredWidth(70);
    queryDbTable.getColumn(queryDbTable.getColumnName(1)).setPreferredWidth(LEFT_PANEL_WIDTH - 70);
    queryDbTable.getColumn(queryDbTable.getColumnName(2)).setPreferredWidth(70);
    queryDbTable.getColumn(queryDbTable.getColumnName(3)).setPreferredWidth(50);

    ListSelectionModel lm3 = queryDbTable.getSelectionModel();
    lm3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lm3.addListSelectionListener(new LmQueryDbListener());

    // ?
    JPanel btnPanel = new JPanel();
    btnName.addActionListener(new BtnSearchNameListener());
    btnAll.addActionListener(new BtnAllListener());
    btnPanel.add(btnName);
    btnPanel.add(btnAll);

    parentPanel2 = new JPanel();
    parentPanel2.setLayout(new BoxLayout(parentPanel2, BoxLayout.PAGE_AXIS));
    parentPanel2.add(btnPanel);
    parentPanel2.add(queryDbPane);

    // ?
    JPanel dispModePanel = new JPanel();
    isDispSelected = dispSelected.isSelected();
    isDispRelated = dispRelated.isSelected();
    if (isDispSelected) {
        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    } else if (isDispRelated) {
        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    Object[] retRadio = new Object[] { dispSelected, dispRelated };
    for (int i = 0; i < retRadio.length; i++) {
        ((JRadioButton) retRadio[i]).addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if (isDispSelected != dispSelected.isSelected() || isDispRelated != dispRelated.isSelected()) {

                    isDispSelected = dispSelected.isSelected();
                    isDispRelated = dispRelated.isSelected();

                    // ??
                    resultTable.clearSelection();
                    resultPlot.clear();
                    compPlot.setPeaks(null, 1);
                    resultPlot.setPeaks(null, 0);
                    setAllPlotAreaRange();
                    pkgView.initResultRecInfo();

                    if (isDispSelected) {
                        resultTable.getSelectionModel()
                                .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                    } else if (isDispRelated) {
                        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    }
                }
            }
        });
    }
    ButtonGroup disGroup = new ButtonGroup();
    disGroup.add(dispSelected);
    disGroup.add(dispRelated);
    dispModePanel.add(lbl2);
    dispModePanel.add(dispSelected);
    dispModePanel.add(dispRelated);

    JPanel paramPanel = new JPanel();
    paramPanel.add(etcPropertyButton);
    etcPropertyButton.setMargin(new Insets(0, 10, 0, 10));
    etcPropertyButton.addActionListener(new ActionListener() {
        private ParameterSetWindow ps = null;

        public void actionPerformed(ActionEvent e) {
            // ??????????
            if (!isSubWindow) {
                ps = new ParameterSetWindow(getParentFrame());
            } else {
                ps.requestFocus();
            }
        }
    });

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(dispModePanel);
    optionPanel.add(paramPanel);

    // PackageView?????
    pkgView = new PackageViewPanel();
    pkgView.initAllRecInfo();

    queryTabPane.addTab("DB", parentPanel2);
    queryTabPane.setToolTipTextAt(TAB_ORDER_DB, "Query from DB.");
    queryTabPane.addTab("File", queryFilePane);
    queryTabPane.setToolTipTextAt(TAB_ORDER_FILE, "Query from user file.");
    queryTabPane.setSelectedIndex(TAB_ORDER_DB);
    queryTabPane.setFocusable(false);
    queryTabPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {

            // ?
            queryPlot.clear();
            compPlot.clear();
            resultPlot.clear();
            queryPlot.setPeaks(null, 0);
            compPlot.setPeaks(null, 1);
            resultPlot.setPeaks(null, 0);

            // PackageView?
            pkgView.initAllRecInfo();

            // DB Hit?
            if (resultTabPane.getTabCount() > 0) {
                resultTabPane.setSelectedIndex(0);
            }
            DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel();
            dataModel.setRowCount(0);
            hitLabel.setText(" ");

            // DB?User File??????
            queryTabPane.update(queryTabPane.getGraphics());
            if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) {
                parentPanel2.update(parentPanel2.getGraphics());
                updateSelectQueryTable(queryDbTable);
            } else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) {
                queryFilePane.update(queryFilePane.getGraphics());
                updateSelectQueryTable(queryFileTable);
            }
        }
    });

    //       
    JPanel queryPanel = new JPanel();
    queryPanel.setLayout(new BorderLayout());
    queryPanel.add(queryTabPane, BorderLayout.CENTER);
    queryPanel.add(optionPanel, BorderLayout.SOUTH);
    queryPanel.setMinimumSize(new Dimension(0, 170));

    JPanel jtp2Panel = new JPanel();
    jtp2Panel.setLayout(new BorderLayout());
    jtp2Panel.add(dbPanel, BorderLayout.CENTER);
    jtp2Panel.add(hitLabel, BorderLayout.SOUTH);
    jtp2Panel.setMinimumSize(new Dimension(0, 70));
    Color colorGreen = new Color(0, 128, 0);
    hitLabel.setForeground(colorGreen);

    resultTabPane.addTab("Result", jtp2Panel);
    resultTabPane.setToolTipTextAt(TAB_RESULT_DB, "Result of DB hit.");
    resultTabPane.setFocusable(false);

    queryPlot.setMinimumSize(new Dimension(0, 100));
    compPlot.setMinimumSize(new Dimension(0, 120));
    resultPlot.setMinimumSize(new Dimension(0, 100));
    int height = initAppletHight / 3;
    JSplitPane jsp_cmp2db = new JSplitPane(JSplitPane.VERTICAL_SPLIT, compPlot, resultPlot);
    JSplitPane jsp_qry2cmp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPlot, jsp_cmp2db);
    jsp_cmp2db.setDividerLocation(height);
    jsp_qry2cmp.setDividerLocation(height - 25);
    jsp_qry2cmp.setMinimumSize(new Dimension(190, 0));

    viewTabPane.addTab("Compare View", jsp_qry2cmp);
    viewTabPane.addTab("Package View", pkgView);
    viewTabPane.setToolTipTextAt(TAB_VIEW_COMPARE, "Comparison of query and result spectrum.");
    viewTabPane.setToolTipTextAt(TAB_VIEW_PACKAGE, "Package comparison of query and result spectrum.");
    viewTabPane.setSelectedIndex(TAB_VIEW_COMPARE);
    viewTabPane.setFocusable(false);

    JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPanel, resultTabPane);
    jsp.setDividerLocation(310);
    jsp.setMinimumSize(new Dimension(180, 0));
    jsp.setOneTouchExpandable(true);

    JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp, viewTabPane);
    int divideSize = (int) (initAppletWidth * 0.4);
    divideSize = (divideSize >= 180) ? divideSize : 180;
    jsp2.setDividerLocation(divideSize);
    jsp2.setOneTouchExpandable(true);

    mainPanel.add(jsp2, BorderLayout.CENTER);
    add(mainPanel);

    queryPlot.setSearchPage(this);
    compPlot.setSearchPage(this);
    resultPlot.setSearchPage(this);

    setJMenuBar(MenuBarGenerator.generateMenuBar(this));
}

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

private void setSliders() {
    if (sliderPanel != null)
        sliderPanel.removeAll();/*from www  . j av a2  s.c  om*/
    else
        sliderPanel = new JPanel();

    JPanel rPanel = new JPanel();
    // rPanel.setBackground(Color.blue);
    JPanel rPanel2 = new JPanel();
    // rPanel2.setBackground(Color.green);
    rPanel.setAlignmentX(LEFT_ALIGNMENT);
    rPanel2.setAlignmentX(LEFT_ALIGNMENT);

    rSliders = new FloatTextField[numStocks]; //expected return

    JPanel matrixPanel = new JPanel();
    matrixPanel.setAlignmentX(LEFT_ALIGNMENT);
    mSliders = new FloatTextField[15];

    JPanel tPanel = new JPanel();
    tPanel.setAlignmentX(LEFT_ALIGNMENT);
    //   tPanel.setBackground(Color.blue);

    //tSlider = new ValueSliderFloat2("Tangency:", -0.5, 0.5, false);
    tSlider = new FloatTextField("Tangency:", t1_y, 0, 1);
    //tSlider.setPreferredSize(new Dimension(SLIDER_SIZE_X,45));

    newMSlider(1, 0, tSlider, tPanel);

    //expected return
    rPanel.setLayout(new GridBagLayout());
    rPanel.add(new JLabel("Expected Return:"));
    for (int i = 0; i < numStocks; i++) {
        rSliders[i] = new FloatTextField("E(R" + (i + 1) + ")", ExpectedReturn[i][0], -0.2, 0.2);
        rSliders[i].setPreferredSize(new Dimension(SLIDER_SIZE_X / numStocks, 45));
        rSliders[i].setToolTipText("Adjusting the value of expected return for stock " + (i + 1) + ".");
        newMSlider(1, i, rSliders[i], rPanel);
    }

    ER_matrix = new Matrix(numStocks, 1, ExpectedReturn);

    // Covariance
    rPanel2.setLayout(new GridBagLayout());
    rPanel2.add(new JLabel("Variance:"));
    for (int i = 0; i < numStocks; i++) {
        mSliders[i] = new FloatTextField("VAR(R" + (i + 1) + ")", COVR[i][i], 0.0, 0.2);
        mSliders[i].setPreferredSize(new Dimension(SLIDER_SIZE_X / numStocks, 45));
        mSliders[i].setToolTipText("Adjusting the value of variance " + (i + 1) + ".");
        newMSlider(1, i, mSliders[i], rPanel2);
    }

    matrixPanel.setLayout(new GridBagLayout());

    if (covarianceFlag)
        addRadioButton(0, 0, "Switch Input Matrix:", "Switch Input Matrix", switchArray, 0, matrixPanel,
                (ActionListener) this);
    else
        addRadioButton(0, 0, "Switch Input Matrix:", "Switch Input Matrix", switchArray, 1, matrixPanel,
                (ActionListener) this);
    switchedFlag = false;

    if (covarianceFlag) {
        // matrixPanel.add(new JLabel("Covariance Matrix:"));

        int k = numStocks;
        for (int i = 1; i < numStocks; i++)
            for (int j = 0; j < i; j++) {
                mSliders[k] = new FloatTextField("COV" + (i + 1) + (j + 1), COVR[i][j], -0.5, 0.5);
                mSliders[k].setPreferredSize(new Dimension(SLIDER_SIZE_X / numStocks, 45));
                mSliders[k]
                        .setToolTipText("Adjusting the value of correlation " + (i + 1) + "," + (j + 1) + ".");
                newMSlider(i, j, mSliders[k], matrixPanel);

                k++;
            }
    } else {
        //   matrixPanel.add(new JLabel("Correlation Matrix:"));
        int k = numStocks;
        for (int i = 1; i < numStocks; i++)
            for (int j = 0; j < i; j++) {
                mSliders[k] = new FloatTextField("CORR" + (i + 1) + (j + 1), CORR[i][j], -0.5, 0.5);
                mSliders[k].setPreferredSize(new Dimension(SLIDER_SIZE_X / numStocks, 45));
                mSliders[k]
                        .setToolTipText("Adjusting the value of correlation " + (i + 1) + "," + (j + 1) + ".");
                newMSlider(i, j, mSliders[k], matrixPanel);
                if (CORR[i][j] > 1)
                    System.out.println("setting slider CORR[" + i + "][" + j + "]=" + CORR[i][j]);

                k++;
            }
    }

    try {
        CORR = covr2corr(COVR, ExpectedReturn, numStocks);
    } catch (Exception e) {
        System.out.println("corrlation out of range.");
    }

    covr_matrix = new Matrix(numStocks, numStocks, COVR);
    corr_matrix = new Matrix(numStocks, numStocks, CORR);

    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);*/
    //sliderPanel.setBackground(Color.red);
    matrixPanel.validate();
    sliderPanel.add(rPanel);
    sliderPanel.add(rPanel2);
    sliderPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    sliderPanel.add(matrixPanel);
    sliderPanel.add(tPanel);
    sliderPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    sliderPanel.validate();
    //sliderPanel.setBackground(Color.white);
}

From source file:org.jdal.swing.PageableTable.java

/**
 * Create a new VisiblityBox initialized with column descriptors
 * @param columnDescriptors column descriptors
 *///from  w w  w .  j  a  va  2 s  .  co  m
public VisibilityBox(List<ColumnDescriptor> columnDescriptors) {
    setColumnDescriptors(columnDescriptors);
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    for (ColumnDescriptor cd : this.columnDescriptors) {
        add(new VisibilityItem(cd));
    }
}

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private JPanel createFieldListPanel() {

    JPanel container = new JPanel();
    container.setBackground(UIHelper.BG_COLOR);
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    JPanel headerLab = new JPanel(new GridLayout(1, 1));
    headerLab.setOpaque(false);//w ww  . ja v a2  s .c o m

    JLabel lab = new JLabel(fieldListTitle);
    headerLab.add(lab);

    container.add(headerLab);
    container.add(Box.createVerticalStrut(5));

    elementModel = new DefaultListModel();
    elementList = new ReOrderableJList(elementModel);
    elementList.setCellRenderer(new CustomReOrderableListCellRenderer(elementList));
    elementList.setDragEnabled(true);
    elementList.setBackground(UIHelper.BG_COLOR);

    elementList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            Display selectedNode = (Display) elementList.getSelectedValue();
            if (selectedNode != null) {
                try {
                    saveCurrentField(false, false);
                } catch (DataNotCompleteException dce) {
                    showMessagePane(dce.getMessage(), JOptionPane.ERROR_MESSAGE);
                }
                if (selectedNode instanceof FieldElement) {
                    fieldInterface.setCurrentField((FieldElement) selectedNode);
                    if (currentPage != fieldInterface) {
                        setCurrentPage(fieldInterface);
                    }
                    removeElementButton.setEnabled(!standardISAFields.isFieldRequired(selectedNode.toString()));
                } else {
                    setCurrentPage(structureElement);
                }
            }
        }
    });

    elementList.addPropertyChangeListener("orderChanged", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            updateFieldOrder();

            if (tableList.getSelectedValue() instanceof MappingObject) {
                validateFormOrTable(ApplicationManager.getCurrentMappingObject());
            }
        }
    });

    JScrollPane listScroller = new JScrollPane(elementList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    listScroller.getViewport().setBackground(UIHelper.BG_COLOR);
    listScroller.setBorder(new EmptyBorder(2, 2, 2, 10));
    listScroller.setPreferredSize(new Dimension(((int) (WIDTH * 0.25)), ((int) (HEIGHT * 0.75))));
    IAppWidgetFactory.makeIAppScrollPane(listScroller);

    container.add(listScroller);
    container.add(Box.createVerticalStrut(5));

    elementCountInfo = UIHelper.createLabel("", UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR);

    container.add(UIHelper.wrapComponentInPanel(elementCountInfo));
    container.add(Box.createVerticalStrut(5));

    // create button panel to add and remove tables
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.LINE_AXIS));
    buttonPanel.setBackground(UIHelper.BG_COLOR);

    final JLabel addFieldButton = new JLabel(addElement, JLabel.LEFT);
    addFieldButton.setOpaque(false);

    addFieldButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            addFieldButton.setIcon(addElementOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            addFieldButton.setIcon(addElement);
        }

        public void mousePressed(MouseEvent event) {
            addFieldButton.setIcon(addElement);
            showAddFieldUI();
        }

    });

    addFieldButton.setToolTipText(
            "<html><b>Add Field to table</b><p>Add a new field to currently selected table</b></p></html>");

    removeElementButton = new JLabel(removeElement, JLabel.LEFT);
    removeElementButton.setOpaque(false);

    removeElementButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            removeElementButton.setIcon(removeElementOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            removeElementButton.setIcon(removeElement);
        }

        public void mousePressed(MouseEvent event) {
            removeElementButton.setIcon(removeElement);
            if (removeElementButton.isEnabled()) {
                removeSelectedElement();
            }
        }

    });

    removeElementButton.setToolTipText(
            "<html><b>Remove Field from table</b><p>Remove this field from this list and the currently selected table.</b></p></html>");

    final JLabel moveDownButton = new JLabel(moveDown);
    moveDownButton.setOpaque(false);
    moveDownButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            moveDownButton.setIcon(moveDownOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            moveDownButton.setIcon(moveDown);
        }

        public void mousePressed(MouseEvent event) {
            moveDownButton.setIcon(moveDown);
            if (elementList.getSelectedIndex() != -1) {
                int toMoveDown = elementList.getSelectedIndex();

                if (toMoveDown != (elementModel.getSize() - 1)) {
                    swapElements(elementList, elementModel, toMoveDown, toMoveDown + 1);
                }

                updateFieldOrder();
                validateFormOrTable(ApplicationManager.getCurrentMappingObject());
            }
        }
    });

    moveDownButton.setToolTipText(
            "<html><b>Move Field Down</b><p>Move the selected field down <b>one</b> position in the list.</p></html>");

    final JLabel moveUpButton = new JLabel(moveUp);
    moveUpButton.setOpaque(false);
    moveUpButton.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseEntered(MouseEvent mouseEvent) {
            moveUpButton.setIcon(moveUpOver);
        }

        @Override
        public void mouseExited(MouseEvent mouseEvent) {
            moveUpButton.setIcon(moveUp);
        }

        public void mousePressed(MouseEvent event) {
            moveUpButton.setIcon(moveUp);
            if (elementList.getSelectedIndex() != -1) {
                int toMoveUp = elementList.getSelectedIndex();

                if (toMoveUp != 0) {
                    swapElements(elementList, elementModel, toMoveUp, toMoveUp - 1);
                }

                updateFieldOrder();
                validateFormOrTable(ApplicationManager.getCurrentMappingObject());

            }
        }

    });

    moveUpButton.setToolTipText(
            "<html><b>Move Field Up</b><p>Move the selected field up <b>one</b> position in the list.</p></html>");

    buttonPanel.add(addFieldButton);
    buttonPanel.add(removeElementButton);
    buttonPanel.add(moveDownButton);
    buttonPanel.add(moveUpButton);

    container.add(buttonPanel);

    container.add(Box.createVerticalGlue());

    return container;
}