ColorSelectionPopupMenu

ColorSelectionPopupMenu 是颜色选择面板,可在颜色选择面板中进行颜色设置。其接口说明可参见 ColorSelectionPopupMenu 接口说明文档。

示范代码

ColorSelectionPopupMenu 控件使用的示例代码如下:

public class MyDialog extends SmDialog {
    private JButton button;
    public MyDialog() {
        this.setSize(new Dimension(300,200));
        initComponents();
        initLayouts();
        initListener();
    }
    private void initComponents() {
        button = new JButton("颜色选择控件");
    }
    private void initLayouts() {
        this.setLayout(new BorderLayout());
        this.add(button, BorderLayout.NORTH);
    }
    private void initListener() {
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ColorSelectionPopupMenu colorSelectionPopupMenu = new ColorSelectionPopupMenu();
                colorSelectionPopupMenu.addColorChangedListener(new IColorChangedListener() {
                    @Override
                    //当选择颜色改变时,响应的事件
                    public void colorChanged(ColorChangedEvent colorChangedEvent) {
                        button.setForeground(colorChangedEvent.getColor());
                    }
                });
                colorSelectionPopupMenu.show(button,0,button.getHeight());
            }
        });
    }
}

ColorSelectionPopupMenu 控件显示效果如下:

ColorSelectionPopupMenuResult