Search in sources :

Example 1 with BasicButtonUI

use of javax.swing.plaf.basic.BasicButtonUI in project intellij-community by JetBrains.

the class ColorPicker method buildTopPanel.

private JComponent buildTopPanel(boolean enablePipette) throws ParseException {
    final JPanel result = new JPanel(new BorderLayout());
    final JPanel previewPanel = new JPanel(new BorderLayout());
    if (enablePipette && myPicker != null) {
        final JButton pipette = new JButton();
        pipette.setUI(new BasicButtonUI());
        pipette.setRolloverEnabled(true);
        pipette.setIcon(AllIcons.Ide.Pipette);
        pipette.setBorder(IdeBorderFactory.createEmptyBorder());
        pipette.setRolloverIcon(AllIcons.Ide.Pipette_rollover);
        pipette.setFocusable(false);
        pipette.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                myPicker.setInitialColor(getColor());
                myPicker.show();
            }
        });
        previewPanel.add(pipette, BorderLayout.WEST);
    }
    myPreviewComponent = new ColorPreviewComponent();
    previewPanel.add(myPreviewComponent, BorderLayout.CENTER);
    result.add(previewPanel, BorderLayout.NORTH);
    final JPanel rgbPanel = new JPanel();
    rgbPanel.setLayout(new BoxLayout(rgbPanel, BoxLayout.X_AXIS));
    if (!UIUtil.isUnderAquaLookAndFeel()) {
        myR_after.setPreferredSize(new Dimension(14, -1));
        myG_after.setPreferredSize(new Dimension(14, -1));
        myB_after.setPreferredSize(new Dimension(14, -1));
    }
    rgbPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
    rgbPanel.add(myR);
    rgbPanel.add(myRed);
    if (!UIUtil.isUnderAquaLookAndFeel())
        rgbPanel.add(myR_after);
    rgbPanel.add(Box.createHorizontalStrut(2));
    rgbPanel.add(myG);
    rgbPanel.add(myGreen);
    if (!UIUtil.isUnderAquaLookAndFeel())
        rgbPanel.add(myG_after);
    rgbPanel.add(Box.createHorizontalStrut(2));
    rgbPanel.add(myB);
    rgbPanel.add(myBlue);
    if (!UIUtil.isUnderAquaLookAndFeel())
        rgbPanel.add(myB_after);
    rgbPanel.add(Box.createHorizontalStrut(2));
    rgbPanel.add(myFormat);
    result.add(rgbPanel, BorderLayout.WEST);
    final JPanel hexPanel = new JPanel();
    hexPanel.setLayout(new BoxLayout(hexPanel, BoxLayout.X_AXIS));
    hexPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
    hexPanel.add(new JLabel("#"));
    hexPanel.add(myHex);
    result.add(hexPanel, BorderLayout.EAST);
    return result;
}
Also used : BasicButtonUI(javax.swing.plaf.basic.BasicButtonUI)

Example 2 with BasicButtonUI

use of javax.swing.plaf.basic.BasicButtonUI in project jadx by skylot.

the class TabbedPane method makeTabComponent.

private Component makeTabComponent(final ContentPanel contentPanel) {
    JNode node = contentPanel.getNode();
    String name = node.makeLongString();
    final JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 0));
    panel.setOpaque(false);
    final JLabel label = new JLabel(name);
    label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
    label.setIcon(node.getIcon());
    final JButton button = new JButton();
    button.setIcon(ICON_CLOSE_INACTIVE);
    button.setRolloverIcon(ICON_CLOSE);
    button.setRolloverEnabled(true);
    button.setOpaque(false);
    button.setUI(new BasicButtonUI());
    button.setContentAreaFilled(false);
    button.setFocusable(false);
    button.setBorder(null);
    button.setBorderPainted(false);
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            closeCodePanel(contentPanel);
        }
    });
    panel.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (SwingUtilities.isMiddleMouseButton(e)) {
                closeCodePanel(contentPanel);
            } else if (SwingUtilities.isRightMouseButton(e)) {
                JPopupMenu menu = createTabPopupMenu(contentPanel);
                menu.show(panel, e.getX(), e.getY());
            } else {
                // TODO: make correct event delegation to tabbed pane
                setSelectedComponent(contentPanel);
            }
        }
    });
    panel.add(label);
    panel.add(button);
    panel.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
    return panel;
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) MouseEvent(java.awt.event.MouseEvent) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) BasicButtonUI(javax.swing.plaf.basic.BasicButtonUI) JPopupMenu(javax.swing.JPopupMenu) ActionListener(java.awt.event.ActionListener) JNode(jadx.gui.treemodel.JNode)

Example 3 with BasicButtonUI

use of javax.swing.plaf.basic.BasicButtonUI in project android by JetBrains.

the class ColorListener method buildTopPanel.

