List of usage examples for javax.swing SwingUtilities paintComponent
public static void paintComponent(Graphics g, Component c, Container p, Rectangle r)
Graphics
. From source file:Main.java
@Override public void paint(Graphics g, JComponent c) { super.paint(g, c); if (c instanceof JLayer == false) { return;/*from w w w .j ava 2 s . c o m*/ } JLayer jlayer = (JLayer) c; JTabbedPane tabPane = (JTabbedPane) jlayer.getView(); for (int i = 0; i < tabPane.getTabCount(); i++) { Rectangle rect = tabPane.getBoundsAt(i); Dimension d = button.getPreferredSize(); int x = rect.x + rect.width - d.width - 2; int y = rect.y + (rect.height - d.height) / 2; Rectangle r = new Rectangle(x, y, d.width, d.height); button.setForeground(r.contains(pt) ? Color.RED : Color.BLACK); SwingUtilities.paintComponent(g, button, p, r); } }