import java.awt.Color; import java.awt.FlowLayout; import java.awt.GradientPaint; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import org.jdesktop.swingx.JXTitledPanel; import org.jdesktop.swingx.painter.MattePainter; public class JXTitledPanelBsp { private static final Color TOP_BG_COLOR = new Color(1f,.6f, .5f); private static final Color BOTTOM_BG_COLOR = new Color(.6f, .3f, .3f); private static final Color FG_COLOR = new Color(5, 10, 40); public static void main(String[] args) { JPanel cPanel = new JPanel(new FlowLayout()); cPanel.add(new JLabel("Text")); cPanel.add(new JButton("klick mich")); JXTitledPanel tPanel = new JXTitledPanel("\u00DCberschrift", cPanel); GradientPaint paint = new GradientPaint(0f, 0f, TOP_BG_COLOR, 0f, 1f, BOTTOM_BG_COLOR); MattePainter painter = new MattePainter(paint); painter.setPaintStretched(true); tPanel.setTitlePainter(painter); tPanel.setTitleForeground(FG_COLOR); JFrame frame = new JFrame(); frame.add(tPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationRelativeTo(null); frame.setTitle("JXTitledPanel- Beispiel"); frame.setSize(300, 300); frame.setVisible(true); } }