Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change color in JFileChooser

Status
Not open for further replies.

PaulBeckett

Programmer
Jan 31, 2002
17
0
0
GB
I have implemented a JFileChooser, but want to be able to customise the color scheme of the background and text color. Does anyone know how I can do this.
Any info / usefull links will be greatly appreciated %-)
Thanks
Paul
 
There is method in the JComponent for setting Background & Foreground try using it . Because you cannot paint that JComponent yourself
 
Thanks for the response. Unfortunately I'm not having much success with setForeground and setBackground.
Below is a code-snippet; as you can see I've tried to use the setForeground tag, it compiles and runs, but just has the standard grey color scheme (fgColor and bgColor are Color objects, that work fine elsewhere in my code).
<CODE_SNIPPET>
final JFileChooser fileChooser = new JFileChooser();
fileChooser.setForeground(fgColor);
fileChooser.setBackground(bgColor);
ConfigFilter configFilter = new ConfigFilter();
fileChooser.setFileFilter(configFilter);
int returnVal = fileChooser.showOpenDialog(QueryApp.this);

if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fileChooser.getSelectedFile();
// Do stuff with file here
}
</CODE_SNIPPET>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top