How to change the bg color of JXTaskPaneContainer
Asked Answered
A

2

7

I want to change blue background color to white of taskpanecontainer. I have used below line but nothing is effected by this line.

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

Please give me some idea to change bg color.

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;
            }
    }

I am sharing the image also so I have cleared in your mind.. enter image description here

Thanks

Alveolus answered 4/2, 2013 at 11:29 Comment(0)
G
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));
Grasp answered 4/2, 2013 at 11:58 Comment(1)
is this safe to do? why swingx don't have a way to edit this?Snailpaced
D
1

The next thing is very simple and worked for me like a charm:

taskPaneContainer.setBackground(Color.WHITE);
taskPaneContainer.setBackgroundPainter(null);
Disinfect answered 1/5, 2017 at 16:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.