Hello guyz.
Is it possible to add gradient background to dock station?
How can I do that?
Hello guyz.
Is it possible to add gradient background to dock station?
How can I do that?
You like the movie “mission impossible”?
The framework uses many layers of JPanels and JComponents, accessing and modifying them directly may proof to be a lot of work (and not possible with the current version of the framework).
I suggest using the LookAndFeel to replace the PanelUI and ComponentUI of all Panels and Components of your application. Then each Component has to find out whether it belongs to some DockStation and paint its background accordingly.
[QUOTE=Beni]You like the movie „mission impossible“?
The framework uses many layers of JPanels and JComponents, accessing and modifying them directly may proof to be a lot of work (and not possible with the current version of the framework).
I suggest using the LookAndFeel to replace the PanelUI and ComponentUI of all Panels and Components of your application. Then each Component has to find out whether it belongs to some DockStation and paint its background accordingly.[/QUOTE]
Thanks for your idea. I’ve done.
Here’s the screenshot:
Nice
Hi,
I’m trying to solve the same problem. Could you please share the code for you test application?
I’m used NimbusLookAndFeel.
public class MyLookAndFeel extends NimbusLookAndFeel {
public MyLookAndFeel () {
super();
getDefaults().put("Panel.opaque", Boolean.FALSE);
getDefaults().put("Viewport.opaque", Boolean.FALSE);
getDefaults().put("RootPane.opaque", Boolean.FALSE);
}
}
protected void paintComponent(Graphics g) {
if (!isOpaque()) {
super.paintComponent(g);
return;
}
// paint background
int w = getWidth();
int h = getHeight();
// Paint a gradient from top to bottom
GradientPaint gp = new GradientPaint(
0, 0, new Color(87, 121, 240),
0, h, new Color(225, 243, 244));
Graphics2D g2d = (Graphics2D) g;
g2d.setPaint(gp);
g2d.fillRect(0, 0, w, h);
setOpaque(false);
super.paintComponent(g);
setOpaque(true);
}
MyLookAndFeel lookAndFeel = new MyLookAndFeel ();
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
UIManager.setLookAndFeel(lookAndFeel);
JFrame frame = new JFrame("frame");
If someone need I can upload the full test source code.
Thanks very much for the quick response. I got it working. Cheers.