use of com.android.tools.swing.ui.ClickableLabel 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;
}
Aggregations