6

我想将 taskpanecontainer 的蓝色背景颜色更改为白色。我已经使用了下面的线,但这条线没有任何影响。

UIManager.put("TaskPaneContainer.background", Color.LIGHT_GRAY);

请给我一些改变背景颜色的想法。

public class NewJFrame2 extends javax.swing.JFrame {

        public NewJFrame2() {
            initComponents();
            setSize(462, 300);
            add(doInit());
            setBackground(Color.WHITE);
        }

        private Component doInit() {
                JXTaskPaneContainer taskpanecontainer = new JXTaskPaneContainer();
                //taskpanecontainer.setLayout(new VerticalLayout(2));

                JXTaskPane taskpane1 = new JXTaskPane();
                taskpane1.setTitle("First TaskPane");
                JXTable table = new JXTable();
                DefaultTableModel model = new DefaultTableModel();
                model.addColumn("ParameterName");
                model.addColumn("ParameterType");
                model.addColumn("Operation");
                model.addRow(new Object[]{"Request", "String", "Delete"});
                model.addRow(new Object[]{"Request", "String", "Delete"});

                table.setModel(model);
                ((JComponent) taskpane1.getContentPane()).setBorder(BorderFactory.createEmptyBorder(0,5,0,5));
                taskpane1.add(table);

                taskpanecontainer.add(taskpane1);

                taskpanecontainer.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0));

                return taskpanecontainer;
            }
    }

我也在分享图像,所以我已经在你的脑海中清除了.. 在此处输入图像描述

谢谢

4

2 回答 2

5

As always, the background property might not be respected by LAFs. That's f.i. the case for a taskpaneContainer in Win: it uses a (Swingx!) painter to fill its background. So the property to provide is

UIManager.put("TaskPaneContainer.backgroundPainter", new MattePainter(Color.RED));
于 2013-02-04T11:58:32.850 回答
0

接下来的事情非常简单,对我来说就像一个魅力:

taskPaneContainer.setBackground(Color.WHITE);
taskPaneContainer.setBackgroundPainter(null);
于 2017-05-01T16:41:43.067 回答