Search in sources :

Example 6 with JComboBox

use of javax.swing.JComboBox in project OpenNotebook by jaltekruse.

the class EnumeratedAdjuster method addPanelContent.

@Override
public void addPanelContent() {
    if (displayFormat == COMBO_BOX) {
        setLayout(new GridBagLayout());
        GridBagConstraints con = new GridBagConstraints();
        con.fill = GridBagConstraints.HORIZONTAL;
        con.weightx = .1;
        con.gridx = 0;
        con.gridy = 0;
        con.insets = new Insets(0, 10, 0, 0);
        add(new JLabel(mAtt.getName()), con);
        con.insets = new Insets(0, 10, 0, 5);
        con.weightx = 1;
        con.gridx = 1;
        final JComboBox valueChoices = new JComboBox(mAtt.getPossibleValues());
        valueChoices.setSelectedItem(mAtt.getValue());
        valueChoices.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent ev) {
                mAtt.setValue((String) valueChoices.getSelectedItem());
                if (notebookPanel != null) {
                    notebookPanel.getCurrentDocViewer().addUndoState();
                    notebookPanel.getCurrentDocViewer().repaintDoc();
                }
            }
        });
        this.add(valueChoices, con);
    } else if (displayFormat == RADIO_BUTTON_ROW) {
        setLayout(new GridBagLayout());
        GridBagConstraints con = new GridBagConstraints();
        con.fill = GridBagConstraints.HORIZONTAL;
        con.weightx = .1;
        con.gridwidth = mAtt.getPossibleValues().length;
        con.gridx = 0;
        con.gridy = 0;
        con.insets = new Insets(2, 2, 2, 2);
        Font f = new Font("Arial", Font.PLAIN, 12);
        Font smallF = new Font("Arial", Font.PLAIN, 11);
        JLabel label = new JLabel(mAtt.getName());
        label.setFont(f);
        add(label, con);
        con.gridwidth = 1;
        con.weightx = 1;
        con.gridy++;
        final ButtonGroup group = new ButtonGroup();
        for (final String s : mAtt.getPossibleValues()) {
            final JRadioButton button = new JRadioButton(s);
            button.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent ev) {
                    mAtt.setValue(s);
                    if (notebookPanel != null) {
                        notebookPanel.getCurrentDocViewer().addUndoState();
                        notebookPanel.getCurrentDocViewer().repaintDoc();
                    }
                }
            });
            if (mAtt.getValue().equals(s)) {
                button.setSelected(true);
            }
            button.setFont(smallF);
            this.add(button, con);
            group.add(button);
            con.gridx++;
        }
    } else if (displayFormat == RADIO_BUTTON_COLOUMN) {
    }
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JRadioButton(javax.swing.JRadioButton) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionListener(java.awt.event.ActionListener) ButtonGroup(javax.swing.ButtonGroup) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) Font(java.awt.Font)

Example 7 with JComboBox

use of javax.swing.JComboBox in project jadx by skylot.

the class LogViewer method initUI.

public final void initUI() {
    textPane = new RSyntaxTextArea();
    textPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
    JPanel controlPane = new JPanel();
    controlPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    @SuppressWarnings("unchecked") final JComboBox cb = new JComboBox(LEVEL_ITEMS);
    cb.setSelectedItem(level);
    cb.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int i = cb.getSelectedIndex();
            level = LEVEL_ITEMS[i];
            registerLogListener();
        }
    });
    JLabel levelLabel = new JLabel(NLS.str("log.level"));
    levelLabel.setLabelFor(cb);
    controlPane.add(levelLabel);
    controlPane.add(cb);
    JScrollPane scrollPane = new JScrollPane(textPane);
    JButton close = new JButton(NLS.str("tabs.close"));
    close.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            close();
        }
    });
    close.setAlignmentX(0.5f);
    Container contentPane = getContentPane();
    contentPane.add(controlPane, BorderLayout.PAGE_START);
    contentPane.add(scrollPane, BorderLayout.CENTER);
    contentPane.add(close, BorderLayout.PAGE_END);
    setTitle("Log Viewer");
    pack();
    setSize(800, 600);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setModalityType(ModalityType.MODELESS);
    setLocationRelativeTo(null);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) Container(java.awt.Container) RSyntaxTextArea(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea) JComboBox(javax.swing.JComboBox) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel)

