com.sun.swingset3.demos.JGridPanel Java Examples

The following examples show how to use com.sun.swingset3.demos.JGridPanel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TextFieldDemo.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void initUI() {
    tfHistory.setHistory(Arrays.asList(resourceManager.getString("TextFieldDemo.history.words").split("\\,")));

    JGridPanel pnDow = new JGridPanel(3, 2);

    pnDow.cell(tfDow).
            cell(btnGo).
            cell(lbDowResult);

    JGridPanel pnPassword = new JGridPanel(3, 2);

    pnPassword.cell(tfPassword1).
            cell(tfPassword2).
            cell();

    JGridPanel pnContent = new JGridPanel(1, 0, 6);

    pnContent.setBorderEqual(10);

    pnContent.cell(lbHistoryTextField).
            cell(tfHistory).
            cell(lbDow, new Insets(20, 0, 0, 0)).
            cell(pnDow).
            cell(lbPassword, new Insets(20, 0, 0, 0)).
            cell(pnPassword).
            cell();

    add(pnContent);
}
 
Example #2
Source File: GridBagLayoutDemo.java    From littleluck with Apache License 2.0 5 votes vote down vote up
private void initUI() {
    JGridPanel pnContent = new JGridPanel(1, 0, 2);

    pnContent.setBorderEqual(10);

    pnContent.cell(lbCaption, JGridPanel.Layout.FILL).
            cell().
            cell(calculator, JGridPanel.Layout.CENTER, JGridPanel.Layout.FIRST).
            cell();

    add(pnContent);
}
 
Example #3
Source File: FileChooserDemo.java    From littleluck with Apache License 2.0 5 votes vote down vote up
private void initUI() {
    setPreferredSize(new Dimension(SIZE, -1));

    setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));

    JGridPanel pnInfo = new JGridPanel(2, 1);

    pnInfo.cell(new JLabel(resourceManager.getString("FileChooserDemo.preview.type"))).
            cell(lbType).
            cell(new JLabel(resourceManager.getString("FileChooserDemo.preview.size"))).
            cell(lbSize);

    cell(pnInfo);
    cell(lbPreview, Layout.FILL, Layout.FILL);
}
 
Example #4
Source File: TextFieldDemo.java    From littleluck with Apache License 2.0 5 votes vote down vote up
private void initUI() {
    tfHistory.setHistory(Arrays.asList(resourceManager.getString("TextFieldDemo.history.words").split("\\,")));

    JGridPanel pnDow = new JGridPanel(3, 2);

    pnDow.cell(tfDow).
            cell(btnGo).
            cell(lbDowResult);

    JGridPanel pnPassword = new JGridPanel(3, 2);

    pnPassword.cell(tfPassword1).
            cell(tfPassword2).
            cell();

    JGridPanel pnContent = new JGridPanel(1, 0, 6);

    pnContent.setBorderEqual(10);

    pnContent.cell(lbHistoryTextField).
            cell(tfHistory).
            cell(lbDow, new Insets(20, 0, 0, 0)).
            cell(pnDow).
            cell(lbPassword, new Insets(20, 0, 0, 0)).
            cell(pnPassword).
            cell();

    add(pnContent);
}
 
Example #5
Source File: GridBagLayoutDemo.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
private void initUI() {
    JGridPanel pnContent = new JGridPanel(1, 0, 2);

    pnContent.setBorderEqual(10);

    pnContent.cell(lbCaption, JGridPanel.Layout.FILL).
            cell().
            cell(calculator, JGridPanel.Layout.CENTER, JGridPanel.Layout.FIRST).
            cell();

    add(pnContent);
}
 
Example #6
Source File: FileChooserDemo.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
private void initUI() {
    setPreferredSize(new Dimension(SIZE, -1));

    setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));

    JGridPanel pnInfo = new JGridPanel(2, 1);

    pnInfo.cell(new JLabel(resourceManager.getString("FileChooserDemo.preview.type"))).
            cell(lbType).
            cell(new JLabel(resourceManager.getString("FileChooserDemo.preview.size"))).
            cell(lbSize);

    cell(pnInfo);
    cell(lbPreview, Layout.FILL, Layout.FILL);
}
 
