java jsplitpane_java – 如何更改JSplitPane的颜色

我写了一个小程序,在读一本关于swing的书时,在两个标签之间创建了一个JSplitPane.

问题是JSplitPane几乎看不到(至少在我的操作系统中 – MAC OS Lion)并且在它上面设置一些属性(如前景色)似乎不起作用.

这是代码:

//Demonstrate a simple JSplitPane

package swingexample4_6;

import javax.swing.*;

import java.awt.*;

public class SplitPaneDemo {

//constructor

public SplitPaneDemo()

{

//Create a new JFrame container.

//Use the default border layout

JFrame jfrm = new JFrame("Split Pane Demo");

//Give the frame an initial size

jfrm.setSize(380, 150);

//Terminate the program when the user closes the application

jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//--Make two labels to show the split pane

JLabel jlab = new JLabel(" Left side: ABCDEFGHIJKLMNOPQRSTUVWXYZ");

JLabel jlab2 = new JLabel(" Right side: ABCDEFGHIJKLMNOPQRSTUVWXYZ");

//Set the minimum size for each label

//This step is not technically needed to use a split pane,

//but it enables the split pane resizing features to be

//used to their maximum extent

jlab.setMinimumSize(new Dimension(90, 30));

jlab2.setMinimumSize(new Dimension(90, 30));

//--Create a split pane

JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jlab, jlab2);

//Code to get a list of component names in the console

Component[] listComponents = jsp.getComponents();

String theList;

for (Component myComponent: listComponents)

{

theList = myComponent.toString();

System.out.println(theList);

}

//Add the split pane to the content pane

jfrm.getContentPane().add(jsp);

//Display the frame

jfrm.setVisible(true);

}

public static void main(String[] args) {

//Create the frame on the event dispatching thread

SwingUtilities.invokeLater(new Runnable(){

@Override

public void run() {

new SplitPaneDemo();

}

});

}

}

有什么方法可以改变它的颜色,这样才能真正脱颖而出吗?

谢谢.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值