Example usage for javax.swing JScrollPane setPreferredSize

List of usage examples for javax.swing JScrollPane setPreferredSize

Introduction

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

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

From source file:statistic.ca.gui.JCAStatisticPanel.java

private JPanel addPropertiesComponents() {
    JPanel p = new JPanel(new GridBagLayout());

    String[] statisticTypeNames = { "Grundinformationen", "Ausgangsverteilung", "Ankunftskurve",
            "evakuierte Individuen in Prozent", "maximale Blockadezeit", "durchschnittliche Blockadezeit",
            "minimale Blockadezeit", "zurckgelegte Distanz", "minimale Distanz zum initialen Ausgang",
            "minimale Distanz zum nchsten Ausgang", "Distanz ber Zeit", "maximale Zeit bis Safe",
            "durchschnittliche Zeit bis Safe", "minimale Zeit bis Safe", "maximale Geschwindigkeit ber Zeit",
            "durschnittliche Geschwindigkeit ber Zeit", "maximale Geschwindigkeit",
            "durchschnittliche Geschwindigkeit", "Panik ber Zeit", "Erschpfung ber Zeit" };
    statisticType = new JComboBox(statisticTypeNames);
    statisticType.addActionListener(new TypePerformed());

    JPanel timeIntervalGroup = new JPanel();
    timeInterval = new JLabel("Zeitintervall:");
    timeIntervalFrom = new JTextField(4);
    timeIntervalTo = new JTextField(4);
    timeIntervalGroup.add(timeInterval);
    timeIntervalGroup.add(timeIntervalFrom);
    timeIntervalGroup.add(new JLabel(" - "));
    timeIntervalGroup.add(timeIntervalTo);

    assignmentListModel = new DefaultListModel();
    assignmentList = new JList(assignmentListModel); // data has type Object[]
    assignmentList.getSelectionModel().addListSelectionListener(new AssignmentTypeListSelect());
    assignmentList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    assignmentList.setLayoutOrientation(JList.VERTICAL);
    assignmentList.setVisibleRowCount(-1);

    JScrollPane listScroller = new JScrollPane(assignmentList);
    listScroller.setPreferredSize(new Dimension(100, 50));

    JPanel assignmentButtons = new JPanel();
    JButton btn_group = new JButton("Group");
    JButton btn_ungroup = new JButton("Ungroup");
    btn_group.addActionListener(new GroupPreformed());
    btn_ungroup.addActionListener(new UngroupPreformed());
    assignmentButtons.add(btn_group);/*from   ww  w.  jav a  2  s  . c o m*/
    assignmentButtons.add(btn_ungroup);

    JButton btn_createDiagram = new JButton("Create Diagram");
    btn_createDiagram.addActionListener(new CreateDiagramPerformed());

    JButton btn_removeDiagram = new JButton("Remove Diagram");
    btn_removeDiagram.addActionListener(new RemovePerformed());

    JPanel diagramButtonGroup = new JPanel();
    diagramButtonGroup.add(btn_createDiagram);
    diagramButtonGroup.add(btn_removeDiagram);

    diagramCategoryListModel = new DefaultListModel();
    diagramCategoryList = new JList(diagramCategoryListModel); // data has type
    // Object[]
    diagramCategoryList.getSelectionModel().addListSelectionListener(new DiagramCategoryListSelect());
    diagramCategoryList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    diagramCategoryList.setLayoutOrientation(JList.VERTICAL);
    diagramCategoryList.setVisibleRowCount(-1);

    JScrollPane diagramCategoryListScroller = new JScrollPane(diagramCategoryList);
    diagramCategoryListScroller.setPreferredSize(new Dimension(100, 50));

    JPanel buttonGroup = new JPanel();
    JButton btn_addToDiagram = new JButton("Add to Diagram");
    JButton btn_removeFromDiagram = new JButton("Remove from Diagram");
    buttonGroup.add(btn_addToDiagram);
    buttonGroup.add(btn_removeFromDiagram);
    btn_addToDiagram.addActionListener(new AddToDiagramPerformed());
    btn_removeFromDiagram.addActionListener(new RemoveFromDiagramPerformed());

    // Create statisticSource at last because we need the GUI Objects above to initialize
    // our selection in BatchResultEntryComboBoxModel.setSelectedItem ()
    model = new BatchResultEntryComboBoxModel();
    statisticSource = new JComboBox(model);

    int y = 0;
    p.add(statisticType, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(statisticSource, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JSeparator(SwingConstants.HORIZONTAL), new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    p.add(new JLabel("Belegungen"), new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(listScroller, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.5, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    p.add(assignmentButtons, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JSeparator(SwingConstants.HORIZONTAL), new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    p.add(buttonGroup, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JSeparator(SwingConstants.HORIZONTAL), new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    p.add(diagramCategoryListScroller, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.5, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    p.add(diagramButtonGroup, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    return p;
}

From source file:net.pms.newgui.NavigationShareTab.java

private PanelBuilder initSharedFoldersGuiComponents(CellConstraints cc) {
    // Apply the orientation for the locale
    ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale());
    String colSpec = FormLayoutUtil.getColSpec(SHARED_FOLDER_COL_SPEC, orientation);

    FormLayout layoutFolders = new FormLayout(colSpec, SHARED_FOLDER_ROW_SPEC);
    PanelBuilder builderFolder = new PanelBuilder(layoutFolders);
    builderFolder.opaque(true);/*  ww w  . jav  a 2  s  .c o  m*/

    JComponent cmp = builderFolder.addSeparator(Messages.getString("FoldTab.7"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 7), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    folderTableModel = new SharedFoldersTableModel();
    sharedFolders = new JTable(folderTableModel);

    JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem menuItemMarkPlayed = new JMenuItem(Messages.getString("FoldTab.75"));
    JMenuItem menuItemMarkUnplayed = new JMenuItem(Messages.getString("FoldTab.76"));

    menuItemMarkPlayed.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String path = (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0);
            TableFilesStatus.setDirectoryFullyPlayed(path, true);
        }
    });

    menuItemMarkUnplayed.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String path = (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0);
            TableFilesStatus.setDirectoryFullyPlayed(path, false);
        }
    });

    popupMenu.add(menuItemMarkPlayed);
    popupMenu.add(menuItemMarkUnplayed);

    sharedFolders.setComponentPopupMenu(popupMenu);

    /* An attempt to set the correct row height adjusted for font scaling.
     * It sets all rows based on the font size of cell (0, 0). The + 4 is
     * to allow 2 pixels above and below the text. */
    DefaultTableCellRenderer cellRenderer = (DefaultTableCellRenderer) sharedFolders.getCellRenderer(0, 0);
    FontMetrics metrics = cellRenderer.getFontMetrics(cellRenderer.getFont());
    sharedFolders.setRowHeight(metrics.getLeading() + metrics.getMaxAscent() + metrics.getMaxDescent() + 4);
    sharedFolders.setIntercellSpacing(new Dimension(8, 2));

    final JPanel tmpsharedPanel = sharedPanel;

    addButton.setToolTipText(Messages.getString("FoldTab.9"));
    addButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser;
            try {
                chooser = new JFileChooser();
            } catch (Exception ee) {
                chooser = new JFileChooser(new RestrictedFileSystemView());
            }
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showOpenDialog((Component) e.getSource());
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                int firstSelectedRow = sharedFolders.getSelectedRow();
                if (firstSelectedRow >= 0) {
                    ((SharedFoldersTableModel) sharedFolders.getModel()).insertRow(firstSelectedRow,
                            new Object[] { chooser.getSelectedFile().getAbsolutePath(), true });
                } else {
                    ((SharedFoldersTableModel) sharedFolders.getModel())
                            .addRow(new Object[] { chooser.getSelectedFile().getAbsolutePath(), true });
                }
            }
        }
    });
    builderFolder.add(addButton, FormLayoutUtil.flip(cc.xy(2, 3), colSpec, orientation));

    removeButton.setToolTipText(Messages.getString("FoldTab.36"));
    removeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int[] rows = sharedFolders.getSelectedRows();
            if (rows.length > 0) {
                if (rows.length > 1) {
                    if (JOptionPane.showConfirmDialog(tmpsharedPanel,
                            String.format(Messages.getString("SharedFolders.ConfirmRemove"), rows.length),
                            Messages.getString("Dialog.Confirm"), JOptionPane.YES_NO_OPTION,
                            JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) {
                        return;
                    }
                }
                for (int i = rows.length - 1; i >= 0; i--) {
                    PMS.get().getDatabase().removeMediaEntriesInFolder(
                            (String) sharedFolders.getValueAt(sharedFolders.getSelectedRow(), 0));
                    ((SharedFoldersTableModel) sharedFolders.getModel()).removeRow(rows[i]);
                }
            }
        }
    });
    builderFolder.add(removeButton, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));

    arrowDownButton.setToolTipText(Messages.getString("SharedFolders.ArrowDown"));
    arrowDownButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (int i = 0; i < sharedFolders.getRowCount() - 1; i++) {
                if (sharedFolders.isRowSelected(i)) {
                    Object value1 = sharedFolders.getValueAt(i, 0);
                    boolean value2 = (boolean) sharedFolders.getValueAt(i, 1);

                    sharedFolders.setValueAt(sharedFolders.getValueAt(i + 1, 0), i, 0);
                    sharedFolders.setValueAt(value1, i + 1, 0);
                    sharedFolders.setValueAt(sharedFolders.getValueAt(i + 1, 1), i, 1);
                    sharedFolders.setValueAt(value2, i + 1, 1);
                    sharedFolders.changeSelection(i + 1, 1, false, false);

                    break;
                }
            }
        }
    });
    builderFolder.add(arrowDownButton, FormLayoutUtil.flip(cc.xy(4, 3), colSpec, orientation));

    arrowUpButton.setToolTipText(Messages.getString("SharedFolders.ArrowUp"));
    arrowUpButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            for (int i = 1; i < sharedFolders.getRowCount(); i++) {
                if (sharedFolders.isRowSelected(i)) {
                    Object value1 = sharedFolders.getValueAt(i, 0);
                    boolean value2 = (boolean) sharedFolders.getValueAt(i, 1);

                    sharedFolders.setValueAt(sharedFolders.getValueAt(i - 1, 0), i, 0);
                    sharedFolders.setValueAt(value1, i - 1, 0);
                    sharedFolders.setValueAt(sharedFolders.getValueAt(i - 1, 1), i, 1);
                    sharedFolders.setValueAt(value2, i - 1, 1);
                    sharedFolders.changeSelection(i - 1, 1, false, false);

                    break;

                }
            }
        }
    });
    builderFolder.add(arrowUpButton, FormLayoutUtil.flip(cc.xy(5, 3), colSpec, orientation));

    scanButton.setToolTipText(Messages.getString("FoldTab.2"));
    scanBusyIcon.start();
    scanBusyDisabledIcon.start();
    scanButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (configuration.getUseCache()) {
                DLNAMediaDatabase database = PMS.get().getDatabase();

                if (database != null) {
                    if (database.isScanLibraryRunning()) {
                        int option = JOptionPane.showConfirmDialog(looksFrame, Messages.getString("FoldTab.10"),
                                Messages.getString("Dialog.Question"), JOptionPane.YES_NO_OPTION);
                        if (option == JOptionPane.YES_OPTION) {
                            database.stopScanLibrary();
                            looksFrame.setStatusLine(Messages.getString("FoldTab.41"));
                            scanButton.setEnabled(false);
                            scanButton.setToolTipText(Messages.getString("FoldTab.41"));
                        }
                    } else {
                        database.scanLibrary();
                        scanButton.setIcon(scanBusyIcon);
                        scanButton.setRolloverIcon(scanBusyRolloverIcon);
                        scanButton.setPressedIcon(scanBusyPressedIcon);
                        scanButton.setDisabledIcon(scanBusyDisabledIcon);
                        scanButton.setToolTipText(Messages.getString("FoldTab.40"));
                    }
                }
            }
        }
    });

    /*
     * Hide the scan button in basic mode since it's better to let it be done in
     * realtime.
     */
    if (!configuration.isHideAdvancedOptions()) {
        builderFolder.add(scanButton, FormLayoutUtil.flip(cc.xy(6, 3), colSpec, orientation));
    }

    scanButton.setEnabled(configuration.getUseCache());

    isScanSharedFoldersOnStartup = new JCheckBox(Messages.getString("NetworkTab.StartupScan"),
            configuration.isScanSharedFoldersOnStartup());
    isScanSharedFoldersOnStartup.setToolTipText(Messages.getString("NetworkTab.StartupScanTooltip"));
    isScanSharedFoldersOnStartup.setContentAreaFilled(false);
    isScanSharedFoldersOnStartup.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setScanSharedFoldersOnStartup((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    builderFolder.add(isScanSharedFoldersOnStartup, FormLayoutUtil.flip(cc.xy(7, 3), colSpec, orientation));

    updateSharedFolders();

    JScrollPane pane = new JScrollPane(sharedFolders);
    Dimension d = sharedFolders.getPreferredSize();
    pane.setPreferredSize(new Dimension(d.width, sharedFolders.getRowHeight() * 2));
    builderFolder.add(pane, FormLayoutUtil.flip(cc.xyw(1, 5, 7, CellConstraints.DEFAULT, CellConstraints.FILL),
            colSpec, orientation));

    return builderFolder;
}

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

public void init() {

    //   dataPoints = new LinkedList();
    t1_x = t2_x = 0;//  w  w  w.j ava 2s  .  c  o m
    t1_y = t2_y = 0.001;
    simulatedPoints = setupUniformSimulate(numStocks, numSimulate);
    tabbedPanelContainer = new JTabbedPane();
    show_tangent = true;

    //   addGraph(chartPanel);
    //   addToolbar(sliderPanel);
    initGraphPanel();
    initMixPanel();
    initInputPanel();
    emptyTool();
    emptyTool2();
    leftControl = new JPanel();
    leftControl.setLayout(new BoxLayout(leftControl, BoxLayout.PAGE_AXIS));
    addRadioButton2Left("Number of Stocks:", "", numStocksArray, numStocks - 2, this);
    addRadioButton2Left("Show Tangent Line :", "", on_off, 0, this);

    JScrollPane mixPanelContainer = new JScrollPane(mixPanel);
    mixPanelContainer.setPreferredSize(new Dimension(600, CHART_SIZE_Y + 100));

    addTabbedPane(GRAPH, graphPanel);

    addTabbedPane(INPUT, inputPanel);

    addTabbedPane(ALL, mixPanelContainer);

    setChart();

    tabbedPanelContainer.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == ALL) {
                mixPanel.removeAll();
                setMixPanel();
                mixPanel.validate();
            } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == GRAPH) {
                graphPanel.removeAll();
                setChart();

            } else if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) == INPUT) {
                //
                setInputPanel();
            }
        }
    });

    statusTextArea = new JTextPane(); //right side lower
    statusTextArea.setEditable(false);
    JScrollPane statusContainer = new JScrollPane(statusTextArea);
    statusContainer.setPreferredSize(new Dimension(600, 140));

    JSplitPane upContainer = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(leftControl),
            new JScrollPane(tabbedPanelContainer));

    this.getMainPanel().removeAll();
    if (SHOW_STATUS_TEXTAREA) {
        JSplitPane container = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(upContainer),
                statusContainer);
        container.setContinuousLayout(true);
        container.setDividerLocation(0.6);
        this.getMainPanel().add(container, BorderLayout.CENTER);
    } else {

        this.getMainPanel().add(new JScrollPane(upContainer), BorderLayout.CENTER);
    }
    this.getMainPanel().validate();

}

