Search in sources :

Example 1 with JSlider

use of javax.swing.JSlider in project jna by java-native-access.

the class AlphaMaskDemo2 method run.

public void run() {
    // Must find a graphics configuration with a depth of 32 bits
    GraphicsConfiguration gconfig = WindowUtils.getAlphaCompatibleGraphicsConfiguration();
    frame = new JFrame("Alpha Mask Demo");
    alphaWindow = new JWindow(frame, gconfig);
    icon = new JLabel();
    icon.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    alphaWindow.getContentPane().add(icon);
    JButton quit = new JButton("Quit");
    JLabel label = new JLabel("Drag this window by its image");
    label.setHorizontalAlignment(SwingConstants.CENTER);
    alphaWindow.getContentPane().add(label, BorderLayout.NORTH);
    alphaWindow.getContentPane().add(quit, BorderLayout.SOUTH);
    quit.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    });
    MouseInputAdapter handler = new MouseInputAdapter() {

        private Point offset;

        public void mousePressed(MouseEvent e) {
            if (SwingUtilities.isLeftMouseButton(e))
                offset = e.getPoint();
        }

        public void mouseReleased(MouseEvent e) {
            offset = null;
        }

        public void mouseDragged(MouseEvent e) {
            if (offset != null) {
                Window w = (Window) e.getSource();
                Point where = e.getPoint();
                where.translate(-offset.x, -offset.y);
                Point loc = w.getLocationOnScreen();
                loc.translate(where.x, where.y);
                w.setLocation(loc.x, loc.y);
            }
        }
    };
    alphaWindow.addMouseListener(handler);
    alphaWindow.addMouseMotionListener(handler);
    JPanel p = new JPanel(new BorderLayout(8, 8));
    p.setBorder(new EmptyBorder(8, 8, 8, 8));
    p.setTransferHandler(new TransferHandler() {

        private static final long serialVersionUID = 1L;

        public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) {
            List<DataFlavor> list = Arrays.asList(transferFlavors);
            if (list.contains(URL_FLAVOR) || list.contains(URI_LIST_FLAVOR) || list.contains(DataFlavor.imageFlavor) || list.contains(DataFlavor.javaFileListFlavor)) {
                return true;
            }
            if (DataFlavor.selectBestTextFlavor(transferFlavors) != null) {
                return true;
            }
            System.err.println("No acceptable flavor found in " + Arrays.asList(transferFlavors));
            return false;
        }

        public boolean importData(JComponent comp, Transferable t) {
            try {
                if (t.isDataFlavorSupported(URL_FLAVOR)) {
                    URL url = (URL) t.getTransferData(URL_FLAVOR);
                    setImage(Toolkit.getDefaultToolkit().getImage(url));
                    return true;
                }
                if (t.isDataFlavorSupported(URI_LIST_FLAVOR)) {
                    String s = (String) t.getTransferData(URI_LIST_FLAVOR);
                    String[] uris = s.split("[\r\n]");
                    if (uris.length > 0) {
                        URL url = new URL(uris[0]);
                        setImage(Toolkit.getDefaultToolkit().getImage(url));
                        return true;
                    }
                    return false;
                }
                if (t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
                    Image image = (Image) t.getTransferData(DataFlavor.imageFlavor);
                    setImage(image);
                    return true;
                }
                if (t.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                    List<File> files = (List<File>) t.getTransferData(DataFlavor.javaFileListFlavor);
                    File f = files.get(0);
                    URL url = new URL("file://" + f.toURI().toURL().getPath());
                    Image image = Toolkit.getDefaultToolkit().getImage(url);
                    setImage(image);
                    return true;
                }
                DataFlavor flavor = DataFlavor.selectBestTextFlavor(t.getTransferDataFlavors());
                if (flavor != null) {
                    Reader reader = flavor.getReaderForText(t);
                    char[] buf = new char[512];
                    StringBuilder b = new StringBuilder();
                    int count;
                    // encoding wrong
                    while ((count = reader.read(buf)) > 0) {
                        for (int i = 0; i < count; i++) {
                            if (buf[i] != 0)
                                b.append(buf, i, 1);
                        }
                    }
                    String html = b.toString();
                    Pattern p = Pattern.compile("<img.*src=\"([^\\\"\">]+)\"", Pattern.CANON_EQ | Pattern.UNICODE_CASE);
                    Matcher m = p.matcher(html);
                    if (m.find()) {
                        URL url = new URL(m.group(1));
                        System.out.println("Load image from " + url);
                        Image image = Toolkit.getDefaultToolkit().getImage(url);
                        setImage(image);
                        return true;
                    }
                    System.err.println("Can't parse text: " + html);
                    return false;
                }
                System.err.println("No flavor available: " + Arrays.asList(t.getTransferDataFlavors()));
            } catch (UnsupportedFlavorException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } catch (Throwable e) {
                e.printStackTrace();
            }
            return false;
        }
    });
    p.add(new JLabel("<html><center>Drop an image with an alpha channel onto this window<br>" + "You may also adjust the overall transparency with the slider</center></html>"), BorderLayout.NORTH);
    p.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    final JSlider slider = new JSlider(0, 255, 255);
    slider.addChangeListener(new ChangeListener() {

        public void stateChanged(ChangeEvent e) {
            int value = slider.getValue();
            WindowUtils.setWindowAlpha(alphaWindow, value / 255f);
        }
    });
    p.add(slider, BorderLayout.SOUTH);
    frame.getContentPane().add(p);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    centerOnScreen(frame);
    frame.setVisible(true);
    WindowUtils.setWindowTransparent(alphaWindow, true);
    alphaWindow.setLocation(frame.getX() + frame.getWidth() + 4, frame.getY());
    try {
        URL url = getClass().getResource("tardis.png");
        if (url != null) {
            setImage(Toolkit.getDefaultToolkit().getImage(url));
        }
    } catch (Exception e) {
    }
}
Also used : JPanel(javax.swing.JPanel) Matcher(java.util.regex.Matcher) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) Reader(java.io.Reader) Image(java.awt.Image) URL(java.net.URL) GraphicsConfiguration(java.awt.GraphicsConfiguration) DataFlavor(java.awt.datatransfer.DataFlavor) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) JSlider(javax.swing.JSlider) List(java.util.List) ChangeListener(javax.swing.event.ChangeListener) EmptyBorder(javax.swing.border.EmptyBorder) Window(java.awt.Window) JWindow(javax.swing.JWindow) Pattern(java.util.regex.Pattern) MouseEvent(java.awt.event.MouseEvent) JWindow(javax.swing.JWindow) JComponent(javax.swing.JComponent) Transferable(java.awt.datatransfer.Transferable) JLabel(javax.swing.JLabel) Point(java.awt.Point) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) IOException(java.io.IOException) ActionListener(java.awt.event.ActionListener) ChangeEvent(javax.swing.event.ChangeEvent) TransferHandler(javax.swing.TransferHandler) File(java.io.File) MouseInputAdapter(javax.swing.event.MouseInputAdapter)

