Search in sources :

Example 26 with GridBagLayout

use of java.awt.GridBagLayout 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)

Example 27 with GridBagLayout

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

the class ScaledNumericPanel method initializeComponents.

private void initializeComponents(String chartTitle) {
    JPanel contentPanel = getContentPanel();
    {
        formPanel = new JPanel(new GridBagLayout());
        contentPanel.add(formPanel, new GridBagConstraints(5, 5, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
        {
            JLabel label = new JLabel("High:");
            formPanel.add(label, new GridBagConstraints(2, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
        }
        {
            highMinSlider = new Slider(0, -99999, 99999, 1f, -400, 400);
            formPanel.add(highMinSlider, new GridBagConstraints(3, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        }
        {
            highMaxSlider = new Slider(0, -99999, 99999, 1f, -400, 400);
            formPanel.add(highMaxSlider, new GridBagConstraints(4, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
        }
        {
            highRangeButton = new JButton("<");
            highRangeButton.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
            formPanel.add(highRangeButton, new GridBagConstraints(5, 1, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 1, 0, 0), 0, 0));
        }
        {
            JLabel label = new JLabel("Low:");
            formPanel.add(label, new GridBagConstraints(2, 2, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 6), 0, 0));
        }
        {
            lowMinSlider = new Slider(0, -99999, 99999, 1f, -400, 400);
            formPanel.add(lowMinSlider, new GridBagConstraints(3, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        }
        {
            lowMaxSlider = new Slider(0, -99999, 99999, 1f, -400, 400);
            formPanel.add(lowMaxSlider, new GridBagConstraints(4, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
        }
        {
            lowRangeButton = new JButton("<");
            lowRangeButton.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
            formPanel.add(lowRangeButton, new GridBagConstraints(5, 2, 1, 1, 0.0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 1, 0, 0), 0, 0));
        }
    }
    {
        chart = new Chart(chartTitle) {

            public void pointsChanged() {
                value.setTimeline(chart.getValuesX());
                value.setScaling(chart.getValuesY());
            }
        };
        contentPanel.add(chart, new GridBagConstraints(6, 5, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
        chart.setPreferredSize(new Dimension(150, 30));
    }
    {
        expandButton = new JButton("+");
        contentPanel.add(expandButton, new GridBagConstraints(7, 5, 1, 1, 1, 0, GridBagConstraints.SOUTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0));
        expandButton.setBorder(BorderFactory.createEmptyBorder(4, 8, 4, 8));
    }
    {
        relativeCheckBox = new JCheckBox("Relative");
        contentPanel.add(relativeCheckBox, new GridBagConstraints(7, 5, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 6, 0, 0), 0, 0));
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension)

Example 28 with GridBagLayout

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

the class InputPanel method makeFoundStatsBox.

//separated out to make constructor more readable
private JPanel makeFoundStatsBox() {
    JPanel foundStatsBox = new JPanel();
    foundStatsBox.setLayout(new GridBagLayout());
    Box labelBox = Box.createHorizontalBox();
    foundStats = new JLabel(" ");
    labelBox.add(foundStats);
    historyButton = new JButton("Statistics");
    historyButton.setEnabled(false);
    historyButton.addActionListener(this);
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.7;
    foundStatsBox.add(labelBox, c);
    c.weightx = .3;
    c.gridwidth = 1;
    foundStatsBox.add(historyButton);
    return foundStatsBox;
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout)

Example 29 with GridBagLayout

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

the class InputPanel method makeTregexPatternArea.

//separated out to make constructor more readable
private JPanel makeTregexPatternArea() {
    //combo box with recent searches
    recentTregexPatternsModel = new DefaultComboBoxModel<>();
    recentTregexPatterns = new JComboBox<>(recentTregexPatternsModel);
    recentTregexPatterns.setMinimumSize(new Dimension(120, 24));
    recentTregexPatterns.addActionListener(this);
    JLabel recentLabel = new JLabel("Recent: ");
    //interactive tregex pattern
    JLabel patternLabel = new JLabel("Pattern: ");
    tregexPattern = new JTextArea();
    tregexPattern.setFocusTraversalKeysEnabled(true);
    tregexPattern.setLineWrap(true);
    JScrollPane patternScroller = new JScrollPane(tregexPattern);
    patternScroller.setBorder(BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
    //add them into the panel
    JPanel tregexInput = new JPanel();
    tregexInput.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    tregexInput.add(recentLabel, c);
    c.weightx = 12.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridx = 1;
    tregexInput.add(recentTregexPatterns, c);
    c.weightx = 1.0;
    //reset to default
    c.gridwidth = 1;
    c.gridheight = GridBagConstraints.REMAINDER;
    c.gridx = 0;
    c.gridy = 1;
    tregexInput.add(patternLabel, c);
    c.gridx = 1;
    c.weightx = 12.0;
    c.weighty = 2.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    tregexInput.add(patternScroller, c);
    return tregexInput;
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) Dimension(java.awt.Dimension)

Example 30 with GridBagLayout

use of java.awt.GridBagLayout in project bigbluebutton by bigbluebutton.

the class CaptureRegionFrame method createMoveBar.

private JPanel createMoveBar() {
    final CirclePanel movePanel = new CirclePanel();
    movePanel.setPreferredSize(new Dimension(MOVE_BAR_SIZE, MOVE_BAR_SIZE));
    movePanel.setLayout(new GridBagLayout());
    BufferedImage moveCursorImage = null;
    try {
        // Image was taken from http://www.iconarchive.com/show/oxygen-icons-by-oxygen-icons.org/Actions-transform-move-icon.html
        moveCursorImage = ImageIO.read(getClass().getResourceAsStream("/images/move-cursor.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    JLabel movePicLabel = new JLabel(new ImageIcon(moveCursorImage));
    movePanel.add(movePicLabel);
    return movePanel;
}
Also used : ImageIcon(javax.swing.ImageIcon) GridBagLayout(java.awt.GridBagLayout) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) IOException(java.io.IOException) BufferedImage(java.awt.image.BufferedImage)

Aggregations

GridBagLayout (java.awt.GridBagLayout)438 GridBagConstraints (java.awt.GridBagConstraints)280 JPanel (javax.swing.JPanel)275 JLabel (javax.swing.JLabel)243 Insets (java.awt.Insets)181 Dimension (java.awt.Dimension)125 JButton (javax.swing.JButton)110 JScrollPane (javax.swing.JScrollPane)94 ActionEvent (java.awt.event.ActionEvent)87 ActionListener (java.awt.event.ActionListener)69 BorderLayout (java.awt.BorderLayout)57 BoxLayout (javax.swing.BoxLayout)57 JCheckBox (javax.swing.JCheckBox)44 JTextField (javax.swing.JTextField)42 FlowLayout (java.awt.FlowLayout)32 ButtonGroup (javax.swing.ButtonGroup)31 JComboBox (javax.swing.JComboBox)24 ImageIcon (javax.swing.ImageIcon)20 TitledBorder (javax.swing.border.TitledBorder)20 WindowEvent (java.awt.event.WindowEvent)19