Lately, I've been assigned a module of the system our team is currently developing. This part of the system uses Java Swing. One of the tasks I had to do concerns asking the user to choose a color and assigning this to the user's profile. Being a Java Swing Noob, I had to research everything first.
I found out that using JColorChooser is an easy way to let the user pick a color he wants.
All you have to do is to call a static method which opens a dialog and returns the color the user chooses.
Then after this, I wanted to have a JTextField with a background which will change together with the color the user chose. Now, I tried using
textField.setbackground();
and
textField.setForeground();
and found out that only the text color will change and not the background inside the JTextField. So, I did a few more searches and found out that a good alternative for this is a JTextPane.
You could check out the following links to help you get started:
JFileChooser
JTextPane
Sunday, November 8, 2009
JTextField, JColorChooser, JTextPane
Labels:
background,
color,
java,
java swing,
JFileChooser,
JTextField,
jtextfield problem,
JTextPane,
swing
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment