Example usage for javax.swing SwingUtilities paintComponent

List of usage examples for javax.swing SwingUtilities paintComponent

Introduction

In this page you can find the example usage for javax.swing SwingUtilities paintComponent.

Prototype

public static void paintComponent(Graphics g, Component c, Container p, Rectangle r) 

Source Link

Document

Paints a component to the specified Graphics.

Usage

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);
    }
}