This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
RE: Controlling the Layout of a disabled JComboBox
Posted by Kishori Sharan on July 21, 2000 at 11:47 AM
Hi You can try setting foreground color for JComboBox and JCheckBox. When you run the following applet you will find the difference in text color when you set the foreground for check box and combo box using setForeground () method. It may be what you are looking for. Thanx Kishori import java.util.* ; import javax.swing.*; import java.awt.*; public class Applet1 extends JApplet { public void init ( ) { Container cp = getContentPane () ; cp.setLayout( new FlowLayout ( ) ) ; cp.setBackground ( Color.white ) ; //Try soem other color too JCheckBox jcbx1 = new JCheckBox ( "Enabled" ) ; JCheckBox jcbx2 = new JCheckBox ( "Disabled" ) ; jcbx2.setForeground ( Color.gray ) ; cp.add ( jcbx1 ) ; cp.add ( jcbx2 ) ; Object[] str = { new String ( "Hello" ), new String ( "Thanx" ) } ;
JComboBox jcombo1 = new JComboBox ( str ) ; JComboBox jcombo2 = new JComboBox ( str ) ; jcombo2.setForeground ( Color.gray ) ; cp.add ( jcombo1 ) ; cp.add ( jcombo2 ) ; } }
Replies:
|