From source file:cellularAutomata.analysis.PricingDistributionAnalysis.java

/**
 * Create the panel used to display the pricing statistics.
 */// w  w  w .java 2s .c  o m
private void createDisplayPanel() {
    int displayWidth = CAFrame.tabbedPaneDimension.width;
    int displayHeight = 600 + (100 * numberOfStates);

    // create the display panel
    if (displayPanel == null) {
        displayPanel = new JPanel(new GridBagLayout());
        displayPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        displayPanel.setPreferredSize(new Dimension(displayWidth, displayHeight));
    } else {
        displayPanel.removeAll();
    }

    if (isCompatibleRule && (numberOfStates <= MAX_NUMBER_OF_STATES)) {
        // create a panel that displays messages
        JPanel messagePanel = createMessagePanel();

        // create the labels for the display
        createDataDisplayLabels();
        JLabel generationLabel = new JLabel("Generation:   ");
        JLabel stateLabel = new JLabel("State:");
        JLabel numStateLabel = new JLabel("Number:");
        JLabel percentOccupiedLabel = new JLabel("Kurtosis:");

        // create boxes for each column of the display (a Box uses the
        // BoxLayout, so it is handy for laying out components)
        Box boxOfStateLabels = Box.createVerticalBox();
        Box boxOfNumberLabels = Box.createVerticalBox();
        Box boxOfPercentLabels = Box.createVerticalBox();

        // the amount of vertical space to put between components
        int verticalSpace = 5;

        // add the states to the first vertical box
        boxOfStateLabels.add(stateLabel);
        boxOfStateLabels.add(Box.createVerticalStrut(verticalSpace));
        for (int state = 0; state < numberOfStates; state++) {
            boxOfStateLabels.add(new JLabel("" + state));
            boxOfStateLabels.add(Box.createVerticalStrut(verticalSpace));
        }

        // add the numbers (in each state) to the second vertical box
        boxOfNumberLabels.add(numStateLabel);
        boxOfNumberLabels.add(Box.createVerticalStrut(verticalSpace));
        for (int i = 0; i < numberOfStates; i++) {
            boxOfNumberLabels.add(numberOccupiedByStateDataLabel[i]);
            boxOfNumberLabels.add(Box.createVerticalStrut(verticalSpace));
        }

        // add the percents (in each state) to the third vertical box
        boxOfPercentLabels.add(percentOccupiedLabel);
        boxOfPercentLabels.add(Box.createVerticalStrut(verticalSpace));
        for (int i = 0; i < numberOfStates; i++) {
            boxOfPercentLabels.add(percentOccupiedByStateDataLabel[i]);
            boxOfPercentLabels.add(Box.createVerticalStrut(verticalSpace));
        }

        // create another box that holds all of the label boxes
        Box boxOfLabels = Box.createHorizontalBox();
        boxOfLabels.add(boxOfStateLabels);
        boxOfLabels.add(boxOfNumberLabels);
        boxOfLabels.add(boxOfPercentLabels);
        boxOfLabels.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));

        // put the boxOfLabels in a scrollPane -- with many states, will get
        // very large
        JScrollPane stateScroller = new JScrollPane(boxOfLabels);
        int scrollPaneWidth = (int) (displayWidth * 0.8);
        int scrollPaneHeight = displayHeight / 4;
        stateScroller.setPreferredSize(new Dimension(scrollPaneWidth, scrollPaneHeight));
        stateScroller.setMinimumSize(new Dimension(scrollPaneWidth, scrollPaneHeight));
        stateScroller.setMaximumSize(new Dimension(scrollPaneWidth, scrollPaneHeight));
        stateScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

        // create a "plot zero state" check box
        plotZeroStateCheckBox = new JCheckBox(PLOT_ZERO_STATE);
        plotZeroStateCheckBox.setSelected(true);
        plotZeroStateCheckBox.setToolTipText(PLOT_ZERO_STATE_TOOLTIP);
        plotZeroStateCheckBox.setActionCommand(PLOT_ZERO_STATE);
        plotZeroStateCheckBox.addActionListener(this);
        JPanel plotZeroStatePanel = new JPanel(new BorderLayout());
        plotZeroStatePanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
        plotZeroStatePanel.add(BorderLayout.CENTER, plotZeroStateCheckBox);

        // create a "save data" check box
        saveDataCheckBox = new JCheckBox(SAVE_DATA);
        saveDataCheckBox.setToolTipText(SAVE_DATA_TOOLTIP);
        saveDataCheckBox.setActionCommand(SAVE_DATA);
        saveDataCheckBox.addActionListener(this);
        JPanel saveDataPanel = new JPanel(new BorderLayout());
        saveDataPanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
        saveDataPanel.add(BorderLayout.CENTER, saveDataCheckBox);

        // create a panel that plots the data
        plot = new SimplePlot();

        // add all the components to the panel
        int row = 0;
        displayPanel.add(messagePanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(1.0, 1.0)
                .setAnchor(GBC.WEST).setInsets(1));

        row++;
        displayPanel.add(plot, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(10.0, 10.0)
                .setAnchor(GBC.WEST).setInsets(1));

        row++;
        for (int i = 0; i < numberOfStates; i++) {
            timeSeriesPlot[i] = new SimplePlot();
            displayPanel.add(timeSeriesPlot[i], new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH)
                    .setWeight(10.0, 10.0).setAnchor(GBC.WEST).setInsets(1));

            row++;
        }
        displayPanel.add(plotZeroStatePanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.NONE).setWeight(1.0, 1.0)
                .setAnchor(GBC.CENTER).setInsets(1));

        row++;
        displayPanel.add(generationLabel, new GBC(1, row).setSpan(1, 1).setFill(GBC.NONE).setWeight(1.0, 1.0)
                .setAnchor(GBC.EAST).setInsets(1));
        displayPanel.add(generationDataLabel, new GBC(2, row).setSpan(1, 1).setFill(GBC.NONE)
                .setWeight(1.0, 1.0).setAnchor(GBC.WEST).setInsets(1));

        row++;
        displayPanel.add(stateScroller, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(1.0, 1.0)
                .setAnchor(GBC.WEST).setInsets(1));

        row++;
        displayPanel.add(saveDataPanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.NONE).setWeight(1.0, 1.0)
                .setAnchor(GBC.CENTER).setInsets(1));

    } else {
        int row = 0;
        displayPanel.add(createWarningMessagePanel(), new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH)
                .setWeight(1.0, 1.0).setAnchor(GBC.WEST).setInsets(1));
    }

}