Example 2 with JSlider

use of javax.swing.JSlider in project zaproxy by zaproxy.

the class OptionsScannerPanel method getSliderHostPerScan.

/**
     * This method initializes sliderHostPerScan
     *
     * @return javax.swing.JSlider
     */
private JSlider getSliderHostPerScan() {
    if (sliderHostPerScan == null) {
        sliderHostPerScan = new JSlider();
        sliderHostPerScan.setMaximum(5);
        sliderHostPerScan.setMinimum(1);
        sliderHostPerScan.setMinorTickSpacing(1);
        sliderHostPerScan.setPaintTicks(true);
        sliderHostPerScan.setPaintLabels(true);
        sliderHostPerScan.setName("");
        sliderHostPerScan.setMajorTickSpacing(1);
        sliderHostPerScan.setSnapToTicks(true);
        sliderHostPerScan.setPaintTrack(true);
    }
    return sliderHostPerScan;
}
Also used : JSlider(javax.swing.JSlider)

Example 3 with JSlider

use of javax.swing.JSlider in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 4 with JSlider

use of javax.swing.JSlider in project zaproxy by zaproxy.

the class OptionsSpiderPanel method getSliderMaxDepth.

/**
	 * This method initializes the slider for MaxDepth.
	 * 
	 * @return the slider for max depth
	 */
private JSlider getSliderMaxDepth() {
    if (sliderMaxDepth == null) {
        sliderMaxDepth = new JSlider();
        sliderMaxDepth.setMaximum(19);
        sliderMaxDepth.setMinimum(1);
        sliderMaxDepth.setMinorTickSpacing(1);
        sliderMaxDepth.setPaintTicks(true);
        sliderMaxDepth.setPaintLabels(true);
        sliderMaxDepth.setName("");
        sliderMaxDepth.setMajorTickSpacing(1);
        sliderMaxDepth.setSnapToTicks(true);
        sliderMaxDepth.setPaintTrack(true);
    }
    return sliderMaxDepth;
}
Also used : JSlider(javax.swing.JSlider)

Example 5 with JSlider

use of javax.swing.JSlider in project ChatGameFontificator by GlitchCog.

