📄 e880. retrieving the color chooser panels in a jcolorchooser dialog.txt
字号:
There are three chooser panels in the default JColorChooser dialog. Although each is implemented by a class in the javax.swing.colorchooser package, these classes are not public. This example demonstrates how to identify these panels by class name.
JColorChooser chooser = new JColorChooser();
// Retrieve the swatch chooser
findPanel(chooser, "javax.swing.colorchooser.DefaultSwatchChooserPanel");
// Retrieve the HSB chooser
findPanel(chooser, "javax.swing.colorchooser.DefaultHSBChooserPanel");
// Retrieve the RGB chooser
findPanel(chooser, "javax.swing.colorchooser.DefaultRGBChooserPanel");
// Returns the panel instance with the specified name.
// Returns null if not found.
public AbstractColorChooserPanel findPanel(JColorChooser chooser, String name) {
AbstractColorChooserPanel[] panels = chooser.getChooserPanels();
for (int i=0; i<panels.length; i++) {
String clsName = panels[i].getClass().getName();
if (clsName.equals(name)) {
return panels[i];
}
}
return null;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -