Servus!

Hier mal eine Möglichkeit eure Swing-Komponenten unabhänig vom verwendeten LookAndFeel einzufärben:

Code :
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
 
/*
 * ColorTestForm.java
 *
 * Created on 17. August 2003, 22:45
 */
 
/**
 *
 * @author  Administrator
 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
 
public class ColorTestForm extends javax.swing.JFrame {
    
    /** Creates new form ColorTestForm */
    public ColorTestForm() {
        initComponents();
                
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Test0", "Test1", "Test2", "Test3", "Test4", "Test5" }));
        UIManager.put("ComboBox.selectionBackground", Color.yellow);
        UIManager.put("ComboBox.foreground", Color.red);
        jComboBox1.updateUI();
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;
 
        jPanel1 = new javax.swing.JPanel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
 
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
            }
        });
 
        jPanel1.setLayout(new java.awt.GridBagLayout());
 
        jPanel1.setPreferredSize(new java.awt.Dimension(320, 240));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        jPanel1.add(jComboBox1, gridBagConstraints);
 
        jLabel1.setText("jLabel1");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        jPanel1.add(jLabel1, gridBagConstraints);
 
        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
 
        pack();
    }
    
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {
        System.exit(0);
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new ColorTestForm().show();
    }
    
    
    // Variables declaration - do not modify
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration
    
}

hier : findet ihr eine Liste mit den passenden Keywords für den passenden UIManager.put - Aufruf ....

Gruß Tom