From source file:io.github.jeremgamer.editor.panels.components.ButtonPanel.java

public ButtonPanel(JFrame frame) {

    this.frame = frame;
    this.setSize(new Dimension(395, frame.getHeight() - 27 - 23));
    this.setLocation(300, 0);
    this.setBorder(BorderFactory.createTitledBorder("Edition du bouton"));
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    JLabel nameLabel = new JLabel("Nom : ");
    name.setPreferredSize(new Dimension(this.getWidth() - 285, 30));
    name.setEditable(false);/*  w w  w  . j  a va  2s. c o m*/
    JPanel namePanel = new JPanel();
    namePanel.add(nameLabel);
    namePanel.add(name);
    JPanel textPanel = new JPanel();
    JPanel nameAndTextPanel = new JPanel();
    JLabel textLabel = new JLabel("Texte :");
    CaretListener caretUpdateText = new CaretListener() {
        public void caretUpdate(javax.swing.event.CaretEvent e) {
            JTextField text = (JTextField) e.getSource();
            bs.set("text", text.getText());
            preview.setText(text.getText());
            preview2.setText(text.getText());
        }
    };
    text.addCaretListener(caretUpdateText);
    text.setPreferredSize(new Dimension(this.getWidth() - 283, 30));
    textPanel.add(textLabel);
    textPanel.add(text);
    nameAndTextPanel.setLayout(new BoxLayout(nameAndTextPanel, BoxLayout.PAGE_AXIS));
    nameAndTextPanel.add(namePanel);
    nameAndTextPanel.add(textPanel);

    JPanel policePanel = new JPanel();
    JLabel policeLabel = new JLabel("Police : ");
    police.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) e.getSource();
            fontStyle = (String) combo.getSelectedItem();
            preview.setFont(new Font(fontStyle, Font.PLAIN, fontSize));
            preview2.setFont(new Font(fontStyle, Font.PLAIN, fontSize));
            bs.set("police", fontStyle);
        }

    });
    police.setPreferredSize(new Dimension(105, 30));
    GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fonts = e.getAllFonts();
    for (Font f : fonts) {
        police.addItem(f.getName());
    }
    police.setSelectedItem("Arial");
    policePanel.add(policeLabel);
    policePanel.add(police);

    JPanel sizePanel = new JPanel();
    size.setPreferredSize(new Dimension(60, 25));
    JLabel sizeLabel = new JLabel("Taille : ");
    sizePanel.add(sizeLabel);
    sizePanel.add(size);
    JButton colorButton = new JButton("Couleur");
    colorButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            colorFrame.setModal(false);
            JButton finish = new JButton("Terminer");
            finish.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    colorFrame.dispose();
                }

            });
            colorFrame.setLayout(new BorderLayout());
            colorFrame.add(color, BorderLayout.CENTER);
            colorFrame.add(finish, BorderLayout.SOUTH);
            colorFrame.pack();
            colorFrame.setLocation(SwingUtilities.windowForComponent(imagedButton).getX() + 325,
                    SwingUtilities.windowForComponent(imagedButton).getY() - colorFrame.getHeight() + 40);
            colorFrame.setVisible(true);
        }

    });
    sizePanel.add(colorButton);
    size.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JSpinner spinner = (JSpinner) e.getSource();
            fontSize = (int) spinner.getValue();
            preview.setFont(new Font(fontStyle, Font.PLAIN, fontSize));
            preview2.setFont(new Font(fontStyle, Font.PLAIN, fontSize));
            bs.set("size", fontSize);
        }
    });

    JPanel policeAndSize = new JPanel();
    policeAndSize.setLayout(new BoxLayout(policeAndSize, BoxLayout.PAGE_AXIS));
    policeAndSize.add(policePanel);
    policeAndSize.add(sizePanel);

    JPanel top = new JPanel();
    top.add(nameAndTextPanel);
    top.add(policeAndSize);
    top.setPreferredSize(new Dimension(395, 20));

    this.add(top);

    JPanel images = new JPanel();
    images.setBorder(BorderFactory.createTitledBorder("Images"));
    images.setLayout(new GridLayout(2, 3));
    images.setPreferredSize(new Dimension(395, this.getHeight() - 320));

    JPanel imaged = new JPanel();
    imaged.setLayout(new BorderLayout());
    imaged.setBorder(BorderFactory.createTitledBorder("Icne interne"));
    imagedButton.setSelected(true);
    imagedButton.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            if (ev.getStateChange() == ItemEvent.SELECTED) {
                bs.set("strings", true);
                preview.setBorderPainted(true);
            } else if (ev.getStateChange() == ItemEvent.DESELECTED) {
                bs.set("strings", false);
                preview.setBorderPainted(false);
            }
        }
    });
    JButton browseInternal = new JButton("Parcourir");
    browseInternal.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "internal.png");
                nameInternal.setText(new File(path).getName());
                nameInternal.setPreferredSize(new Dimension(imgBasic.getWidth() - 10, 30));
                preview.setIcon(new ImageIcon(path));
                preview.repaint();
                bs.set("imageInternal", new File(path).getName());
            }
        }

    });
    JPanel northImaged = new JPanel();
    northImaged.setLayout(new BorderLayout());
    northImaged.add(imagedButton, BorderLayout.NORTH);
    northImaged.add(browseInternal, BorderLayout.SOUTH);
    imaged.add(northImaged, BorderLayout.NORTH);
    imaged.add(nameInternal, BorderLayout.CENTER);
    JButton removeInternal = null;
    try {
        removeInternal = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removeInternal.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/internal.png");
            file.delete();
            nameInternal.setText("");
            bs.set("imageInternal", "");
            preview.setIcon(null);
        }

    });
    imaged.add(removeInternal, BorderLayout.SOUTH);
    images.add(imaged);

    imgBasic.setBorder(BorderFactory.createTitledBorder("Base"));
    JButton browseBasic = new JButton("Parcourir");
    browseBasic.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "basic.png");
                nameBasic.setText(new File(path).getName());
                nameBasic.setPreferredSize(new Dimension(imgBasic.getWidth() - 10, 30));
                previewPanel.remove(preview);
                previewPanel.remove(preview2);
                previewPanel.add(preview2);
                color.changePreview(preview2);
                bs.set("imageBasic", new File(path).getName());
                preview2.update();
                previewPanel.repaint();
            }
        }

    });
    imgBasic.setLayout(new BorderLayout());
    imgBasic.add(browseBasic, BorderLayout.NORTH);
    imgBasic.add(nameBasic, BorderLayout.CENTER);
    JButton removeBasic = null;
    try {
        removeBasic = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removeBasic.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/basic.png");
            file.delete();
            nameBasic.setText("");
            bs.set("imageBasic", "");
            preview2.update();
            previewPanel.repaint();
            if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("")
                    && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("")
                    && bs.getString("imageReleased").equals("")) {
                previewPanel.remove(preview2);
                previewPanel.add(preview);
            }
        }

    });
    imgBasic.add(removeBasic, BorderLayout.SOUTH);
    images.add(imgBasic);

    imgEntered.setBorder(BorderFactory.createTitledBorder("Survol"));
    JButton browseEntered = new JButton("Parcourir");
    browseEntered.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "entered.png");
                nameEntered.setText(new File(path).getName());
                nameEntered.setPreferredSize(new Dimension(imgEntered.getWidth() - 10, 30));
                bs.set("imageEntered", new File(path).getName());
                preview2.update();
                previewPanel.repaint();
            }
        }

    });
    imgEntered.setLayout(new BorderLayout());
    imgEntered.add(browseEntered, BorderLayout.NORTH);
    imgEntered.add(nameEntered, BorderLayout.CENTER);
    JButton removeEntered = null;
    try {
        removeEntered = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removeEntered.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/entered.png");
            file.delete();
            nameEntered.setText("");
            bs.set("imageEntered", "");
            preview2.update();
            previewPanel.repaint();
            if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("")
                    && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("")
                    && bs.getString("imageReleased").equals("")) {
                previewPanel.remove(preview2);
                previewPanel.add(preview);
            }
        }

    });
    imgEntered.add(removeEntered, BorderLayout.SOUTH);
    images.add(imgEntered);

    imgExited.setBorder(BorderFactory.createTitledBorder("Sortie"));
    JButton browseExited = new JButton("Parcourir");
    browseExited.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "exited.png");
                nameExited.setText(new File(path).getName());
                nameExited.setPreferredSize(new Dimension(imgExited.getWidth() - 10, 30));
                bs.set("imageExited", new File(path).getName());
                preview2.update();
                previewPanel.repaint();
            }
        }

    });
    imgExited.setLayout(new BorderLayout());
    imgExited.add(browseExited, BorderLayout.NORTH);
    imgExited.add(nameExited, BorderLayout.CENTER);
    JButton removeExited = null;
    try {
        removeExited = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removeExited.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/exited.png");
            file.delete();
            nameExited.setText("");
            bs.set("imageExited", "");
            preview2.update();
            previewPanel.repaint();
            if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("")
                    && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("")
                    && bs.getString("imageReleased").equals("")) {
                previewPanel.remove(preview2);
                previewPanel.add(preview);
            }
        }

    });
    imgExited.add(removeExited, BorderLayout.SOUTH);
    images.add(imgExited);

    imgPressed.setBorder(BorderFactory.createTitledBorder("Clic"));
    JButton browsePressed = new JButton("Parcourir");
    browsePressed.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "pressed.png");
                namePressed.setText(new File(path).getName());
                namePressed.setPreferredSize(new Dimension(imgPressed.getWidth() - 10, 30));
                bs.set("imagePressed", new File(path).getName());
                preview2.update();
                previewPanel.repaint();
            }
        }

    });
    imgPressed.setLayout(new BorderLayout());
    imgPressed.add(browsePressed, BorderLayout.NORTH);
    imgPressed.add(namePressed, BorderLayout.CENTER);
    JButton removePressed = null;
    try {
        removePressed = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removePressed.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/pressed.png");
            file.delete();
            namePressed.setText("");
            bs.set("imagePressed", "");
            preview2.update();
            previewPanel.repaint();
            if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("")
                    && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("")
                    && bs.getString("imageReleased").equals("")) {
                previewPanel.remove(preview2);
                previewPanel.add(preview);
            }
        }

    });
    imgPressed.add(removePressed, BorderLayout.SOUTH);
    images.add(imgPressed);

    imgReleased.setBorder(BorderFactory.createTitledBorder("Relachement"));
    JButton browseReleased = new JButton("Parcourir");
    browseReleased.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            String path = null;
            JFileChooser chooser = new JFileChooser(Editor.lastPath);
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "png", "gif", "jpeg",
                    "bmp");
            chooser.setFileFilter(filter);
            chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int option = chooser.showOpenDialog(null);
            if (option == JFileChooser.APPROVE_OPTION) {
                path = chooser.getSelectedFile().getAbsolutePath();
                Editor.lastPath = chooser.getSelectedFile().getParent();
                copyImage(new File(path), "released.png");
                nameReleased.setText(new File(path).getName());
                nameReleased.setPreferredSize(new Dimension(imgReleased.getWidth() - 10, 30));
                bs.set("imageReleased", new File(path).getName());
                preview2.update();
                previewPanel.repaint();
            }
        }

    });
    imgReleased.setLayout(new BorderLayout());
    imgReleased.add(browseReleased, BorderLayout.NORTH);
    imgReleased.add(nameReleased, BorderLayout.CENTER);
    JButton removeReleased = null;
    try {
        removeReleased = new JButton(new ImageIcon(ImageIO.read(ImageGetter.class.getResource("remove.png"))));
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    removeReleased.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            File file = new File(
                    "projects/" + Editor.getProjectName() + "/buttons/" + name.getText() + "/released.png");
            file.delete();
            nameReleased.setText("");
            bs.set("imageReleased", "");
            preview2.update();
            previewPanel.repaint();
            if (bs.getString("imageBasic").equals("") && bs.getString("imageEntered").equals("")
                    && bs.getString("imageExited").equals("") && bs.getString("imagePressed").equals("")
                    && bs.getString("imageReleased").equals("")) {
                previewPanel.remove(preview2);
                previewPanel.add(preview);
            }
        }

    });
    imgReleased.add(removeReleased, BorderLayout.SOUTH);
    images.add(imgReleased);

    this.add(images);

    JPanel action = new JPanel();
    action.setPreferredSize(new Dimension(395, -20));
    JLabel labelAction = new JLabel("Action : ");
    action.add(labelAction);
    actionList.removeAllItems();
    actionList.addItem("Aucune");
    for (String s : Actions.getActions()) {
        actionList.addItem(s);
    }
    actionList.setPreferredSize(new Dimension(this.getWidth() - 100, 30));
    actionList.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent event) {
            @SuppressWarnings("unchecked")
            JComboBox<String> combo = (JComboBox<String>) event.getSource();
            bs.set("action", combo.getSelectedItem());
        }

    });
    action.add(actionList);
    this.add(action);

    JScrollPane previewScroll = new JScrollPane(previewPanel);
    previewScroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    previewPanel.setBorder(BorderFactory.createTitledBorder("Aperu"));
    previewPanel.add(preview);
    previewScroll.setPreferredSize(new Dimension(395, 40));
    previewScroll.setBorder(null);

    this.add(previewScroll);
}

