use of javax.swing.plaf.UIResource in project Botnak by Gocnak.
the class GraphiteButtonUI method paintBackground.
protected void paintBackground(Graphics g, AbstractButton b) {
int w = b.getWidth();
int h = b.getHeight();
Graphics2D g2D = (Graphics2D) g;
Shape savedClip = g.getClip();
if ((b.getBorder() != null) && b.isBorderPainted() && (b.getBorder() instanceof UIResource)) {
Area clipArea = new Area(new RoundRectangle2D.Double(0, 0, w - 1, h - 1, 6, 6));
clipArea.intersect(new Area(savedClip));
g2D.setClip(clipArea);
}
super.paintBackground(g, b);
g2D.setClip(savedClip);
}
use of javax.swing.plaf.UIResource in project intellij-community by JetBrains.
the class JBViewport method updateBorder.
private static void updateBorder(Component view) {
// tables are not supported yet
if (view instanceof JTable)
return;
if (view instanceof JComponent) {
JComponent component = (JComponent) view;
Border border = component.getBorder();
// already set
if (border instanceof ViewBorder)
return;
component.setBorder(border == null || border instanceof UIResource ? new ResourceViewBorder(border) : new ViewBorder(border));
}
}
use of javax.swing.plaf.UIResource in project intellij-community by JetBrains.
the class DarculaSpinnerUI method createArrow.
private JButton createArrow(@MagicConstant(intValues = { SwingConstants.NORTH, SwingConstants.SOUTH }) int direction) {
final Color shadow = UIUtil.getPanelBackground();
final Color enabledColor = new JBColor(Gray._255, UIUtil.getLabelForeground());
final Color disabledColor = new JBColor(Gray._200, UIUtil.getLabelForeground().darker());
BasicArrowButton b = new BasicArrowButton(direction, shadow, shadow, enabledColor, shadow) {
@Override
public void paint(Graphics g) {
paintArrowButton(g, this, direction);
}
@Override
public boolean isOpaque() {
return false;
}
@Override
public void paintTriangle(Graphics g, int x, int y, int size, int direction, boolean isEnabled) {
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
int mid;
final int w = 8;
final int h = 6;
mid = w / 2;
g.setColor(isEnabled ? enabledColor : disabledColor);
g.translate(x, y);
switch(direction) {
case SOUTH:
g.fillPolygon(new int[] { 0, w, mid }, new int[] { 1, 1, h }, 3);
break;
case NORTH:
g.fillPolygon(new int[] { 0, w, mid }, new int[] { h - 1, h - 1, 0 }, 3);
break;
case WEST:
case EAST:
}
g.translate(-x, -y);
config.restore();
}
};
Border buttonBorder = UIManager.getBorder("Spinner.arrowButtonBorder");
if (buttonBorder instanceof UIResource) {
// Wrap the border to avoid having the UIResource be replaced by
// the ButtonUI. This is the opposite of using BorderUIResource.
b.setBorder(new CompoundBorder(buttonBorder, null));
} else {
b.setBorder(buttonBorder);
}
b.setInheritsPopupMenu(true);
return b;
}
use of javax.swing.plaf.UIResource in project intellij-community by JetBrains.
the class DialogWrapper method unregisterKeyboardActions.
public static void unregisterKeyboardActions(@Nullable Component rootPane) {
int[] flags = { JComponent.WHEN_FOCUSED, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, JComponent.WHEN_IN_FOCUSED_WINDOW };
for (JComponent eachComp : UIUtil.uiTraverser(rootPane).traverse().filter(JComponent.class)) {
ActionMap actionMap = eachComp.getActionMap();
if (actionMap == null)
continue;
for (KeyStroke eachStroke : eachComp.getRegisteredKeyStrokes()) {
boolean remove = true;
for (int i : flags) {
Object key = eachComp.getInputMap(i).get(eachStroke);
Action action = key == null ? null : actionMap.get(key);
if (action instanceof UIResource)
remove = false;
}
if (remove)
eachComp.unregisterKeyboardAction(eachStroke);
}
}
}
use of javax.swing.plaf.UIResource in project intellij-community by JetBrains.
the class JBList method installDefaultCopyAction.
private void installDefaultCopyAction() {
final Action copy = getActionMap().get("copy");
if (copy == null || copy instanceof UIResource) {
Action newCopy = new AbstractAction() {
@Override
public boolean isEnabled() {
return getSelectedIndex() != -1;
}
@Override
public void actionPerformed(ActionEvent e) {
ArrayList<String> selected = new ArrayList<>();
JBList list = JBList.this;
ListCellRenderer renderer = list.getCellRenderer();
if (renderer != null) {
for (int index : getSelectedIndices()) {
Object value = list.getModel().getElementAt(index);
//noinspection unchecked
Component c = renderer.getListCellRendererComponent(list, value, index, true, true);
SimpleColoredComponent coloredComponent = null;
if (c instanceof JComponent) {
coloredComponent = UIUtil.findComponentOfType((JComponent) c, SimpleColoredComponent.class);
}
if (coloredComponent != null) {
selected.add(coloredComponent.toString());
} else if (c instanceof JTextComponent) {
selected.add(((JTextComponent) c).getText());
} else if (value != null) {
selected.add(value.toString());
}
}
}
if (selected.size() > 0) {
String text = StringUtil.join(selected, " ");
CopyPasteManager.getInstance().setContents(new StringSelection(text));
}
}
};
getActionMap().put("copy", newCopy);
}
}
Aggregations