import java.awt.*;
import javax.swing.*;
public class PaintDemo {
private final JFrame window;
public PaintDemo() {
window = new JFrame("PaintDemo");
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.setSize(280, 300);
window.setLocationRelativeTo(null);
window.add(new DrawingArea());
window.setVisible(true);
}
public static void main(final String... args) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
} catch (Exception ex) {
}
UIManager.put("ScrollBar.thumb", new Color(130, 130, 130, 80));
UIManager.put("ScrollBar.thumbShadow", new Color(130, 130, 130, 80));
UIManager.put("ScrollBar.thumbHighlight", new Color(130, 130, 130, 80));
UIManager.put("ScrollBar.track", new Color(0, 0, 0, 0));
Runnable gui = new Runnable() {
public void run() {
PaintDemo paintDemo = new PaintDemo();
}
};
SwingUtilities.invokeLater(gui);
}
private class DrawingArea extends JComponent {
public DrawingArea() {
add(textbox("1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n", 100, 90, 60, 100));
}
@Override
protected void paintComponent(final Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(Color.LIGHT_GRAY);
g2.fillOval(80, 10, 100, 250);
g2.setColor(Color.ORANGE);
g2.fillOval(10, 60, 250, 100);
}
private JScrollPane textbox(final String text, final int x, final int y,
final int width, final int height) {
JTextArea textarea = new JTextArea(text);
JScrollPane scroller = new JScrollPane(textarea);
scroller.setBounds(x, y, width, height);
//make transparent:
scroller.getHorizontalScrollBar().setOpaque(false);
scroller.getVerticalScrollBar().setOpaque(false);
Component[] c = scroller.getHorizontalScrollBar().getComponents();
for (int i = 0; i < c.length; i++) {
JButton component = (JButton) c[i];
component.setOpaque(false);
}
c = scroller.getVerticalScrollBar().getComponents();
for (int i = 0; i < c.length; i++) {
JButton component = (JButton) c[i];
component.setOpaque(false);
}
textarea.setOpaque(false);
scroller.getViewport().setOpaque(false);
scroller.setOpaque(false);
//
return scroller;
}
}
}