From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java

public void showNewFiles() {
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JLabel("Aktualisierte Dateien:"), BorderLayout.NORTH);

    final FileObjectTableModel tableModel = new FileObjectTableModel();
    tableModel.setRowObjects(statusCount.getUpdatedFilesAll());
    JTableX<FileObject> table = generateFileObjectTable(tableModel);

    JScrollPane scrollpane = new JScrollPane(table);
    scrollpane
            .setPreferredSize(new Dimension(mainFrame.getSize().width - 100, mainFrame.getSize().height - 200));
    panel.add(scrollpane, BorderLayout.CENTER);

    JPanel panel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton buttonClear = new JButton("Liste leeren");
    buttonClear.addActionListener(new ActionListener() {

        @Override/*from  w w  w .  j a  v  a  2s .  c  o  m*/
        public void actionPerformed(ActionEvent e) {
            statusCount.clearAll();
            updateNewFilesButton();
            tableModel.updateTable();
        }
    });
    panel2.add(buttonClear);
    panel.add(panel2, BorderLayout.SOUTH);

    JOptionPane.showMessageDialog(mainFrame, panel, "Neue Dateien", JOptionPane.INFORMATION_MESSAGE);

}

From source file:de.codesourcery.jasm16.utils.ASTInspector.java

private void setupUI() throws MalformedURLException {
    // editor pane
    editorPane = new JTextPane();
    editorScrollPane = new JScrollPane(editorPane);
    editorPane.addCaretListener(listener);

    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(400, 600));
    editorScrollPane.setMinimumSize(new Dimension(100, 100));

    final AdjustmentListener adjustmentListener = new AdjustmentListener() {

        @Override/*from  w ww  .  java 2  s  .  c  om*/
        public void adjustmentValueChanged(AdjustmentEvent e) {
            if (!e.getValueIsAdjusting()) {
                if (currentUnit != null) {
                    doSemanticHighlighting(currentUnit);
                }
            }
        }
    };
    editorScrollPane.getVerticalScrollBar().addAdjustmentListener(adjustmentListener);
    editorScrollPane.getHorizontalScrollBar().addAdjustmentListener(adjustmentListener);

    // button panel
    final JPanel topPanel = new JPanel();

    final JToolBar toolbar = new JToolBar();
    final JButton showASTButton = new JButton("Show AST");
    showASTButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean currentlyVisible = astInspector != null ? astInspector.isVisible() : false;
            if (currentlyVisible) {
                showASTButton.setText("Show AST");
            } else {
                showASTButton.setText("Hide AST");
            }
            if (currentlyVisible) {
                astInspector.setVisible(false);
            } else {
                showASTInspector();
            }

        }
    });

    fileChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser chooser;
            if (lastOpenDirectory != null && lastOpenDirectory.isDirectory()) {
                chooser = new JFileChooser(lastOpenDirectory);
            } else {
                lastOpenDirectory = null;
                chooser = new JFileChooser();
            }

            final FileFilter filter = new FileFilter() {

                @Override
                public boolean accept(File f) {
                    if (f.isDirectory()) {
                        return true;
                    }
                    return f.isFile() && (f.getName().endsWith(".asm") || f.getName().endsWith(".dasm")
                            || f.getName().endsWith(".dasm16"));
                }

                @Override
                public String getDescription() {
                    return "DCPU-16 assembler sources";
                }
            };
            chooser.setFileFilter(filter);
            int returnVal = chooser.showOpenDialog(frame);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File newFile = chooser.getSelectedFile();
                if (newFile.isFile()) {
                    lastOpenDirectory = newFile.getParentFile();
                    try {
                        openFile(newFile);
                    } catch (IOException e1) {
                        statusModel.addError("Failed to read from file " + newFile.getAbsolutePath(), e1);
                    }
                }
            }
        }
    });
    toolbar.add(fileChooser);
    toolbar.add(showASTButton);

    final ComboBoxModel<String> model = new ComboBoxModel<String>() {

        private ICompilerPhase selected;

        private final List<String> realModel = new ArrayList<String>();

        {
            for (ICompilerPhase p : compiler.getCompilerPhases()) {
                realModel.add(p.getName());
                if (p.getName().equals(ICompilerPhase.PHASE_GENERATE_CODE)) {
                    selected = p;
                }
            }
        }

        @Override
        public Object getSelectedItem() {
            return selected != null ? selected.getName() : null;
        }

        private ICompilerPhase getPhaseByName(String name) {
            for (ICompilerPhase p : compiler.getCompilerPhases()) {
                if (p.getName().equals(name)) {
                    return p;
                }
            }
            return null;
        }

        @Override
        public void setSelectedItem(Object name) {
            selected = getPhaseByName((String) name);
        }

        @Override
        public void addListDataListener(ListDataListener l) {
        }

        @Override
        public String getElementAt(int index) {
            return realModel.get(index);
        }

        @Override
        public int getSize() {
            return realModel.size();
        }

        @Override
        public void removeListDataListener(ListDataListener l) {
        }

    };
    comboBox.setModel(model);
    comboBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (model.getSelectedItem() != null) {
                ICompilerPhase oldPhase = findDisabledPhase();
                if (oldPhase != null) {
                    oldPhase.setStopAfterExecution(false);
                }
                compiler.getCompilerPhaseByName((String) model.getSelectedItem()).setStopAfterExecution(true);
                try {
                    compile();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }

        private ICompilerPhase findDisabledPhase() {
            for (ICompilerPhase p : compiler.getCompilerPhases()) {
                if (p.isStopAfterExecution()) {
                    return p;
                }
            }
            return null;
        }
    });

    toolbar.add(new JLabel("Stop compilation after: "));
    toolbar.add(comboBox);

    cursorPosition.setSize(new Dimension(400, 15));
    cursorPosition.setEditable(false);

    statusArea.setPreferredSize(new Dimension(400, 100));
    statusArea.setModel(statusModel);

    /**
     * TOOLBAR
     * SOURCE
     * cursor position
     * status area 
     */
    topPanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    topPanel.add(toolbar, cnstrs);

    cnstrs = constraints(0, 1, GridBagConstraints.BOTH);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    topPanel.add(editorScrollPane, cnstrs);

    cnstrs = constraints(0, 2, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;
    topPanel.add(cursorPosition, cnstrs);

    cnstrs = constraints(0, 3, GridBagConstraints.HORIZONTAL);
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.weighty = 0;

    final JPanel bottomPanel = new JPanel();
    bottomPanel.setLayout(new GridBagLayout());

    statusArea.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);

    statusArea.addMouseListener(new MouseAdapter() {

        public void mouseClicked(java.awt.event.MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                final int row = statusArea.rowAtPoint(e.getPoint());
                StatusMessage message = statusModel.getMessage(row);
                if (message.getLocation() != null) {
                    moveCursorTo(message.getLocation());
                }
            }
        };
    });

    statusArea.setFillsViewportHeight(true);
    statusArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    final JScrollPane statusPane = new JScrollPane(statusArea);
    statusPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    statusPane.setPreferredSize(new Dimension(400, 100));
    statusPane.setMinimumSize(new Dimension(100, 20));

    cnstrs = constraints(0, 0, GridBagConstraints.BOTH);
    cnstrs.weightx = 1;
    cnstrs.weighty = 1;
    cnstrs.gridwidth = GridBagConstraints.REMAINDER;
    cnstrs.gridheight = GridBagConstraints.REMAINDER;

    bottomPanel.add(statusPane, cnstrs);

    // setup frame
    frame = new JFrame(
            "DCPU-16 assembler " + Compiler.VERSION + "   (c) 2012 by tobias.gierke@code-sourcery.de");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, bottomPanel);
    splitPane.setBackground(Color.WHITE);
    frame.getContentPane().add(splitPane);

    frame.pack();
    frame.setVisible(true);

    splitPane.setDividerLocation(0.9);
}