Example #7
Source File: TextFieldDemo.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
private void initUI() {
    tfHistory.setHistory(Arrays.asList(resourceManager.getString("TextFieldDemo.history.words").split("\\,")));

    JGridPanel pnDow = new JGridPanel(3, 2);

    pnDow.cell(tfDow).
            cell(btnGo).
            cell(lbDowResult);

    JGridPanel pnPassword = new JGridPanel(3, 2);

    pnPassword.cell(tfPassword1).
            cell(tfPassword2).
            cell();

    JGridPanel pnContent = new JGridPanel(1, 0, 6);

    pnContent.setBorderEqual(10);

    pnContent.cell(lbHistoryTextField).
            cell(tfHistory).
            cell(lbDow, new Insets(20, 0, 0, 0)).
            cell(pnDow).
            cell(lbPassword, new Insets(20, 0, 0, 0)).
            cell(pnPassword).
            cell();

    add(pnContent);
}
 
Example #8
Source File: GridBagLayoutDemo.java    From Darcula with Apache License 2.0 5 votes vote down vote up
private void initUI() {
    JGridPanel pnContent = new JGridPanel(1, 0, 2);

    pnContent.setBorderEqual(10);

    pnContent.cell(lbCaption, JGridPanel.Layout.FILL).
            cell().
            cell(calculator, JGridPanel.Layout.CENTER, JGridPanel.Layout.FIRST).
            cell();

    add(pnContent);
}
 
Example #9
Source File: FileChooserDemo.java    From Darcula with Apache License 2.0 5 votes vote down vote up
private void initUI() {
    setPreferredSize(new Dimension(SIZE, -1));

    setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));

    JGridPanel pnInfo = new JGridPanel(2, 1);

    pnInfo.cell(new JLabel(resourceManager.getString("FileChooserDemo.preview.type"))).
            cell(lbType).
            cell(new JLabel(resourceManager.getString("FileChooserDemo.preview.size"))).
            cell(lbSize);

    cell(pnInfo);
    cell(lbPreview, Layout.FILL, Layout.FILL);
}
 
Example #10
Source File: TextFieldDemo.java    From Darcula with Apache License 2.0 5 votes vote down vote up
private void initUI() {
    tfHistory.setHistory(Arrays.asList(resourceManager.getString("TextFieldDemo.history.words").split("\\,")));

    JGridPanel pnDow = new JGridPanel(3, 2);

    pnDow.cell(tfDow).
            cell(btnGo).
            cell(lbDowResult);

    JGridPanel pnPassword = new JGridPanel(3, 2);

    pnPassword.cell(tfPassword1).
            cell(tfPassword2).
            cell();

    JGridPanel pnContent = new JGridPanel(1, 0, 6);

    pnContent.setBorderEqual(10);

    pnContent.cell(lbHistoryTextField).
            cell(tfHistory).
            cell(lbDow, new Insets(20, 0, 0, 0)).
            cell(pnDow).
            cell(lbPassword, new Insets(20, 0, 0, 0)).
            cell(pnPassword).
            cell();

    add(pnContent);
}
 
