Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Swing / AWT / SWT
Change color of JButtons in Java 5.0
Chandra Sekar
Ranch Hand
Posts: 94
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
I like the 3D look of JButtons in
Java
5. However when change the foreground color using setForeground(), the 3D look of the Button is lost.
I'd like to have a Orange shade for my buttons instead of the default blue shade. How can I change it without losing the 3D look of the button.
Chandru
Chandra Sekar
Ranch Hand
Posts: 94
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
How come, ranchers are unable to solve a problem??
Is this impossible? If so, is there a work-around??
Chandru
Jeff Albertson
Ranch Hand
Posts: 1780
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
import java.awt.*; import java.util.*; import javax.swing.*; import java.util.List; public class Example { public static void main(String[] args) { EventQueue.invokeLater(new Runnable(){ public void run() {gui();} }); } static void gui() { JPanel p = new JPanel(); adjustGradient(Color.ORANGE); p.add(new JButton("button")); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(p, BorderLayout.NORTH); f.pack(); f.setLocationRelativeTo(null); f.setVisible(true); } static void adjustGradient(Color color) { List list = new ArrayList(); list.add(new Float(0.3F)); list.add(new Float(0)); list.add(color); list.add(Color.WHITE); list.add(color.darker().darker()); UIManager.put("Button.gradient", list); } }
There is no emoticon for what I am feeling!
Chandra Sekar
Ranch Hand
Posts: 94
posted 17 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Thanx Jeff. Sorry for the delayed reply. I was a bit busy with exams.
By the way could you please explain it?
Chandru
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JButtons in f. Windows XP Style
JButton is not displaying the background color
Creating a NxN grid.
Disabling the JTable
Buttons in a java 3d canvas!
More...