Example 8 with JComboBox

use of javax.swing.JComboBox in project libgdx by libgdx.

the class DynamicsInfluencerPanel method initializeComponents.

protected void initializeComponents() {
    super.initializeComponents();
    JPanel velocitiesPanel = new JPanel();
    velocitiesPanel.setLayout(new GridBagLayout());
    {
        JPanel sideButtons = new JPanel(new GridBagLayout());
        velocitiesPanel.add(sideButtons, new GridBagConstraints(1, 0, 1, 1, 1, 1, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        {
            sideButtons.add(velocityBox = new JComboBox(new DefaultComboBoxModel()), new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
        }
        {
            JButton newButton = new JButton("New");
            sideButtons.add(newButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            newButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    createVelocity(velocityBox.getSelectedItem());
                }
            });
        }
        {
            JButton deleteButton = new JButton("Delete");
            sideButtons.add(deleteButton, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
            deleteButton.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent event) {
                    deleteVelocity();
                }
            });
        }
    }
    JScrollPane scroll = new JScrollPane();
    velocitiesPanel.add(scroll, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
    velocityTable = new JTable() {

        public Class getColumnClass(int column) {
            return column == 1 ? Boolean.class : super.getColumnClass(column);
        }

        @Override
        public Dimension getPreferredScrollableViewportSize() {
            Dimension dim = super.getPreferredScrollableViewportSize();
            dim.height = getPreferredSize().height;
            return dim;
        }
    };
    velocityTable.getTableHeader().setReorderingAllowed(false);
    velocityTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scroll.setViewportView(velocityTable);
    velocityTableModel = new DefaultTableModel(new String[0][0], new String[] { "Velocity", "Active" });
    velocityTable.setModel(velocityTableModel);
    velocityTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent event) {
            if (event.getValueIsAdjusting())
                return;
            velocitySelected();
        }
    });
    velocityTableModel.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent event) {
            if (event.getColumn() != 1)
                return;
            velocityChecked(event.getFirstRow(), (Boolean) velocityTable.getValueAt(event.getFirstRow(), 1));
        }
    });
    //Velocity values
    emptyPanel = new ParticleValuePanel(editor, "", "", true, false);
    strengthVelocityPanel = new StrengthVelocityPanel(editor, null, "Life", "", "");
    angularVelocityPanel = new AngularVelocityPanel(editor, null, "Life", "", "");
    strengthVelocityPanel.setVisible(false);
    angularVelocityPanel.setVisible(false);
    emptyPanel.setVisible(false);
    strengthVelocityPanel.setIsAlwayShown(true);
    angularVelocityPanel.setIsAlwayShown(true);
    emptyPanel.setIsAlwayShown(true);
    emptyPanel.setValue(null);
    //Assemble
    int i = 0;
    addContent(i++, 0, velocitiesPanel);
    addContent(i++, 0, strengthVelocityPanel);
    addContent(i++, 0, angularVelocityPanel);
    addContent(i++, 0, emptyPanel);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) TableModelEvent(javax.swing.event.TableModelEvent) DefaultTableModel(javax.swing.table.DefaultTableModel) JButton(javax.swing.JButton) ListSelectionEvent(javax.swing.event.ListSelectionEvent) JScrollPane(javax.swing.JScrollPane) JComboBox(javax.swing.JComboBox) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) ListSelectionListener(javax.swing.event.ListSelectionListener) ActionListener(java.awt.event.ActionListener) JTable(javax.swing.JTable) TableModelListener(javax.swing.event.TableModelListener)

Example 9 with JComboBox

use of javax.swing.JComboBox 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 10 with JComboBox

use of javax.swing.JComboBox in project libgdx by libgdx.

the class RegionPickerPanel method initializeComponents.

private void initializeComponents() {
    setLayout(new GridBagLayout());
    content = new JPanel();
    atlasPanel = new TextureAtlasPanel();
    texturePanel = new TexturePanel();
    CustomCardLayout cardLayout = new CustomCardLayout();
    content.setLayout(cardLayout);
    content.add(atlasPanel, "atlas");
    content.add(texturePanel, "texture");
    add(content, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    JPanel controls = new JPanel(new GridBagLayout());
    controls.add(selectButton = new JButton("Select"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(new JSeparator(JSeparator.HORIZONTAL), new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
    //Pick
    JPanel pickPanel = new JPanel(new GridBagLayout());
    pickPanel.add(selectAllButton = new JButton("Pick All"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    pickPanel.add(clearButton = new JButton("Clear Selection"), new GridBagConstraints(1, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    pickPanel.add(reverseButton = new JButton("Reverse Selection"), new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(pickPanel, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    //Generation
    generationPanel = new JPanel(new GridBagLayout());
    generationPanel.add(new JLabel("Rows"), new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    generationPanel.add(rowSlider = new Slider(1, 1, 9999, 1), new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    generationPanel.add(new JLabel("Columns"), new GridBagConstraints(0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    generationPanel.add(columnSlider = new Slider(1, 1, 9999, 1), new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    generationPanel.add(generateBox = new JComboBox(new DefaultComboBoxModel(GenerationMode.values())), new GridBagConstraints(0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    generationPanel.add(generateButton = new JButton("Generate"), new GridBagConstraints(1, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    controls.add(new JSeparator(JSeparator.HORIZONTAL), new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 6, 0), 0, 0));
    controls.add(generationPanel, new GridBagConstraints(0, -1, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    add(controls, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
    selectButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            JPanel panel = ((CustomCardLayout) content.getLayout()).getCurrentCard(content);
            TexturePanel currentTexturePanel = panel == atlasPanel ? atlasPanel.getCurrentRegionPanel() : texturePanel;
            listener.onRegionsSelected(currentTexturePanel.selectedRegions);
        }
    });
    selectAllButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            JPanel panel = ((CustomCardLayout) content.getLayout()).getCurrentCard(content);
            TexturePanel currentTexturePanel = panel == atlasPanel ? atlasPanel.getCurrentRegionPanel() : texturePanel;
            currentTexturePanel.selectAll();
        }
    });
    reverseButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            JPanel panel = ((CustomCardLayout) content.getLayout()).getCurrentCard(content);
            TexturePanel currentTexturePanel = panel == atlasPanel ? atlasPanel.getCurrentRegionPanel() : texturePanel;
            currentTexturePanel.selectedRegions.reverse();
            currentTexturePanel.revalidate();
            currentTexturePanel.repaint();
        }
    });
    clearButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            JPanel panel = ((CustomCardLayout) content.getLayout()).getCurrentCard(content);
            TexturePanel currentPanel = panel == atlasPanel ? atlasPanel.getCurrentRegionPanel() : texturePanel;
            currentPanel.clearSelection();
        }
    });
    generateButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            generateRegions((GenerationMode) generateBox.getSelectedItem());
            texturePanel.revalidate();
            texturePanel.repaint();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) JSeparator(javax.swing.JSeparator) ActionListener(java.awt.event.ActionListener)

Aggregations

JComboBox (javax.swing.JComboBox)150 JLabel (javax.swing.JLabel)66 JPanel (javax.swing.JPanel)57 ActionEvent (java.awt.event.ActionEvent)51 ActionListener (java.awt.event.ActionListener)48 JButton (javax.swing.JButton)47 JScrollPane (javax.swing.JScrollPane)28 JTextField (javax.swing.JTextField)27 BoxLayout (javax.swing.BoxLayout)26 Dimension (java.awt.Dimension)25 JCheckBox (javax.swing.JCheckBox)23 JTable (javax.swing.JTable)22 BorderLayout (java.awt.BorderLayout)21 GridBagLayout (java.awt.GridBagLayout)20 Insets (java.awt.Insets)20 GridBagConstraints (java.awt.GridBagConstraints)19 FlowLayout (java.awt.FlowLayout)18 DefaultCellEditor (javax.swing.DefaultCellEditor)17 TableColumn (javax.swing.table.TableColumn)14 ItemEvent (java.awt.event.ItemEvent)11