Example #11
Source File: FileChooserDemo.java    From littleluck with Apache License 2.0 4 votes vote down vote up
private void initUI() {
    externalChooser.addChoosableFileFilter(new FileNameExtensionFilter("JPEG images", "jpg"));
    externalChooser.addChoosableFileFilter(new FileNameExtensionFilter("All supported images",
            ImageIO.getWriterFormatNames()));

    final FilePreview filePreview = new FilePreview();

    externalChooser.setAccessory(filePreview);
    externalChooser.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY,
            new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    filePreview.loadFileInfo(externalChooser.getSelectedFile());
                }
            });

    embeddedChooser.setControlButtonsAreShown(false);

    embeddedChooser.addChoosableFileFilter(new FileNameExtensionFilter("JPEG images", "jpg"));

    FileNameExtensionFilter filter = new FileNameExtensionFilter("All supported images",
            ImageIO.getWriterFormatNames());

    embeddedChooser.addChoosableFileFilter(filter);
    embeddedChooser.setFileFilter(filter);

    for (int i = MIN_FILTER_ID; i <= MAX_FILTER_ID; i++) {
        cbFilters.addItem(new FilterItem(i, resourceManager.getString(FILTER_NAMES[i])));
    }

    JGridPanel pnFilter = new JGridPanel(2, 0);

    pnFilter.cell(cbFilters).
            cell(btnApplyFilter);

    JGridPanel pnRotateButtons = new JGridPanel(4, 3);

    pnRotateButtons.cell(btnRotateLeft).
            cell(btnRotateRight).
            cell(btnFlipHorizontal).
            cell(btnFlipVertical);

    JGridPanel pnBottom = new JGridPanel(4, 1);

    pnBottom.setHGap(JGridPanel.DEFAULT_GAP * 4);

    pnBottom.cell(btnSelect, JGridPanel.Layout.FILL).
            cell().
            cell(pnFilter).
            cell(btnSave, JGridPanel.Layout.FILL).
            cell(btnSelectWithPreview, JGridPanel.Layout.FILL).
            cell().
            cell(pnRotateButtons).
            cell(btnCancel, JGridPanel.Layout.FILL);

    pnContent.cell(pnImage);
    pnContent.cell(pnBottom, new Insets(10, 10, 10, 10));

    add(pnContent);

    setState(State.EMPTY, false);
}
 
Example #12
Source File: ColorChooserDemo.java    From littleluck with Apache License 2.0 4 votes vote down vote up
/**
 * ColorChooserDemo Constructor
 */
public ColorChooserDemo() {
    setLayout(new BorderLayout());

    outerColorButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.OUTER));
    
    outerColorButton.putClientProperty(LuckButtonUIBundle.IS_PAINTBG, "");

    backgroundColorButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.BACKGROUND));
    
    backgroundColorButton.putClientProperty(LuckButtonUIBundle.IS_PAINTBG, "");

    gradientAButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.GRADIENT_A));
    
    gradientAButton.putClientProperty(LuckButtonUIBundle.IS_PAINTBG, "");

    gradientBButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.GRADIENT_B));
    
    gradientBButton.putClientProperty(LuckButtonUIBundle.IS_PAINTBG, "");

    ActionListener l = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JButton button = (JButton) e.getSource();

            final BezierAnimationPanel.BezierColor bezierColor =
                    ((ColorSwatch) button.getIcon()).getBezierColor();

            Color current = bezAnim.getBezierColor(bezierColor);

            final JColorChooser chooser = new JColorChooser(current != null ?
                    current :
                    Color.WHITE);

            ActionListener colorChooserListener = new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    bezAnim.setBezierColor(bezierColor, chooser.getColor());
                }
            };

            JDialog dialog = JColorChooser.createDialog(ColorChooserDemo.this,
                    resourceManager.getString("ColorChooserDemo.chooser_title"),
                    true,
                    chooser,
                    colorChooserListener,
                    null);

            dialog.setVisible(true);
        }
    };

    outerColorButton.addActionListener(l);
    backgroundColorButton.addActionListener(l);
    gradientAButton.addActionListener(l);
    gradientBButton.addActionListener(l);

    // Add control buttons
    JPanel buttonPanel = new JPanel(new GridLayout(1, 4, 15, 0));

    buttonPanel.add(backgroundColorButton);
    buttonPanel.add(gradientAButton);
    buttonPanel.add(gradientBButton);
    buttonPanel.add(outerColorButton);

    // Add everything to the panel
    JGridPanel pnContent = new JGridPanel(1, 0, 1);

    pnContent.cell(buttonPanel, JGridPanel.Layout.CENTER).
            cell(bezAnim);

    pnContent.setBorder(new EmptyBorder(10, 0, 0, 0));

    add(pnContent);
}
 
