1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.*;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
public class Enable{ //extends JFrame{
public static void main(String[] args){
new Enable();
}
public Enable(){
//super("test !!!");
/*try{
UIManager.setLookAndFeel ("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch(Exception e){
SwingUtilities.updateComponentTreeUI (getContentPane());
}*/
FontUIResource sansserifPlain11 = new FontUIResource("SansSerif",Font.PLAIN, 22);
UIManager.put("ComboBox.font", sansserifPlain11);
UIManager.put("ComboBox.disabledText", new ColorUIResource(Color.BLACK));
UIManager.put("Button.border", new ColorUIResource(Color.BLACK));
UIManager.put("ComboBox.background", new ColorUIResource(Color.WHITE));
UIManager.put("ComboBox.foreground", new ColorUIResource(Color.RED));
UIManager.put("ComboBox.selectionForeground", new ColorUIResource(Color.BLUE));
UIManager.put("ComboBox.disabledForeground", new ColorUIResource(Color.BLACK));
UIManager.put("ComboBox.disabledBackground", new ColorUIResource(Color.WHITE));
JFrame jf = new JFrame("bonjour");
JComboBox jcb = new JComboBox();
jcb.addItem("hello");
jcb.addItem("the");
jcb.addItem("world");
jcb.setEnabled(true);
jf.getContentPane().add(jcb);
//jf.getContentPane().add(new JLabel("bonjour !!!"));
//jcb.setEnabled(false);
jcb.setEnabled(false);
jf.show();
}
} |
Partager