@NotNull
private JComponent buildTopPanel(boolean enablePipette) throws ParseException {
    final JComponent result = new Box(BoxLayout.PAGE_AXIS);
    JComponent namePanel = new Box(BoxLayout.LINE_AXIS);
    myPreviewColorName = new JLabel("");
    Font f = myPreviewColorName.getFont();
    myPreviewColorName.setFont(f.deriveFont(f.getStyle() | Font.BOLD));
    myColorSuggestionPreview = new ClickableLabel("CLOSEST MATERIAL COLOR");
    myColorSuggestionPreview.setFont(f.deriveFont(JBUI.scale(8.0f)));
    myColorSuggestionPreview.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            myColorSelectionPanel.setColor(myClosestColor, this);
        }
    });
    namePanel.add(myPreviewColorName);
    namePanel.add(Box.createRigidArea(new Dimension(JBUI.scale(5), 0)));
    namePanel.add(myColorSuggestionPreview);
    namePanel.add(Box.createHorizontalGlue());
    result.add(namePanel);
    final JComponent previewPanel = new Box(BoxLayout.LINE_AXIS);
    if (enablePipette && ColorPipette.isAvailable()) {
        final JButton pipette = new JButton();
        pipette.setUI(new BasicButtonUI());
        pipette.setRolloverEnabled(true);
        pipette.setIcon(AllIcons.Ide.Pipette);
        pipette.setBorder(IdeBorderFactory.createEmptyBorder());
        pipette.setRolloverIcon(AllIcons.Ide.Pipette_rollover);
        pipette.setFocusable(false);
        pipette.addActionListener(e -> {
            myPicker.myOldColor = getColor();
            myPicker.pick();
        });
        previewPanel.add(pipette);
    }
    myPreviewComponent = new ColorPreviewComponent();
    previewPanel.add(myPreviewComponent);
    result.add(previewPanel);
    final JComponent rgbPanel = new Box(BoxLayout.LINE_AXIS);
    if (!UIUtil.isUnderAquaLookAndFeel()) {
        myR_after.setPreferredSize(JBUI.size(14, -1));
        myG_after.setPreferredSize(JBUI.size(14, -1));
        myB_after.setPreferredSize(JBUI.size(14, -1));
    }
    rgbPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
    rgbPanel.add(myA);
    rgbPanel.add(myAlpha);
    myA.setVisible(isARGBMode());
    myAlpha.setVisible(isARGBMode());
    rgbPanel.add(Box.createHorizontalStrut(JBUI.scale(3)));
    rgbPanel.add(myR);
    rgbPanel.add(myRed);
    if (!UIUtil.isUnderAquaLookAndFeel())
        rgbPanel.add(myR_after);
    myR_after.setVisible(false);
    rgbPanel.add(Box.createHorizontalStrut(JBUI.scale(3)));
    rgbPanel.add(myG);
    rgbPanel.add(myGreen);
    if (!UIUtil.isUnderAquaLookAndFeel())
        rgbPanel.add(myG_after);
    myG_after.setVisible(false);
    rgbPanel.add(Box.createHorizontalStrut(JBUI.scale(3)));
    rgbPanel.add(myB);
    rgbPanel.add(myBlue);
    if (!UIUtil.isUnderAquaLookAndFeel())
        rgbPanel.add(myB_after);
    myB_after.setVisible(false);
    rgbPanel.add(Box.createHorizontalStrut(JBUI.scale(3)));
    rgbPanel.add(myFormat);
    JComponent valuesPanel = new Box(BoxLayout.LINE_AXIS);
    rgbPanel.setMaximumSize(JBUI.size(-1, 35));
    valuesPanel.add(rgbPanel);
    final JComponent hexPanel = new Box(BoxLayout.X_AXIS);
    hexPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
    hexPanel.add(myHexLabel);
    hexPanel.add(myHex);
    myHex.setMaximumSize(JBUI.size(120, 25));
    valuesPanel.add(Box.createHorizontalGlue());
    valuesPanel.add(hexPanel);
    result.add(valuesPanel);
    return result;
}
Also used : ClickableLabel(com.android.tools.swing.ui.ClickableLabel) BasicButtonUI(javax.swing.plaf.basic.BasicButtonUI) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with BasicButtonUI

use of javax.swing.plaf.basic.BasicButtonUI in project jdk8u_jdk by JetBrains.

the class bug6797139 method createGui.

private static void createGui() {
    JButton b = new JButton("Probably");
    b.setUI(new BasicButtonUI() {

        protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
            super.paintText(g, b, textRect, text);
            if (text.endsWith("...")) {
                throw new RuntimeException("Text is truncated!");
            }
        }
    });
    b.setSize(b.getPreferredSize());
    BufferedImage image = new BufferedImage(b.getWidth(), b.getHeight(), BufferedImage.TYPE_INT_ARGB);
    Graphics g = image.getGraphics();
    b.paint(g);
    g.dispose();
}
Also used : BasicButtonUI(javax.swing.plaf.basic.BasicButtonUI) BufferedImage(java.awt.image.BufferedImage)

Aggregations

BasicButtonUI (javax.swing.plaf.basic.BasicButtonUI)4 ClickableLabel (com.android.tools.swing.ui.ClickableLabel)1 JNode (jadx.gui.treemodel.JNode)1 FlowLayout (java.awt.FlowLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 BufferedImage (java.awt.image.BufferedImage)1 JButton (javax.swing.JButton)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JPopupMenu (javax.swing.JPopupMenu)1 NotNull (org.jetbrains.annotations.NotNull)1