Example #13
Source File: FileChooserDemo.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
private void initUI() {
    externalChooser.addChoosableFileFilter(new FileNameExtensionFilter("JPEG images", "jpg"));
    externalChooser.addChoosableFileFilter(new FileNameExtensionFilter("All supported images",
            ImageIO.getWriterFormatNames()));

    final FilePreview filePreview = new FilePreview();

    externalChooser.setAccessory(filePreview);
    externalChooser.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY,
            new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    filePreview.loadFileInfo(externalChooser.getSelectedFile());
                }
            });

    embeddedChooser.setControlButtonsAreShown(false);

    embeddedChooser.addChoosableFileFilter(new FileNameExtensionFilter("JPEG images", "jpg"));

    FileNameExtensionFilter filter = new FileNameExtensionFilter("All supported images",
            ImageIO.getWriterFormatNames());

    embeddedChooser.addChoosableFileFilter(filter);
    embeddedChooser.setFileFilter(filter);

    for (int i = MIN_FILTER_ID; i <= MAX_FILTER_ID; i++) {
        cbFilters.addItem(new FilterItem(i, resourceManager.getString(FILTER_NAMES[i])));
    }

    JGridPanel pnFilter = new JGridPanel(2, 0);

    pnFilter.cell(cbFilters).
            cell(btnApplyFilter);

    JGridPanel pnRotateButtons = new JGridPanel(4, 3);

    pnRotateButtons.cell(btnRotateLeft).
            cell(btnRotateRight).
            cell(btnFlipHorizontal).
            cell(btnFlipVertical);

    JGridPanel pnBottom = new JGridPanel(4, 1);

    pnBottom.setHGap(JGridPanel.DEFAULT_GAP * 4);

    pnBottom.cell(btnSelect, JGridPanel.Layout.FILL).
            cell().
            cell(pnFilter).
            cell(btnSave, JGridPanel.Layout.FILL).
            cell(btnSelectWithPreview, JGridPanel.Layout.FILL).
            cell().
            cell(pnRotateButtons).
            cell(btnCancel, JGridPanel.Layout.FILL);

    pnContent.cell(pnImage);
    pnContent.cell(pnBottom, new Insets(10, 10, 10, 10));

    add(pnContent);

    setState(State.EMPTY, false);
}
 
Example #14
Source File: ColorChooserDemo.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
 * ColorChooserDemo Constructor
 */
public ColorChooserDemo() {
    setLayout(new BorderLayout());

    outerColorButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.OUTER));

    backgroundColorButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.BACKGROUND));

    gradientAButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.GRADIENT_A));

    gradientBButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.GRADIENT_B));

    ActionListener l = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JButton button = (JButton) e.getSource();

            final BezierAnimationPanel.BezierColor bezierColor =
                    ((ColorSwatch) button.getIcon()).getBezierColor();

            Color current = bezAnim.getBezierColor(bezierColor);

            final JColorChooser chooser = new JColorChooser(current != null ?
                    current :
                    Color.WHITE);

            ActionListener colorChooserListener = new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    bezAnim.setBezierColor(bezierColor, chooser.getColor());
                }
            };

            JDialog dialog = JColorChooser.createDialog(ColorChooserDemo.this,
                    resourceManager.getString("ColorChooserDemo.chooser_title"),
                    true,
                    chooser,
                    colorChooserListener,
                    null);

            dialog.setVisible(true);
        }
    };

    outerColorButton.addActionListener(l);
    backgroundColorButton.addActionListener(l);
    gradientAButton.addActionListener(l);
    gradientBButton.addActionListener(l);

    // Add control buttons
    JPanel buttonPanel = new JPanel(new GridLayout(1, 4, 15, 0));

    buttonPanel.add(backgroundColorButton);
    buttonPanel.add(gradientAButton);
    buttonPanel.add(gradientBButton);
    buttonPanel.add(outerColorButton);

    // Add everything to the panel
    JGridPanel pnContent = new JGridPanel(1, 0, 1);

    pnContent.cell(buttonPanel, JGridPanel.Layout.CENTER).
            cell(bezAnim);

    pnContent.setBorder(new EmptyBorder(10, 0, 0, 0));

    add(pnContent);
}
 