From source file:com.floreantpos.ui.model.PizzaItemForm.java

private void initComponents() {
    setLayout(new BorderLayout());
    JLabel lblButtonColor = new JLabel(Messages.getString("MenuItemForm.19")); //$NON-NLS-1$
    tabbedPane = new javax.swing.JTabbedPane();

    JPanel tabGeneral = new javax.swing.JPanel();

    JLabel lblName = new JLabel();
    lblName.setHorizontalAlignment(SwingConstants.TRAILING);

    tfName = new com.floreantpos.swing.FixedLengthTextField(20);
    tfDescription = new JTextArea(new FixedLengthDocument(120));

    JLabel lTax = new javax.swing.JLabel();
    lTax.setHorizontalAlignment(SwingConstants.TRAILING);

    cbTax = new javax.swing.JComboBox();
    JButton btnNewTax = new javax.swing.JButton();

    JPanel tabShift = new javax.swing.JPanel();
    JPanel tabPrice = new javax.swing.JPanel();

    JPanel tabButtonStyle = new javax.swing.JPanel();
    JButton btnDeleteShift = new javax.swing.JButton();
    JButton btnAddShift = new javax.swing.JButton();

    JButton btnNewPrice = new javax.swing.JButton();
    JButton btnUpdatePrice = new javax.swing.JButton();
    JButton btnDeletePrice = new javax.swing.JButton();
    JButton btnDeleteAll = new javax.swing.JButton();
    JButton btnDefaultValue = new javax.swing.JButton();
    JButton btnAutoGenerate = new javax.swing.JButton();

    JScrollPane jScrollPane2 = new javax.swing.JScrollPane();
    JScrollPane priceTabScrollPane = new javax.swing.JScrollPane();

    shiftTable = new JTable();

    priceTable = new JTable();
    priceTable.setRowHeight(PosUIManager.getSize(priceTable.getRowHeight()));
    priceTable.setCellSelectionEnabled(true);
    priceTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    priceTable.setSurrendersFocusOnKeystroke(true);
    cbPrinterGroup = new JComboBox<PrinterGroup>(new DefaultComboBoxModel<PrinterGroup>(
            PrinterGroupDAO.getInstance().findAll().toArray(new PrinterGroup[0])));
    cbPrinterGroup.setPreferredSize(new Dimension(226, 0));

    tfDefaultSellPortion = new IntegerTextField(10);
    tfTranslatedName = new FixedLengthTextField(20);
    tfTranslatedName.setLength(120);/*from   w ww.  ja  v  a2 s . c  o m*/
    lblKitchenPrinter = new JLabel(Messages.getString("MenuItemForm.27")); //$NON-NLS-1$
    lblName.setText(Messages.getString("LABEL_NAME")); //$NON-NLS-1$
    tfName.setLength(120);
    JLabel lblTranslatedName = new JLabel(Messages.getString("MenuItemForm.lblTranslatedName.text")); //$NON-NLS-1$
    tfSortOrder = new IntegerTextField(20);
    tfSortOrder.setText(""); //$NON-NLS-1$
    cbTax.setPreferredSize(new Dimension(198, 0));
    btnButtonColor = new JButton(); //$NON-NLS-1$
    btnButtonColor.setPreferredSize(new Dimension(228, 40));
    JLabel lblTextColor = new JLabel(Messages.getString("MenuItemForm.lblTextColor.text")); //$NON-NLS-1$
    btnTextColor = new JButton(Messages.getString("MenuItemForm.SAMPLE_TEXT")); //$NON-NLS-1$
    cbShowTextWithImage = new JCheckBox(Messages.getString("MenuItemForm.40")); //$NON-NLS-1$
    cbShowTextWithImage.setActionCommand(Messages.getString("MenuItemForm.41")); //$NON-NLS-1$
    lTax.setText(Messages.getString("LABEL_TAX")); //$NON-NLS-1$
    btnNewTax.setText("...");
    lTax.setText(Messages.getString("LABEL_TAX")); //$NON-NLS-1$

    btnNewTax.setText("..."); //$NON-NLS-1$
    btnNewTax.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btnNewTaxdoCreateNewTax(evt);
        }
    });

    tabbedPane.addTab(com.floreantpos.POSConstants.GENERAL, tabGeneral);
    tabbedPane.setPreferredSize(new Dimension(750, 470));

    tabbedPane.addTab(com.floreantpos.POSConstants.MODIFIER_GROUPS, getModifierGroupTab());

    btnAddShift.addActionListener(this);
    btnDeleteShift.addActionListener(this);

    tabGeneral.setLayout(new MigLayout("insets 20", "[][]20px[][]", "[][][][][][][][][][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    tabGeneral.add(lblName, "cell 0 1 ,right"); //$NON-NLS-1$
    tabGeneral.add(tfName, "cell 1 1,grow"); //$NON-NLS-1$

    tabGeneral.add(lblTranslatedName, "cell 0 2,right"); //$NON-NLS-1$
    tabGeneral.add(tfTranslatedName, "cell 1 2,grow");

    JLabel lgroup = new javax.swing.JLabel();
    lgroup.setHorizontalAlignment(SwingConstants.TRAILING);
    lgroup.setText(Messages.getString("LABEL_GROUP")); //$NON-NLS-1$

    tabGeneral.add(lgroup, "cell 0 3,alignx right"); //$NON-NLS-1$
    JLabel lblBarcode = new JLabel(Messages.getString("MenuItemForm.lblBarcode.text")); //$NON-NLS-1$

    tabGeneral.add(lblBarcode, "cell 0 4,alignx right"); //$NON-NLS-1$
    tfBarcode = new FixedLengthTextField(20);
    tabGeneral.add(tfBarcode, "cell 1 4,grow"); //$NON-NLS-1$
    JLabel lblStockCount = new JLabel(Messages.getString("MenuItemForm.17")); //$NON-NLS-1$

    tabGeneral.add(lblStockCount, "cell 0 5,alignx right"); //$NON-NLS-1$
    tfStockCount = new DoubleTextField(1);
    tabGeneral.add(tfStockCount, "cell 1 5,grow"); //$NON-NLS-1$
    chkVisible = new javax.swing.JCheckBox();

    tabGeneral.add(new JLabel("Default sell portion (%)"), "cell 0 6");
    tabGeneral.add(tfDefaultSellPortion, "cell 1 6,grow");

    chkVisible.setText(com.floreantpos.POSConstants.VISIBLE);
    chkVisible.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
    chkVisible.setMargin(new java.awt.Insets(0, 0, 0, 0));

    tabGeneral.add(chkVisible, "cell 1 7");
    tabGeneral.add(lblKitchenPrinter, "cell 2 1,right"); //$NON-NLS-1$
    tabGeneral.add(cbPrinterGroup, "cell 3 1,grow"); //$NON-NLS-1$

    tabGeneral.add(lTax, "cell 2 2,right"); //$NON-NLS-1$
    tabGeneral.add(cbTax, "cell 3 2"); //$NON-NLS-1$
    tabGeneral.add(btnNewTax, "cell 3 2,grow"); //$NON-NLS-1$

    cbGroup = new javax.swing.JComboBox();
    cbGroup.setPreferredSize(new Dimension(198, 0));

    tabGeneral.add(cbGroup, "flowx,cell 1 3"); //$NON-NLS-1$
    JButton btnNewGroup = new javax.swing.JButton();

    btnNewGroup.setText("..."); //$NON-NLS-1$
    btnNewGroup.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            doCreateNewGroup(evt);
        }
    });
    tabGeneral.add(btnNewGroup, "cell 1 3"); //$NON-NLS-1$

    tabGeneral.add(new JLabel(Messages.getString("MenuItemForm.25")), "cell 2 3,right"); //$NON-NLS-1$ //$NON-NLS-2$
    orderList = new CheckBoxList();

    List<OrderType> orderTypes = Application.getInstance().getOrderTypes();
    orderList.setModel(orderTypes);

    JScrollPane orderCheckBoxList = new JScrollPane(orderList);
    orderCheckBoxList.setPreferredSize(new Dimension(228, 100));
    tabGeneral.add(orderCheckBoxList, "cell 3 3 3 3"); //$NON-NLS-1$
    cbDisableStockCount = new JCheckBox(Messages.getString("MenuItemForm.18")); //$NON-NLS-1$
    tabGeneral.add(cbDisableStockCount, "cell 1 8"); //$NON-NLS-1$

    tabGeneral.add(new JLabel(Messages.getString("MenuItemForm.29")), "cell 2 6,alignx right"); //$NON-NLS-1$ //$NON-NLS-2$
    JScrollPane scrlDescription = new JScrollPane(tfDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrlDescription.setPreferredSize(new Dimension(228, 70));
    tfDescription.setLineWrap(true);
    tabGeneral.add(scrlDescription, "cell 3 6 3 3"); //$NON-NLS-1$

    add(tabbedPane);
    //TODO: 
    addRecepieExtension();

    btnDeleteShift.setText(com.floreantpos.POSConstants.DELETE_SHIFT);
    btnAddShift.setText(com.floreantpos.POSConstants.ADD_SHIFT);

    shiftTable
            .setModel(new javax.swing.table.DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null } },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    jScrollPane2.setViewportView(shiftTable);

    org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(tabShift);
    tabShift.setLayout(jPanel3Layout);
    jPanel3Layout
            .setHorizontalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel3Layout.createSequentialGroup().addContainerGap(76, Short.MAX_VALUE)
                            .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane2,
                                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 670,
                                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                            jPanel3Layout.createSequentialGroup().add(btnAddShift).add(5, 5, 5)
                                                    .add(btnDeleteShift)))
                            .addContainerGap()));
    jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 345,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(btnAddShift).add(btnDeleteShift))
                    .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    tabbedPane.addTab(com.floreantpos.POSConstants.SHIFTS, tabShift);

    btnNewPrice.setText(Messages.getString("MenuItemForm.9")); //$NON-NLS-1$
    btnNewPrice.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            addNewPrice();
        }
    });
    btnUpdatePrice.setText(Messages.getString("MenuItemForm.13")); //$NON-NLS-1$
    btnUpdatePrice.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updatePrice();
        }
    });
    btnDeletePrice.setText(Messages.getString("MenuItemForm.14")); //$NON-NLS-1$
    btnDeletePrice.addActionListener(new ActionListener() {

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

    btnAutoGenerate.setText("Auto Generate"); //$NON-NLS-1$
    btnAutoGenerate.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            autoGeneratePizzaItemSizeAndPrice();
        }
    });

    btnDeleteAll.setText(Messages.getString("MenuItemForm.15")); //$NON-NLS-1$
    btnDeleteAll.addActionListener(new ActionListener() {

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

    btnDefaultValue.setText(Messages.getString("MenuItemForm.7")); //$NON-NLS-1$
    priceTabScrollPane.setViewportView(priceTable);

    tabPrice.setLayout(new BorderLayout());
    tabPrice.add(priceTabScrollPane, BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel();

    buttonPanel.add(btnNewPrice);
    buttonPanel.add(btnUpdatePrice);
    buttonPanel.add(btnDeletePrice);
    buttonPanel.add(btnAutoGenerate);

    tabPrice.add(buttonPanel, BorderLayout.SOUTH);
    tabGeneral.add(tabPrice, "cell 0 10,grow,span");
    tabbedPane.addChangeListener(this);

    tabButtonStyle.setLayout(new MigLayout("insets 10", "[][]100[][][][]", "[][][center][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

    JLabel lblImage = new JLabel(Messages.getString("MenuItemForm.28")); //$NON-NLS-1$
    lblImage.setHorizontalAlignment(SwingConstants.TRAILING);
    tabButtonStyle.add(lblImage, "cell 0 0,right"); //$NON-NLS-1$

    lblImagePreview = new JLabel(""); //$NON-NLS-1$
    lblImagePreview.setHorizontalAlignment(JLabel.CENTER);
    lblImagePreview.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
    lblImagePreview.setPreferredSize(new Dimension(100, 100));
    tabButtonStyle.add(lblImagePreview, "cell 1 0"); //$NON-NLS-1$

    JButton btnSelectImage = new JButton("..."); //$NON-NLS-1$
    btnClearImage = new JButton(Messages.getString("MenuItemForm.34")); //$NON-NLS-1$
    tabButtonStyle.add(btnClearImage, "cell  1 0"); //$NON-NLS-1$
    tabButtonStyle.add(btnSelectImage, "cell 1 0"); //$NON-NLS-1$

    tabButtonStyle.add(lblButtonColor, "cell 0 2,right"); //$NON-NLS-1$
    tabButtonStyle.add(btnButtonColor, "cell 1 2,grow"); //$NON-NLS-1$
    tabButtonStyle.add(lblTextColor, "cell 0 3,right"); //$NON-NLS-1$
    tabButtonStyle.add(btnTextColor, "cell 1 3"); //$NON-NLS-1$
    tabButtonStyle.add(cbShowTextWithImage, "cell 1 4"); //$NON-NLS-1$

    btnTextColor.setPreferredSize(new Dimension(228, 50));

    btnSelectImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doSelectImageFile();
        }
    });

    btnClearImage.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doClearImage();
        }
    });

    btnButtonColor.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Color color = JColorChooser.showDialog(POSUtil.getBackOfficeWindow(),
                    Messages.getString("MenuItemForm.42"), btnButtonColor.getBackground()); //$NON-NLS-1$
            btnButtonColor.setBackground(color);
            btnTextColor.setBackground(color);
        }
    });

    btnTextColor.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Color color = JColorChooser.showDialog(POSUtil.getBackOfficeWindow(),
                    Messages.getString("MenuItemForm.43"), btnTextColor.getForeground()); //$NON-NLS-1$
            btnTextColor.setForeground(color);
        }
    });

    tabbedPane.addTab(Messages.getString("MenuItemForm.26"), tabButtonStyle); //$NON-NLS-1$
}