the class ControlPanelFont method build.

@Override
protected void build() {
    sliderListener = new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (fontScaleSlider.getSlider().equals(source)) {
                config.setFontScale(fontScaleSlider.getScaledValue());
                fontScaleSlider.setValueTextColor(((int) config.getFontScale() == config.getFontScale()) ? SCALE_EVEN : SCALE_UNEVEN);
            } else if (borderScaleSlider.getSlider().equals(source)) {
                config.setBorderScale(borderScaleSlider.getScaledValue());
                borderScaleSlider.setValueTextColor(((int) config.getBorderScale() == config.getBorderScale()) ? SCALE_EVEN : SCALE_UNEVEN);
            } else if (borderInsetXSlider.getSlider().equals(source)) {
                config.setBorderInsetX(borderInsetXSlider.getValue());
            } else if (borderInsetYSlider.getSlider().equals(source)) {
                config.setBorderInsetY(borderInsetYSlider.getValue());
            } else if (spaceWidthSlider.getSlider().equals(source)) {
                config.setSpaceWidth(spaceWidthSlider.getValue());
            } else if (baselineOffsetSlider.getSlider().equals(source)) {
                config.setBaselineOffset(baselineOffsetSlider.getValue());
            } else if (lineSpacingSlider.getSlider().equals(source)) {
                config.setLineSpacing(lineSpacingSlider.getValue());
            } else if (charSpacingSlider.getSlider().equals(source)) {
                config.setCharSpacing(charSpacingSlider.getValue());
            }
            chat.repaint();
        }
    };
    ActionListener fontAl = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JMenuItem source = (JMenuItem) e.getSource();
            DropdownLabel key = new DropdownLabel(source.getText());
            if (CUSTOM_KEY.equals(key)) {
                int selectionResult = fontPngPicker.showDialog(ControlWindow.me, "Select Font PNG");
                if (selectionResult == JFileChooser.APPROVE_OPTION) {
                    fontFilenameInput.setText(fontPngPicker.getSelectedFile().getAbsolutePath());
                    fontPresetDropdown.setSelectedText(fontPngPicker.getSelectedFile().getName());
                }
            } else {
                fontFilenameInput.setText(PRESET_FONT_FILE_MAP.get(key).getFontFilename());
                fontTypeCheckbox.setSelected(FontType.VARIABLE_WIDTH.equals(PRESET_FONT_FILE_MAP.get(key).getDefaultType()));
                spaceWidthSlider.setEnabled(fontTypeCheckbox.isSelected());
            }
            updateFontOrBorder(true);
        }
    };
    ActionListener borderAl = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            JMenuItem source = (JMenuItem) e.getSource();
            DropdownLabel key = new DropdownLabel(source.getText());
            if (CUSTOM_KEY.equals(key)) {
                int selectionResult = borderPngPicker.showDialog(ControlWindow.me, "Select Border PNG");
                if (selectionResult == JFileChooser.APPROVE_OPTION) {
                    borderFilenameInput.setText(borderPngPicker.getSelectedFile().getAbsolutePath());
                    borderPresetDropdown.setSelectedText(borderPngPicker.getSelectedFile().getName());
                }
            } else {
                DropdownBorder border = PRESET_BORDER_FILE_MAP.get(key);
                borderFilenameInput.setText(border.getBorderFilename());
                colorPanel.setBorderColor(border.getDefaultTint());
            }
            updateFontOrBorder(false);
        }
    };
    fontTypeListener = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            config.setFontType(fontTypeCheckbox.isSelected() ? FontType.VARIABLE_WIDTH : FontType.FIXED_WIDTH);
            spaceWidthSlider.setEnabled(fontTypeCheckbox.isSelected());
            updateFontOrBorder(true);
        }
    };
    extendedCharBox = new JCheckBox("Display Extended Characters");
    extendedCharBox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final boolean ecbSelected = extendedCharBox.isSelected();
            config.setExtendedCharEnabled(ecbSelected);
            unknownCharPopupButton.setEnabled(!ecbSelected);
            unknownCharLabel.setEnabled(!ecbSelected);
            chat.repaint();
        }
    });
    unknownCharLabel = new JLabel("");
    charPicker = new CharacterPicker(ControlWindow.me, fProps.getFontConfig(), unknownCharLabel, chat);
    Map<String, List<String>> fontMenuMap = getMenuMapFromPresets(PRESET_FONT_FILE_MAP.keySet());
    fontMenuMap.put(CUSTOM_KEY.getLabel(), null);
    Map<String, List<String>> borderMenuMap = getMenuMapFromPresets(PRESET_BORDER_FILE_MAP.keySet());
    borderMenuMap.put(CUSTOM_KEY.getLabel(), null);
    fontTypeCheckbox = new JCheckBox("Variable Width Characters");
    fontFilenameInput = new LabeledInput("Font Filename", 32);
    fontPresetDropdown = new ComboMenuBar(fontMenuMap, fontAl);
    borderFilenameInput = new LabeledInput("Border Filename", 32);
    borderPresetDropdown = new ComboMenuBar(borderMenuMap, borderAl);
    gridWidthInput = new LabeledInput("Grid Width", 4);
    gridHeightInput = new LabeledInput("Grid Height", 4);
    fontScaleSlider = new LabeledSlider("Font Scale", "x", ConfigFont.MIN_FONT_SCALE, ConfigFont.MAX_FONT_SCALE, ConfigFont.FONT_BORDER_SCALE_GRANULARITY);
    borderScaleSlider = new LabeledSlider("Border Scale", "x", ConfigFont.MIN_BORDER_SCALE, ConfigFont.MAX_BORDER_SCALE, ConfigFont.FONT_BORDER_SCALE_GRANULARITY);
    borderInsetXSlider = new LabeledSlider("X", "pixels", ConfigFont.MIN_BORDER_INSET, ConfigFont.MAX_BORDER_INSET);
    borderInsetYSlider = new LabeledSlider("Y", "pixels", ConfigFont.MIN_BORDER_INSET, ConfigFont.MAX_BORDER_INSET);
    characterKeyInput = new LabeledInput("Character Key", 32);
    spaceWidthSlider = new LabeledSlider("Space Width", "%", ConfigFont.MIN_SPACE_WIDTH, ConfigFont.MAX_SPACE_WIDTH);
    baselineOffsetSlider = new LabeledSlider("Baseline Height Offset", "pixels", ConfigFont.MIN_BASELINE_OFFSET, ConfigFont.MAX_BASELINE_OFFSET);
    lineSpacingSlider = new LabeledSlider("Line Spacing", "pixels", ConfigFont.MIN_LINE_SPACING, ConfigFont.MAX_LINE_SPACING);
    charSpacingSlider = new LabeledSlider("Char Spacing", "pixels", ConfigFont.MIN_CHAR_SPACING, ConfigFont.MAX_LINE_SPACING);
    unknownCharPopupButton = new JButton("Select Missing Character");
    unknownCharPopupButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            charPicker.setVisible(true);
        }
    });
    fontFilenameInput.setEnabled(false);
    borderFilenameInput.setEnabled(false);
    fontScaleSlider.addChangeListener(sliderListener);
    borderScaleSlider.addChangeListener(sliderListener);
    borderInsetXSlider.addChangeListener(sliderListener);
    borderInsetYSlider.addChangeListener(sliderListener);
    spaceWidthSlider.addChangeListener(sliderListener);
    baselineOffsetSlider.addChangeListener(sliderListener);
    lineSpacingSlider.addChangeListener(sliderListener);
    charSpacingSlider.addChangeListener(sliderListener);
    JPanel fontPanel = new JPanel(new GridBagLayout());
    JPanel borderPanel = new JPanel(new GridBagLayout());
    JPanel unknownPanel = new JPanel(new GridBagLayout());
    fontPanel.setBorder(new TitledBorder(baseBorder, "Font"));
    borderPanel.setBorder(new TitledBorder(baseBorder, "Border"));
    unknownPanel.setBorder(new TitledBorder(baseBorder, "Extended and Unicode Characters"));
    GridBagConstraints fontGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 0, 0);
    GridBagConstraints borderGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 0, 0);
    GridBagConstraints unknownGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 0, 0);
    // Fields are still used and stored in properties files when saved, but the values are either fixed or meant to
    // be filled by other components
    // add(fontFilenameInput);
    // add(borderFilenameInput);
    // add(gridWidthInput);
    // add(gridHeightInput);
    // add(characterKeyInput);
    fontPanel.add(fontPresetDropdown, fontGbc);
    fontGbc.gridx++;
    // This slider being on the same row as the preset dropdown keeps the combo menu bar from collapsing to no
    // height in the layout
    fontPanel.add(fontScaleSlider, fontGbc);
    fontGbc.gridwidth = 2;
    fontGbc.gridx = 0;
    fontGbc.gridy++;
    fontPanel.add(lineSpacingSlider, fontGbc);
    fontGbc.gridy++;
    fontPanel.add(charSpacingSlider, fontGbc);
    fontGbc.gridy++;
    JPanel variableWidthPanel = new JPanel(new GridBagLayout());
    GridBagConstraints vwpGbc = getGbc();
    vwpGbc.anchor = GridBagConstraints.EAST;
    vwpGbc.weightx = 0.0;
    vwpGbc.fill = GridBagConstraints.NONE;
    variableWidthPanel.add(fontTypeCheckbox, vwpGbc);
    vwpGbc.anchor = GridBagConstraints.WEST;
    vwpGbc.weightx = 1.0;
    vwpGbc.fill = GridBagConstraints.HORIZONTAL;
    vwpGbc.gridx++;
    variableWidthPanel.add(spaceWidthSlider, vwpGbc);
    fontPanel.add(variableWidthPanel, fontGbc);
    fontGbc.gridy++;
    fontPanel.add(baselineOffsetSlider, fontGbc);
    fontGbc.gridy++;
    borderPanel.add(borderPresetDropdown, borderGbc);
    borderGbc.gridx++;
    // This slider being on the same row as the preset dropdown keeps the combo menu bar from collapsing to no
    // height in the layout
    borderPanel.add(borderScaleSlider, borderGbc);
    borderGbc.gridwidth = 2;
    borderGbc.gridx = 0;
    borderGbc.gridy++;
    borderGbc.anchor = GridBagConstraints.CENTER;
    borderPanel.add(new JLabel("Font Insets Off Border"), borderGbc);
    borderGbc.gridy++;
    borderPanel.add(borderInsetXSlider, borderGbc);
    borderGbc.gridy++;
    borderPanel.add(borderInsetYSlider, borderGbc);
    borderGbc.gridy++;
    unknownPanel.add(extendedCharBox, unknownGbc);
    unknownGbc.gridx++;
    unknownPanel.add(unknownCharPopupButton, unknownGbc);
    unknownGbc.gridx++;
    unknownPanel.add(unknownCharLabel, unknownGbc);
    unknownGbc.gridx++;
    JPanel everything = new JPanel(new GridBagLayout());
    GridBagConstraints eGbc = new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, DEFAULT_INSETS, 10, 10);
    everything.add(fontPanel, eGbc);
    eGbc.gridy++;
    everything.add(borderPanel, eGbc);
    eGbc.gridy++;
    everything.add(unknownPanel, eGbc);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    add(everything, gbc);
    // Filler panel
    gbc.gridy++;
    gbc.weighty = 1.0;
    gbc.anchor = GridBagConstraints.SOUTH;
    add(new JPanel(), gbc);
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) DropdownBorder(com.glitchcog.fontificator.gui.controls.panel.model.DropdownBorder) LabeledInput(com.glitchcog.fontificator.gui.component.LabeledInput) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) DropdownLabel(com.glitchcog.fontificator.gui.controls.panel.model.DropdownLabel) TitledBorder(javax.swing.border.TitledBorder) JCheckBox(javax.swing.JCheckBox) LabeledSlider(com.glitchcog.fontificator.gui.component.LabeledSlider) ChangeEvent(javax.swing.event.ChangeEvent) ActionListener(java.awt.event.ActionListener) CharacterPicker(com.glitchcog.fontificator.gui.component.CharacterPicker) JSlider(javax.swing.JSlider) ComboMenuBar(com.glitchcog.fontificator.gui.component.combomenu.ComboMenuBar) ChangeListener(javax.swing.event.ChangeListener) ArrayList(java.util.ArrayList) List(java.util.List) JMenuItem(javax.swing.JMenuItem)

Aggregations

JSlider (javax.swing.JSlider)30 ChangeEvent (javax.swing.event.ChangeEvent)14 ChangeListener (javax.swing.event.ChangeListener)14 JPanel (javax.swing.JPanel)12 JLabel (javax.swing.JLabel)11 JButton (javax.swing.JButton)10 ActionEvent (java.awt.event.ActionEvent)9 ActionListener (java.awt.event.ActionListener)9 GridBagLayout (java.awt.GridBagLayout)6 JCheckBox (javax.swing.JCheckBox)6 JToggleButton (javax.swing.JToggleButton)6 BorderLayout (java.awt.BorderLayout)5 Dimension (java.awt.Dimension)5 GridBagConstraints (java.awt.GridBagConstraints)5 JRadioButton (javax.swing.JRadioButton)5 List (java.util.List)4 BoundedRangeModel (javax.swing.BoundedRangeModel)4 DefaultBoundedRangeModel (javax.swing.DefaultBoundedRangeModel)4 LabeledSlider (com.glitchcog.fontificator.gui.component.LabeledSlider)3 Point (java.awt.Point)3