Example #15
Source File: FileChooserDemo.java    From Darcula with Apache License 2.0 4 votes vote down vote up
private void initUI() {
    externalChooser.addChoosableFileFilter(new FileNameExtensionFilter("JPEG images", "jpg"));
    externalChooser.addChoosableFileFilter(new FileNameExtensionFilter("All supported images",
            ImageIO.getWriterFormatNames()));

    final FilePreview filePreview = new FilePreview();

    externalChooser.setAccessory(filePreview);
    externalChooser.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY,
            new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    filePreview.loadFileInfo(externalChooser.getSelectedFile());
                }
            });

    embeddedChooser.setControlButtonsAreShown(false);

    embeddedChooser.addChoosableFileFilter(new FileNameExtensionFilter("JPEG images", "jpg"));

    FileNameExtensionFilter filter = new FileNameExtensionFilter("All supported images",
            ImageIO.getWriterFormatNames());

    embeddedChooser.addChoosableFileFilter(filter);
    embeddedChooser.setFileFilter(filter);

    for (int i = MIN_FILTER_ID; i <= MAX_FILTER_ID; i++) {
        cbFilters.addItem(new FilterItem(i, resourceManager.getString(FILTER_NAMES[i])));
    }

    JGridPanel pnFilter = new JGridPanel(2, 0);

    pnFilter.cell(cbFilters).
            cell(btnApplyFilter);

    JGridPanel pnRotateButtons = new JGridPanel(4, 3);

    pnRotateButtons.cell(btnRotateLeft).
            cell(btnRotateRight).
            cell(btnFlipHorizontal).
            cell(btnFlipVertical);

    JGridPanel pnBottom = new JGridPanel(4, 1);

    pnBottom.setHGap(JGridPanel.DEFAULT_GAP * 4);

    pnBottom.cell(btnSelect, JGridPanel.Layout.FILL).
            cell().
            cell(pnFilter).
            cell(btnSave, JGridPanel.Layout.FILL).
            cell(btnSelectWithPreview, JGridPanel.Layout.FILL).
            cell().
            cell(pnRotateButtons).
            cell(btnCancel, JGridPanel.Layout.FILL);

    pnContent.cell(pnImage);
    pnContent.cell(pnBottom, new Insets(10, 10, 10, 10));

    add(pnContent);

    setState(State.EMPTY, false);
}
 
Example #16
Source File: ColorChooserDemo.java    From Darcula with Apache License 2.0 4 votes vote down vote up
/**
 * ColorChooserDemo Constructor
 */
public ColorChooserDemo() {
    setLayout(new BorderLayout());

    outerColorButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.OUTER));

    backgroundColorButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.BACKGROUND));

    gradientAButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.GRADIENT_A));

    gradientBButton.setIcon(new ColorSwatch(BezierAnimationPanel.BezierColor.GRADIENT_B));

    ActionListener l = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JButton button = (JButton) e.getSource();

            final BezierAnimationPanel.BezierColor bezierColor =
                    ((ColorSwatch) button.getIcon()).getBezierColor();

            Color current = bezAnim.getBezierColor(bezierColor);

            final JColorChooser chooser = new JColorChooser(current != null ?
                    current :
                    Color.WHITE);

            ActionListener colorChooserListener = new ActionListener() {
                public void actionPerformed(ActionEvent ae) {
                    bezAnim.setBezierColor(bezierColor, chooser.getColor());
                }
            };

            JDialog dialog = JColorChooser.createDialog(ColorChooserDemo.this,
                    resourceManager.getString("ColorChooserDemo.chooser_title"),
                    true,
                    chooser,
                    colorChooserListener,
                    null);

            dialog.setVisible(true);
        }
    };

    outerColorButton.addActionListener(l);
    backgroundColorButton.addActionListener(l);
    gradientAButton.addActionListener(l);
    gradientBButton.addActionListener(l);

    // Add control buttons
    JPanel buttonPanel = new JPanel(new GridLayout(1, 4, 15, 0));

    buttonPanel.add(backgroundColorButton);
    buttonPanel.add(gradientAButton);
    buttonPanel.add(gradientBButton);
    buttonPanel.add(outerColorButton);

    // Add everything to the panel
    JGridPanel pnContent = new JGridPanel(1, 0, 1);

    pnContent.cell(buttonPanel, JGridPanel.Layout.CENTER).
            cell(bezAnim);

    pnContent.setBorder(new EmptyBorder(10, 0, 0, 0));

    add(pnContent);
}