From source file:org.agmip.ui.afsirs.frames.SWFrame.java

private void showSoilDataButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showSoilDataButtonActionPerformed
    // TODO add your handling code here:

    boolean isFileEnabled = jRadioFile.isSelected();
    boolean isFileLocationEnabled = jRadioButtonSavedLocation.isSelected();
    String str = "";

    if (isFileLocationEnabled) {
        SoilData soilData;/*from w  w  w. j a v a  2 s . c  o m*/
        File latestFile;
        try {
            latestFile = findLatestFile(soilFileListCombo.getSelectedIndex());
            str = readFromJsonFileForSoilDetailsButton(latestFile);

        } catch (FileNotFoundException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
            return;
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else if (isFileEnabled) {
        str += "Soil Name = " + SNAME + "\n";
        str += "Texture = " + TXT[0] + "\n";
        str += "Number of Layers = " + NL + "\n";
        str += "    DU        WCL        WCU        (WCU-WCL)\n";
        for (int i = 0; i < NL; i++) {
            str += (i + 1) + "  " + DU[i] + "       " + WCL[i] + "       " + WCU[i] + "       "
                    + (WCU[i] - WCL[i]) + "\n";
        }
    }

    JTextArea textArea = new JTextArea(str);
    JScrollPane scrollPane = new JScrollPane(textArea);
    textArea.setLineWrap(true);
    textArea.setEditable(false);
    textArea.setWrapStyleWord(true);
    scrollPane.setPreferredSize(new Dimension(500, 300));
    JOptionPane.showMessageDialog(null, scrollPane, "Soil Info", JOptionPane.NO_OPTION);

    //JOptionPane.showMessageDialog(null, str);            

}

From source file:br.org.acessobrasil.ases.ferramentas_de_reparo.vista.imagem.analise_geral.PanelAnaliseGeral.java

/**
 * Inicia os componentes//from   ww w.  ja  va  2  s.c o  m
 * 
 * @param erros
 */

private void initComponentsEscalavel(ArrayList<FerramentaAnaliseGeralModel> erros) {
    incValueProgress();
    hashCodeInicial = null;
    PainelStatusBar.hideProgTarReq();
    Ferramenta_Imagens.carregaTexto(TokenLang.LANG);
    JPanel regraFonteBtn = new JPanel();
    regraFonteBtn.setLayout(new BorderLayout());
    PainelStatusBar.setValueProgress(3);
    boxCode = new G_TextAreaSourceCode();
    boxCode.setTipoHTML();
    incValueProgress();
    parentFrame.setJMenuBar(this.criaMenuBar());
    PainelStatusBar.setValueProgress(6);
    // parentFrame.setTitle("Associador de rtulos");
    tableLinCod = new TabelaAnaliseGeral(this, erros);
    arTextPainelCorrecao = new ArTextPainelCorrecao(this);
    incValueProgress();
    // scrollPaneCorrecaoLabel = new ConteudoCorrecaoLabel();
    analiseSistematica = new JButton();
    salvar = new JButton();

    cancelar = new JButton();

    salvarMod = new JButton();

    salvarPag = new JButton();

    aplicarPag = new JButton();

    aplicarTod = new JButton();

    strConteudoalt = new String();
    incValueProgress();
    btnSalvar = new JMenuItem(GERAL.BTN_SALVAR);
    PainelStatusBar.setValueProgress(10);
    pnRegra = new JPanel();
    lbRegras1 = new JLabel();
    lbRegras2 = new JLabel();
    pnSetaDescricao = new JPanel();
    spTextoDescricao = new JScrollPane();
    tArParticipRotulo = new TArParticipRotulo(this);
    conteudoDoAlt = new JTextArea();
    pnListaErros = new JPanel();
    scrollPanetabLinCod = new JScrollPane();
    incValueProgress();
    /**
     * Mostra pro usurio a imagem que est sem descrio
     */
    imagemSemDesc = new XHTMLPanel();

    pnBotoes = new JPanel();
    salvar.setEnabled(false);
    // salvaAlteracoes = new SalvaAlteracoes(boxCode.getTextPane(), salvar,
    // btnSalvar, parentFrame);
    adicionar = new JButton();
    aplicar = new JButton();
    conteudoParticRotulo = new ArrayList<String>();
    analiseSistematica.setEnabled(false);
    boxCode.getTextPane().setText(TxtBuffer.getContent());
    PainelStatusBar.setValueProgress(20);
    String fullUrl = this.enderecoImagem;
    System.out.println("\t\t\t\t\tendereo da imagem: " + fullUrl);
    SetImage setImage = new SetImage(this, fullUrl);
    setImage.start();
    incValueProgress();
    setBackground(CoresDefault.getCorPaineis());
    Container contentPane = this;// ??
    contentPane.setLayout(new GridLayout(2, 1));
    incValueProgress();
    // ======== pnRegra ========
    {
        pnRegra.setBorder(criaBorda(Ferramenta_Imagens.TITULO_REGRA));
        pnRegra.setLayout(new GridLayout(2, 1));
        pnRegra.add(lbRegras1);
        lbRegras1.setText(Ferramenta_Imagens.REGRAP1);
        lbRegras2.setText(Ferramenta_Imagens.REGRAP2);
        lbRegras1.setHorizontalAlignment(SwingConstants.CENTER);
        lbRegras2.setHorizontalAlignment(SwingConstants.CENTER);
        pnRegra.add(lbRegras1);
        pnRegra.add(lbRegras2);
        pnRegra.setPreferredSize(new Dimension(700, 60));
        incValueProgress();
    }
    PainelStatusBar.setValueProgress(30);
    // G_URLIcon.setIcon(lbTemp,
    // "http://pitecos.blogs.sapo.pt/arquivo/pai%20natal%20o5.%20jpg.jpg");
    JScrollPane sp = new JScrollPane();

    sp.setViewportView(imagemSemDesc);
    sp.setPreferredSize(new Dimension(500, 300));

    // ======== pnDescricao ========
    incValueProgress();
    // ---- Salvar ----
    salvarMod.setText(GERAL.SALVAR_MODIFICADAS);
    salvarMod.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            salvarModificadosActionPerformed(e);
        }
    });
    incValueProgress();
    salvarMod.setToolTipText(GERAL.DICA_SALVAR_MODIFICADOS);
    salvarMod.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SALVAR_MODIFICADOS);
    salvarMod.getAccessibleContext().setAccessibleName(GERAL.DICA_SALVAR_MODIFICADOS);
    salvarMod.setBounds(10, 0, 150, 25);
    PainelStatusBar.setValueProgress(40);
    salvarPag.setText(GERAL.SALVAR_ULTIMA);
    salvarPag.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            salvarPaginaActionPerformed(e);
        }
    });
    incValueProgress();
    salvarPag.setToolTipText(GERAL.DICA_SALVAR_ULTIMA_MODIFICADA);
    salvarPag.getAccessibleContext().setAccessibleDescription(GERAL.DICA_SALVAR_ULTIMA_MODIFICADA);
    salvarPag.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_ABRIR_HTML);
    salvarPag.setBounds(165, 0, 150, 25);
    incValueProgress();
    salvarMod.setEnabled(false);
    salvarPag.setEnabled(false);
    ArrayList<JButton> btnsSalvar = new ArrayList<JButton>();
    btnsSalvar.add(salvarMod);
    btnsSalvar.add(salvarPag);
    btnsSalvar.add(salvar);
    salvaAlteracoes = new SalvaAlteracoes(boxCode.getTextPane(), btnsSalvar, btnSalvar, parentFrame);
    aplicarPag.setText(GERAL.APLICAR_PAGINA);
    aplicarPag.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            aplicarPaginaActionPerformed(e);
        }
    });
    incValueProgress();
    PainelStatusBar.setValueProgress(50);
    aplicarPag.setToolTipText(GERAL.DICA_APLICA_PAGINA);
    aplicarPag.getAccessibleContext().setAccessibleDescription(GERAL.DICA_APLICA_PAGINA);
    aplicarPag.getAccessibleContext().setAccessibleName(GERAL.DICA_APLICA_PAGINA);
    aplicarPag.setBounds(320, 0, 150, 25);
    incValueProgress();
    aplicarTod.setText(GERAL.APLICA_TODOS);
    aplicarTod.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Thread t = new Thread(new Runnable() {
                public void run() {
                    aplicarATodosActionPerformed();
                }
            });
            t.start();
        }
    });
    incValueProgress();
    aplicarTod.setToolTipText(GERAL.DICA_APLICA_ULTIMA_TODOS);
    aplicarTod.getAccessibleContext().setAccessibleDescription(GERAL.DICA_APLICA_ULTIMA_TODOS);
    aplicarTod.getAccessibleContext().setAccessibleName(GERAL.DICA_APLICA_ULTIMA_TODOS);
    aplicarTod.setBounds(475, 0, 150, 25);
    aplicarPag.setEnabled(false);
    aplicarTod.setEnabled(false);
    PainelStatusBar.setValueProgress(60);
    incValueProgress();
    cancelar.setText(GERAL.TELA_ANTERIOR);
    cancelar.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            CancelarActionPerformed(e);
        }
    });

    cancelar.setToolTipText(Ferramenta_Imagens.DICA_BTN_CANCELAR);
    cancelar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_BTN_CANCELAR);
    cancelar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_BTN_CANCELAR);
    cancelar.setBounds(630, 0, 150, 25);
    incValueProgress();
    pnSetaDescricao.setBorder(criaBorda(Ferramenta_Imagens.TITULO_DIGITE_O_ALT));
    GridBagConstraints cons = new GridBagConstraints();
    GridBagLayout layout = new GridBagLayout();
    cons.fill = GridBagConstraints.BOTH;
    cons.weighty = 1;
    cons.weightx = 0.80;
    PainelStatusBar.setValueProgress(70);
    incValueProgress();
    pnSetaDescricao.setLayout(layout);
    cons.anchor = GridBagConstraints.SOUTHEAST;
    cons.insets = new Insets(0, 0, 0, 10);
    // ======== spParticRotulo ========
    conteudoDoAlt.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent arg0) {
        }

        public void keyTyped(KeyEvent arg0) {
        }

        public void keyReleased(KeyEvent arg0) {
            if (conteudoDoAlt.getText().length() == 0 || tableLinCod.getNumLinhas() < 1) {
                System.out.println("conteudo vazio");
                aplicarPag.setEnabled(false);
                aplicarTod.setEnabled(false);

            } else if (tableLinCod.getSelectedRow() != -1) {
                System.out.println("com conteudo");
                aplicarPag.setEnabled(true);
                aplicarTod.setEnabled(true);

            } else {
                aplicarTod.setEnabled(true);
            }
        }
    });

    {
        spTextoDescricao.setViewportView(conteudoDoAlt);
    }
    incValueProgress();
    // lbRegras1.setText(Reparo_Imagens.REGRAP2);
    // lbRegras1.setHorizontalAlignment(SwingConstants.CENTER);

    // pnRegra.add(lbRegras1);

    pnSetaDescricao.add(spTextoDescricao, cons);
    cons.weightx = 0.20;
    pnSetaDescricao.setPreferredSize(new Dimension(400, 60));

    // ======== pnListaErros ========
    {
        PainelStatusBar.setValueProgress(80);
        pnListaErros.setBorder(criaBorda(Ferramenta_Imagens.LISTA_ERROS));
        pnListaErros.setLayout(new BorderLayout());
        // ======== scrollPanetabLinCod ========
        {
            scrollPanetabLinCod.setViewportView(tableLinCod);
        }
        pnListaErros.add(scrollPanetabLinCod, BorderLayout.CENTER);
    }
    // ======== pnBotoes ========
    incValueProgress();
    {

        // pnBotoes.setBorder(criaBorda(""));

        pnBotoes.setLayout(null);
        // ---- adicionar ----
        adicionar.setText(Ferramenta_Imagens.BTN_ADICIONAR);
        adicionar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                adicionarActionPerformed(e);
            }
        });
        PainelStatusBar.setValueProgress(90);
        adicionar.setToolTipText(Ferramenta_Imagens.DICA_ADICIONAR);
        adicionar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_ADICIONAR);
        adicionar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_ADICIONAR);
        adicionar.setBounds(10, 5, 150, 25);
        // pnBotoes.add(adicionar);
        incValueProgress();
        // ---- aplicarRotulo ----
        aplicar.setEnabled(false);
        aplicar.setText(Ferramenta_Imagens.BTN_APLICAR);
        aplicar.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                aplicarRotuloActionPerformed(e);
            }
        });
        incValueProgress();
        aplicar.setToolTipText(Ferramenta_Imagens.DICA_APLICAR);
        aplicar.getAccessibleContext().setAccessibleDescription(Ferramenta_Imagens.DICA_APLICAR);
        aplicar.getAccessibleContext().setAccessibleName(Ferramenta_Imagens.DICA_APLICAR);
        aplicar.setBounds(10, 5, 150, 25);
        // pnBotoes.add(aplicar);
    }

    /*
     * Colocar os controles
     */
    pnRegra.setBackground(CoresDefault.getCorPaineis());
    regraFonteBtn.add(pnRegra, BorderLayout.NORTH);
    boxCode.setBorder(criaBorda(""));
    boxCode.setBackground(CoresDefault.getCorPaineis());
    incValueProgress();
    JSplitPane splitPane = null;

    Dimension minimumSize = new Dimension(0, 0);
    // JScrollPane ajudaScrollPane = new
    // JScrollPane(ajuda,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    PainelStatusBar.setValueProgress(93);
    sp.setMinimumSize(minimumSize);
    sp.setPreferredSize(new Dimension(150, 90));
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sp, boxCode);
    splitPane.setOneTouchExpandable(true);
    // splitPane.set
    // splitPane.setDividerLocation(0.95);
    int w = parentFrame.getWidth();
    int s = w / 4;
    splitPane.setDividerLocation(s);
    incValueProgress();
    // regraFonteBtn.add(scrollPaneCorrecaoLabel, BorderLayout.CENTER);
    regraFonteBtn.add(splitPane, BorderLayout.CENTER);
    pnBotoes.setPreferredSize(new Dimension(600, 35));
    pnBotoes.setBackground(CoresDefault.getCorPaineis());
    // regraFonteBtn.add(pnBotoes, BorderLayout.SOUTH);
    regraFonteBtn.setBackground(CoresDefault.getCorPaineis());
    contentPane.add(regraFonteBtn);
    PainelStatusBar.setValueProgress(96);
    JPanel textoErrosBtn = new JPanel();
    textoErrosBtn.setLayout(new BorderLayout());
    pnSetaDescricao.setBackground(CoresDefault.getCorPaineis());
    pnSetaDescricao.add(pnBotoes, cons);
    textoErrosBtn.add(pnSetaDescricao, BorderLayout.NORTH);

    textoErrosBtn.add(pnListaErros, BorderLayout.CENTER);
    JPanel pnSalvarCancelar = new JPanel();
    pnSalvarCancelar.setLayout(null);
    pnSalvarCancelar.setPreferredSize(new Dimension(600, 35));
    incValueProgress();
    pnSalvarCancelar.add(salvarMod);
    pnSalvarCancelar.add(salvarPag);
    pnSalvarCancelar.add(aplicarPag);
    pnSalvarCancelar.add(aplicarTod);
    pnSalvarCancelar.add(cancelar);
    pnSalvarCancelar.setBackground(CoresDefault.getCorPaineis());

    incValueProgress();

    textoErrosBtn.add(pnSalvarCancelar, BorderLayout.SOUTH);
    PainelStatusBar.setValueProgress(100);
    pnListaErros.setBackground(CoresDefault.getCorPaineis());
    textoErrosBtn.add(pnListaErros, BorderLayout.CENTER);
    contentPane.setBackground(CoresDefault.getCorPaineis());

    incValueProgress();

    contentPane.add(textoErrosBtn);
    System.out.println("\t\t\t" + TxtBuffer.getContent());

    incValueProgress();

    this.setVisible(true);

}