本文整理匯總了Java中javax.swing.JColorChooser.getColor方法的典型用法代碼示例。如果您正苦於以下問題:Java JColorChooser.getColor方法的具體用法?Java JColorChooser.getColor怎麽用?Java JColorChooser.getColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JColorChooser
的用法示例。
在下文中一共展示了JColorChooser.getColor方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: actionPerformed
import javax.swing.JColorChooser; //導入方法依賴的package包/類
@Override
public void actionPerformed(ActionEvent ae) {
if (ae.getSource()==this.button) {
//The user has clicked the cell, so bring up the dialog.
button.setBackground(currentColor);
//Set up the dialog that the button brings up.
colorChooser = new JColorChooser();
colorChooser.setColor(currentColor);
JDialog dialog = JColorChooser.createDialog(button, "Pick a Color", true, colorChooser, this, null);
dialog.setVisible(true);
// --- From here: user action in the dialog ---
fireEditingStopped();
} else { //User pressed dialog's "OK" button.
currentColor = colorChooser.getColor();
}
}
示例2: showDialog
import javax.swing.JColorChooser; //導入方法依賴的package包/類
public static Color showDialog(Component component, String title,
Color initial) {
JColorChooser choose = new JColorChooser(initial);
JDialog dialog = createDialog(component, title, true, choose, null, null);
AbstractColorChooserPanel[] panels = choose.getChooserPanels();
for (AbstractColorChooserPanel accp : panels) {
choose.removeChooserPanel(accp);
}
GrayScaleSwatchChooserPanel grayScaleSwatchChooserPanelFreeStyle = new GrayScaleSwatchChooserPanel();
GrayScalePanel grayScalePanelFreeStyle = new GrayScalePanel();
choose.addChooserPanel(grayScaleSwatchChooserPanelFreeStyle);
choose.addChooserPanel(grayScalePanelFreeStyle);
dialog.getContentPane().add(choose);
dialog.pack();
dialog.setVisible(true);//.show();
return choose.getColor();
}
示例3: main
import javax.swing.JColorChooser; //導入方法依賴的package包/類
public static void main(String[] args) {
JColorChooser chooser = new JColorChooser();
chooser.setColor(new Color(new Random().nextInt()));
Color before = chooser.getColor();
Color after = copy(chooser).getColor();
if (!after.equals(before)) {
throw new Error("color is changed after serialization");
}
}