Search in sources :

Example 31 with BorderLayout

use of java.awt.BorderLayout in project libgdx by libgdx.

the class Hiero method initializeComponents.

private void initializeComponents() {
    getContentPane().setLayout(new GridBagLayout());
    JPanel leftSidePanel = new JPanel();
    leftSidePanel.setLayout(new GridBagLayout());
    getContentPane().add(leftSidePanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    {
        JPanel fontPanel = new JPanel();
        leftSidePanel.add(fontPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
        fontPanel.setLayout(new GridBagLayout());
        fontPanel.setBorder(BorderFactory.createTitledBorder("Font"));
        {
            fontSizeSpinner = new JSpinner(new SpinnerNumberModel(32, 0, 256, 1));
            fontPanel.add(fontSizeSpinner, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
            ((JSpinner.DefaultEditor) fontSizeSpinner.getEditor()).getTextField().setColumns(2);
        }
        {
            JScrollPane fontScroll = new JScrollPane();
            fontPanel.add(fontScroll, new GridBagConstraints(1, 1, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
            {
                fontListModel = new DefaultComboBoxModel(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());
                fontList = new JList();
                fontScroll.setViewportView(fontList);
                fontList.setModel(fontListModel);
                fontList.setVisibleRowCount(6);
                fontList.setSelectedIndex(0);
                fontScroll.setMinimumSize(new Dimension(220, fontList.getPreferredScrollableViewportSize().height));
            }
        }
        {
            systemFontRadio = new JRadioButton("System:", true);
            fontPanel.add(systemFontRadio, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 5), 0, 0));
            systemFontRadio.setMargin(new Insets(0, 0, 0, 0));
        }
        {
            fontFileRadio = new JRadioButton("File:");
            fontPanel.add(fontFileRadio, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
            fontFileRadio.setMargin(new Insets(0, 0, 0, 0));
        }
        {
            fontFileText = new JTextField();
            fontPanel.add(fontFileText, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
        }
        {
            fontPanel.add(new JLabel("Size:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
        }
        {
            unicodePanel = new JPanel(new GridBagLayout());
            fontPanel.add(unicodePanel, new GridBagConstraints(2, 3, 2, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 5), 0, 0));
            {
                boldCheckBox = new JCheckBox("Bold");
                unicodePanel.add(boldCheckBox, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
            {
                italicCheckBox = new JCheckBox("Italic");
                unicodePanel.add(italicCheckBox, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
        }
        {
            bitmapPanel = new JPanel(new GridBagLayout());
            fontPanel.add(bitmapPanel, new GridBagConstraints(2, 3, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
            {
                bitmapPanel.add(new JLabel("Gamma:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
            {
                gammaSpinner = new JSpinner(new SpinnerNumberModel(1.8f, 0, 30, 0.01));
                ((JSpinner.DefaultEditor) gammaSpinner.getEditor()).getTextField().setColumns(2);
                bitmapPanel.add(gammaSpinner, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
            }
            {
                monoCheckBox = new JCheckBox("Mono");
                bitmapPanel.add(monoCheckBox, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
        }
        {
            browseButton = new JButton("...");
            fontPanel.add(browseButton, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            browseButton.setMargin(new Insets(0, 0, 0, 0));
        }
        {
            fontPanel.add(new JLabel("Rendering:"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
        }
        {
            JPanel renderingPanel = new JPanel(new GridBagLayout());
            fontPanel.add(renderingPanel, new GridBagConstraints(1, 4, 3, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            {
                freeTypeRadio = new JRadioButton("FreeType");
                renderingPanel.add(freeTypeRadio, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
            {
                javaRadio = new JRadioButton("Java");
                renderingPanel.add(javaRadio, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
            {
                nativeRadio = new JRadioButton("Native");
                renderingPanel.add(nativeRadio, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
        }
        ButtonGroup buttonGroup = new ButtonGroup();
        buttonGroup.add(systemFontRadio);
        buttonGroup.add(fontFileRadio);
        buttonGroup = new ButtonGroup();
        buttonGroup.add(freeTypeRadio);
        buttonGroup.add(javaRadio);
        buttonGroup.add(nativeRadio);
        freeTypeRadio.setSelected(true);
    }
    {
        JPanel samplePanel = new JPanel();
        leftSidePanel.add(samplePanel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 5, 5), 0, 0));
        samplePanel.setLayout(new GridBagLayout());
        samplePanel.setBorder(BorderFactory.createTitledBorder("Sample Text"));
        {
            JScrollPane textScroll = new JScrollPane();
            samplePanel.add(textScroll, new GridBagConstraints(0, 0, 4, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
            {
                sampleTextPane = new JTextPane();
                textScroll.setViewportView(sampleTextPane);
            }
        }
        {
            sampleNeheButton = new JButton();
            sampleNeheButton.setText("NEHE");
            samplePanel.add(sampleNeheButton, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
        }
        {
            sampleAsciiButton = new JButton();
            sampleAsciiButton.setText("ASCII");
            samplePanel.add(sampleAsciiButton, new GridBagConstraints(3, 1, 1, 1, 0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
        }
        {
            sampleExtendedButton = new JButton();
            sampleExtendedButton.setText("Extended");
            samplePanel.add(sampleExtendedButton, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
        }
    }
    {
        JPanel renderingPanel = new JPanel();
        leftSidePanel.add(renderingPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
        renderingPanel.setBorder(BorderFactory.createTitledBorder("Rendering"));
        renderingPanel.setLayout(new GridBagLayout());
        {
            JPanel wrapperPanel = new JPanel();
            renderingPanel.add(wrapperPanel, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0));
            wrapperPanel.setLayout(new BorderLayout());
            wrapperPanel.setBackground(java.awt.Color.white);
            {
                gamePanel = new JPanel();
                wrapperPanel.add(gamePanel);
                gamePanel.setLayout(new BorderLayout());
                gamePanel.setBackground(java.awt.Color.white);
            }
        }
        {
            glyphCachePanel = new JPanel() {

                private int maxWidth;

                public Dimension getPreferredSize() {
                    // Keep glyphCachePanel width from ever going down so the CanvasGameContainer doesn't change sizes and flicker.
                    Dimension size = super.getPreferredSize();
                    maxWidth = Math.max(maxWidth, size.width);
                    size.width = maxWidth;
                    return size;
                }
            };
            glyphCachePanel.setVisible(false);
            renderingPanel.add(glyphCachePanel, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            glyphCachePanel.setLayout(new GridBagLayout());
            {
                glyphCachePanel.add(new JLabel("Glyphs:"), new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
            }
            {
                glyphCachePanel.add(new JLabel("Pages:"), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
            }
            {
                glyphCachePanel.add(new JLabel("Page width:"), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
            }
            {
                glyphCachePanel.add(new JLabel("Page height:"), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
            }
            {
                glyphPageWidthCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] { new Integer(32), new Integer(64), new Integer(128), new Integer(256), new Integer(512), new Integer(1024), new Integer(2048) }));
                glyphCachePanel.add(glyphPageWidthCombo, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
                glyphPageWidthCombo.setSelectedIndex(4);
            }
            {
                glyphPageHeightCombo = new JComboBox(new DefaultComboBoxModel(new Integer[] { new Integer(32), new Integer(64), new Integer(128), new Integer(256), new Integer(512), new Integer(1024), new Integer(2048) }));
                glyphCachePanel.add(glyphPageHeightCombo, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
                glyphPageHeightCombo.setSelectedIndex(4);
            }
            {
                resetCacheButton = new JButton("Reset Cache");
                glyphCachePanel.add(resetCacheButton, new GridBagConstraints(0, 6, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
            }
            {
                glyphPagesTotalLabel = new JLabel("1");
                glyphCachePanel.add(glyphPagesTotalLabel, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
            {
                glyphsTotalLabel = new JLabel("0");
                glyphCachePanel.add(glyphsTotalLabel, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
            {
                glyphPageComboModel = new DefaultComboBoxModel();
                glyphPageCombo = new JComboBox();
                glyphCachePanel.add(glyphPageCombo, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
                glyphPageCombo.setModel(glyphPageComboModel);
            }
            {
                glyphCachePanel.add(new JLabel("View:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
            }
        }
        {
            JPanel radioButtonsPanel = new JPanel();
            renderingPanel.add(radioButtonsPanel, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
            radioButtonsPanel.setLayout(new GridBagLayout());
            {
                sampleTextRadio = new JRadioButton("Sample text");
                radioButtonsPanel.add(sampleTextRadio, new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
                sampleTextRadio.setSelected(true);
            }
            {
                glyphCacheRadio = new JRadioButton("Glyph cache");
                radioButtonsPanel.add(glyphCacheRadio, new GridBagConstraints(3, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
            {
                radioButtonsPanel.add(new JLabel("Background:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 5, 5, 5), 0, 0));
            }
            {
                backgroundColorLabel = new JLabel();
                radioButtonsPanel.add(backgroundColorLabel, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 5), 0, 0));
            }
            ButtonGroup buttonGroup = new ButtonGroup();
            buttonGroup.add(glyphCacheRadio);
            buttonGroup.add(sampleTextRadio);
        }
    }
    JPanel rightSidePanel = new JPanel();
    rightSidePanel.setLayout(new GridBagLayout());
    getContentPane().add(rightSidePanel, new GridBagConstraints(1, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    {
        JPanel paddingPanel = new JPanel();
        paddingPanel.setLayout(new GridBagLayout());
        rightSidePanel.add(paddingPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
        paddingPanel.setBorder(BorderFactory.createTitledBorder("Padding"));
        {
            padTopSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
            paddingPanel.add(padTopSpinner, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            ((JSpinner.DefaultEditor) padTopSpinner.getEditor()).getTextField().setColumns(2);
        }
        {
            padRightSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
            paddingPanel.add(padRightSpinner, new GridBagConstraints(2, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 5), 0, 0));
            ((JSpinner.DefaultEditor) padRightSpinner.getEditor()).getTextField().setColumns(2);
        }
        {
            padLeftSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
            paddingPanel.add(padLeftSpinner, new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0));
            ((JSpinner.DefaultEditor) padLeftSpinner.getEditor()).getTextField().setColumns(2);
        }
        {
            padBottomSpinner = new JSpinner(new SpinnerNumberModel(1, 0, 999, 1));
            paddingPanel.add(padBottomSpinner, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            ((JSpinner.DefaultEditor) padBottomSpinner.getEditor()).getTextField().setColumns(2);
        }
        {
            JPanel advancePanel = new JPanel();
            FlowLayout advancePanelLayout = new FlowLayout();
            advancePanel.setLayout(advancePanelLayout);
            paddingPanel.add(advancePanel, new GridBagConstraints(0, 4, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            {
                advancePanel.add(new JLabel("X:"));
            }
            {
                padAdvanceXSpinner = new JSpinner(new SpinnerNumberModel(-2, -999, 999, 1));
                advancePanel.add(padAdvanceXSpinner);
                ((JSpinner.DefaultEditor) padAdvanceXSpinner.getEditor()).getTextField().setColumns(2);
            }
            {
                advancePanel.add(new JLabel("Y:"));
            }
            {
                padAdvanceYSpinner = new JSpinner(new SpinnerNumberModel(-2, -999, 999, 1));
                advancePanel.add(padAdvanceYSpinner);
                ((JSpinner.DefaultEditor) padAdvanceYSpinner.getEditor()).getTextField().setColumns(2);
            }
        }
    }
    {
        effectsPanel = new JPanel();
        effectsPanel.setLayout(new GridBagLayout());
        rightSidePanel.add(effectsPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 0, 5, 5), 0, 0));
        effectsPanel.setBorder(BorderFactory.createTitledBorder("Effects"));
        effectsPanel.setMinimumSize(new Dimension(210, 1));
        {
            effectsScroll = new JScrollPane();
            effectsPanel.add(effectsScroll, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0));
            {
                effectsListModel = new DefaultComboBoxModel();
                effectsList = new JList();
                effectsScroll.setViewportView(effectsList);
                effectsList.setModel(effectsListModel);
                effectsList.setVisibleRowCount(7);
                effectsScroll.setMinimumSize(effectsList.getPreferredScrollableViewportSize());
            }
        }
        {
            addEffectButton = new JButton("Add");
            effectsPanel.add(addEffectButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 5, 6, 5), 0, 0));
            addEffectButton.setEnabled(false);
        }
        {
            appliedEffectsScroll = new JScrollPane();
            effectsPanel.add(appliedEffectsScroll, new GridBagConstraints(1, 3, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.BOTH, new Insets(0, 0, 5, 0), 0, 0));
            appliedEffectsScroll.setBorder(new EmptyBorder(0, 0, 0, 0));
            appliedEffectsScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
            {
                JPanel panel = new JPanel();
                panel.setLayout(new GridBagLayout());
                appliedEffectsScroll.setViewportView(panel);
                {
                    appliedEffectsPanel = new JPanel();
                    appliedEffectsPanel.setLayout(new GridBagLayout());
                    panel.add(appliedEffectsPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
                    appliedEffectsPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, java.awt.Color.black));
                }
            }
        }
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) FlowLayout(java.awt.FlowLayout) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) SpinnerNumberModel(javax.swing.SpinnerNumberModel) JCheckBox(javax.swing.JCheckBox) JTextPane(javax.swing.JTextPane) BorderLayout(java.awt.BorderLayout) ButtonGroup(javax.swing.ButtonGroup) JSpinner(javax.swing.JSpinner) EmptyBorder(javax.swing.border.EmptyBorder) JList(javax.swing.JList)

Example 32 with BorderLayout

use of java.awt.BorderLayout in project CoreNLP by stanfordnlp.

the class TregexGUI method doFileFilters.

private void doFileFilters(File[] files) {
    //System.out.println("Doing file filters");
    final File[] cFiles = files;
    final JPanel fileFilterPanel = new JPanel();
    fileFilterPanel.setLayout(new BoxLayout(fileFilterPanel, BoxLayout.PAGE_AXIS));
    JLabel text = new JLabel("<html>Please indicate any constraints on the files you want to load. All files in specified folders that satisfy all of the given constraints will be loaded. Just press Okay to load all files.</html>");
    //text.setBorder(BorderFactory.createLineBorder(Color.black));
    text.setAlignmentX(SwingConstants.LEADING);
    JPanel textPanel = new JPanel(new BorderLayout());
    textPanel.setPreferredSize(new Dimension(100, 50));
    //textPanel.setBorder(BorderFactory.createLineBorder(Color.black));
    textPanel.add(text);
    fileFilterPanel.add(textPanel);
    fileFilterPanel.add(Box.createVerticalStrut(5));
    Box defaultFilter = getNewFilter();
    //defaultFilter.setBorder(BorderFactory.createLineBorder(Color.black));
    //fileFilterPanel.setBorder(BorderFactory.createLineBorder(Color.black));
    fileFilterPanel.add(defaultFilter);
    final JOptionPane fileFilterDialog = new JOptionPane();
    fileFilterDialog.setMessage(fileFilterPanel);
    JButton[] options = new JButton[3];
    JButton okay = new JButton("Okay");
    JButton add = new JButton("Add another filter");
    JButton cancel = new JButton("Cancel");
    options[0] = okay;
    options[1] = add;
    options[2] = cancel;
    fileFilterDialog.setOptions(options);
    final JDialog dialog = fileFilterDialog.createDialog(null, "Set file filters...");
    okay.addActionListener(arg0 -> {
        final EnumMap<FilterType, String> filters = getFilters(fileFilterPanel);
        if (filters.containsKey(FilterType.isInRange)) {
            try {
                new NumberRangesFileFilter(filters.get(FilterType.isInRange), false);
            } catch (Exception e) {
                JOptionPane.showMessageDialog(dialog, new JLabel("<html>Please check the range you specified for the file number.  Ranges must be numerical, and disjoint <br>ranges should be separated by commas.  For example \"1-200,250-375\" is a valid range.</html>"), "Error in File Number Range", JOptionPane.ERROR_MESSAGE);
                return;
            }
        }
        dialog.setVisible(false);
        startFileLoadingThread(filters, cFiles);
    });
    add.addActionListener(e -> {
        fileFilterPanel.add(getNewFilter());
        dialog.pack();
    });
    cancel.addActionListener(e -> dialog.setVisible(false));
    dialog.getRootPane().setDefaultButton(okay);
    dialog.pack();
    dialog.setLocationRelativeTo(this);
    dialog.setVisible(true);
}
Also used : NumberRangesFileFilter(edu.stanford.nlp.io.NumberRangesFileFilter) Dimension(java.awt.Dimension) IOException(java.io.IOException) BorderLayout(java.awt.BorderLayout) File(java.io.File)

Example 33 with BorderLayout

use of java.awt.BorderLayout in project smile by haifengl.

the class ClassificationDemo method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if ("startButton".equals(e.getActionCommand())) {
        Thread thread = new Thread(this);
        thread.start();
    } else if ("datasetBox".equals(e.getActionCommand())) {
        datasetIndex = datasetBox.getSelectedIndex();
        if (dataset[datasetIndex] == null) {
            DelimitedTextParser parser = new DelimitedTextParser();
            parser.setDelimiter("[\t ]+");
            parser.setResponseIndex(new NominalAttribute("class"), 0);
            try {
                dataset[datasetIndex] = parser.parse(datasetName[datasetIndex], smile.data.parser.IOUtils.getTestDataFile(datasource[datasetIndex]));
            } catch (Exception ex) {
                JOptionPane.showMessageDialog(null, "Failed to load dataset.", "ERROR", JOptionPane.ERROR_MESSAGE);
                System.err.println(ex);
            }
        }
        double[][] data = dataset[datasetIndex].toArray(new double[dataset[datasetIndex].size()][]);
        int[] label = dataset[datasetIndex].toArray(new int[dataset[datasetIndex].size()]);
        if (data.length < 500) {
            pointLegend = 'o';
        } else {
            pointLegend = '.';
        }
        PlotCanvas canvas = ScatterPlot.plot(data, pointLegend);
        for (int i = 0; i < data.length; i++) {
            canvas.point(pointLegend, Palette.COLORS[label[i]], data[i]);
        }
        BorderLayout layout = (BorderLayout) getLayout();
        remove(layout.getLayoutComponent(BorderLayout.CENTER));
        add(canvas, BorderLayout.CENTER);
        validate();
    }
}
Also used : DelimitedTextParser(smile.data.parser.DelimitedTextParser) NominalAttribute(smile.data.NominalAttribute) BorderLayout(java.awt.BorderLayout) PlotCanvas(smile.plot.PlotCanvas)

Example 34 with BorderLayout

use of java.awt.BorderLayout in project smile by haifengl.

the class PlotCanvas method initCanvas.

/**
     * Initialize the canvas.
     */
private void initCanvas() {
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    if (ge.isHeadless()) {
        setPreferredSize(new Dimension(1600, 1200));
    }
    setLayout(new BorderLayout());
    canvas = new MathCanvas();
    add(canvas, BorderLayout.CENTER);
    initContextMenauAndToolBar();
// set a new dismiss delay to a really big value, default is 4 sec.
//ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);
}
Also used : BorderLayout(java.awt.BorderLayout) Dimension(java.awt.Dimension) GraphicsEnvironment(java.awt.GraphicsEnvironment)

Example 35 with BorderLayout

use of java.awt.BorderLayout in project smile by haifengl.

the class FontChooser method getFontSizePanel.

private JPanel getFontSizePanel() {
    if (fontSizePanel == null) {
        fontSizePanel = new JPanel();
        fontSizePanel.setLayout(new BorderLayout());
        fontSizePanel.setPreferredSize(new Dimension(70, 130));
        fontSizePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        JScrollPane scrollPane = new JScrollPane(getFontSizeList());
        scrollPane.getVerticalScrollBar().setFocusable(false);
        scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        JPanel p = new JPanel();
        p.setLayout(new BorderLayout());
        p.add(getFontSizeTextField(), BorderLayout.NORTH);
        p.add(scrollPane, BorderLayout.CENTER);
        JLabel label = new JLabel(getMessage("FontSize"));
        label.setHorizontalAlignment(JLabel.LEFT);
        label.setHorizontalTextPosition(JLabel.LEFT);
        label.setLabelFor(getFontSizeTextField());
        label.setDisplayedMnemonic('S');
        fontSizePanel.add(label, BorderLayout.NORTH);
        fontSizePanel.add(p, BorderLayout.CENTER);
    }
    return fontSizePanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Aggregations

BorderLayout (java.awt.BorderLayout)761 JPanel (javax.swing.JPanel)514 JLabel (javax.swing.JLabel)238 JScrollPane (javax.swing.JScrollPane)191 Dimension (java.awt.Dimension)155 JButton (javax.swing.JButton)134 FlowLayout (java.awt.FlowLayout)90 ActionEvent (java.awt.event.ActionEvent)88 JTextField (javax.swing.JTextField)85 EmptyBorder (javax.swing.border.EmptyBorder)73 ActionListener (java.awt.event.ActionListener)70 JCheckBox (javax.swing.JCheckBox)69 Insets (java.awt.Insets)64 BoxLayout (javax.swing.BoxLayout)62 GridBagConstraints (java.awt.GridBagConstraints)57 GridBagLayout (java.awt.GridBagLayout)57 JTable (javax.swing.JTable)57 JTextArea (javax.swing.JTextArea)52 GridLayout (java.awt.GridLayout)49 Box (javax.swing.Box)45