Results 1 to 1 of 1
Thread: JComponent gradient background
- 12-30-2008, 12:38 AM #1
Member
- Join Date
- Dec 2008
- Posts
- 1
- Rep Power
- 0
JComponent gradient background
Hi, new to java.
What i am trying to achieve, is to provide a swing component with a gradient background. I started off with a plain background, but even this won't work. Any ideas? I am trying a simple rectangle with a solid background to attach to a box. I realise i can use setbackground, but this is just a start.
Here is my code. Any help would be much appreciated, thanks.
Java Code:private Box bxSide = Box.createVerticalBox(); private void buildSidebar() { //code omitted bxSide.add(jlblStatus); bxSide.add(Box.createVerticalStrut(30)); bxSide.setBorder(BorderFactory.createEmptyBorder(10,10,10,10)); jfrmMain.add(bxSide, BorderLayout.WEST); } public void paintComponent(Graphics g) { Graphics2D g2d = (Graphics2D)g.create(); g2d.setBackground(Color.GREEN); // g2d.clearRect(0,0, bxSide.getWidth(), bxSide.getHeight()); g2d.dispose(); SwingUtilities.paintComponent(g2d, bxSide,this, 0,0,bxSide.getWidth(), bxSide.getHeight()); }
Similar Threads
-
How to Run a .exe in background???
By jazz2k8 in forum New To JavaReplies: 9Last Post: 01-21-2011, 11:27 AM -
polygon-shaped JComponent
By zenMarko in forum New To JavaReplies: 2Last Post: 11-04-2008, 06:06 PM -
CLabel Gradient Background
By Java Tip in forum SWTReplies: 0Last Post: 07-11-2008, 04:39 PM -
MemImage is an in-memory icon showing a Color gradient
By Java Tip in forum java.awtReplies: 0Last Post: 06-23-2008, 11:18 PM -
Color gradient
By Java Tip in forum java.awtReplies: 0Last Post: 06-21-2008, 08:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks