本文整理汇总了Java中javax.swing.JColorChooser.createDialog方法的典型用法代码示例。如果您正苦于以下问题:Java JColorChooser.createDialog方法的具体用法?Java JColorChooser.createDialog怎么用?Java JColorChooser.createDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JColorChooser
的用法示例。
在下文中一共展示了JColorChooser.createDialog方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ColorEditor
import javax.swing.JColorChooser; //导入方法依赖的package包/类
public ColorEditor() {
// Set up the editor (from the table's point of view),
// which is a button.
// This button brings up the color chooser dialog,
// which is the editor from the user's point of view.
button = new JButton();
button.setActionCommand(EDIT);
button.addActionListener(this);
button.setBorderPainted(false);
// Set up the dialog that the button brings up.
colorChooser = new JColorChooser();
dialog = JColorChooser.createDialog(button, "Pick a Color", true, // modal
colorChooser, this, // OK button handler
null); // no CANCEL button handler
}
示例2: 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();
}
}
示例3: showDialog
import javax.swing.JColorChooser; //导入方法依赖的package包/类
private Color showDialog(Component component, String title, Color initialColor) throws HeadlessException {
final JColorChooser chooser = new JColorChooser(initialColor != null ? initialColor : Color.white);
// configuring color chooser panel
chooser.setPreviewPanel(new JPanel());
if (colorChoosers != null) {
chooser.setChooserPanels(colorChoosers);
} else {
chooser.removeChooserPanel(chooser.getChooserPanels()[0]);
chooser.removeChooserPanel(chooser.getChooserPanels()[1]);
}
// creating dialog
ColorTracker ok = new ColorTracker(chooser);
JDialog dialog = JColorChooser.createDialog(component, title, true, chooser, ok, null);
dialog.setVisible(true); // blocks until user brings dialog down...
return ok.getColor();
}
示例4: actionPerformed
import javax.swing.JColorChooser; //导入方法依赖的package包/类
/**
* Handles events from the editor button and from
* the dialog's OK button.
*/
public void actionPerformed(ActionEvent e) {
if (EDIT.equals(e.getActionCommand())) {
//The user has clicked the cell, so
//bring up the dialog.
button.setBackground(currentColor);
colorChooser.setColor(currentColor);
JDialog dialog = JColorChooser.createDialog(button, "Choose User Class Color", true, //modal
colorChooser, this, //OK button handler
null); //no CANCEL button handler
Dimension scrDim = Toolkit.getDefaultToolkit().getScreenSize();
dialog.setBounds((scrDim.width - dialog.getWidth()) / 2, (scrDim.height - dialog.getHeight()) / 2, dialog.getWidth(), dialog.getHeight());
dialog.setVisible(true);
//Make the renderer reappear.
fireEditingStopped();
} else { //User pressed dialog's "OK" button.
currentColor = colorChooser.getColor();
}
}
示例5: ColorCellEditor
import javax.swing.JColorChooser; //导入方法依赖的package包/类
/**
* Constructor.
*/
public ColorCellEditor() {
button = new JButton() {
@Override
public void paintComponent(Graphics g) {
// When the buttons are pressed they are redrawn with the default
// background color but not what we want.
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
}
};
button.setActionCommand(EDIT);
button.addActionListener(this);
//Set up the dialog that the button brings up.
colorChooser = new JColorChooser();
dialog = JColorChooser.createDialog(button, "Pick a Color", true, colorChooser, this, null);
}
示例6: show
import javax.swing.JColorChooser; //导入方法依赖的package包/类
static JDialog show(JColorChooser chooser) {
JDialog dialog = JColorChooser.createDialog(null, null, false, chooser, null, null);
dialog.setVisible(true);
// block till displayed
Point point = null;
while (point == null) {
try {
point = dialog.getLocationOnScreen();
}
catch (IllegalStateException exception) {
pause(DELAY);
}
}
return dialog;
}
示例7: actionPerformed
import javax.swing.JColorChooser; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent actionEvent) {
Object object = actionEvent.getSource();
Component component = object instanceof Component ? (Component)object : null;
JDialog jDialog = JColorChooser.createDialog(component, "ColorChooser", false, new JColorChooser(Color.BLUE), null, null);
jDialog.setVisible(true);
}
示例8: actionPerformed
import javax.swing.JColorChooser; //导入方法依赖的package包/类
/**
* Method description
*
* @see
* @param objPactionEvent
*/
@Override final public void actionPerformed(ActionEvent objPactionEvent) {
Tools.debug("PreferenceStringLocalColorJButton.actionPerformed()");
int intLtitleStringLanguageIndex = Constants.bytS_UNCLASS_NO_VALUE;
switch (this.bytGcolorPreferenceType) {
case PreferencesJDialog.bytS_STRING_LOCAL_PREFERENCE_SITESWAP_DAY:
intLtitleStringLanguageIndex = Language.intS_TITLE_DAY_SITESWAP_COLOR;
break;
case PreferencesJDialog.bytS_STRING_LOCAL_PREFERENCE_SITESWAP_NIGHT:
intLtitleStringLanguageIndex = Language.intS_TITLE_NIGHT_SITESWAP_COLOR;
break;
case PreferencesJDialog.bytS_STRING_LOCAL_PREFERENCE_BACKGROUND_DAY:
intLtitleStringLanguageIndex = Language.intS_TITLE_DAY_BACKGROUND_COLOR;
break;
case PreferencesJDialog.bytS_STRING_LOCAL_PREFERENCE_BACKGROUND_NIGHT:
intLtitleStringLanguageIndex = Language.intS_TITLE_NIGHT_BACKGROUND_COLOR;
break;
case PreferencesJDialog.bytS_STRING_LOCAL_PREFERENCE_JUGGLER_DAY:
intLtitleStringLanguageIndex = Language.intS_TITLE_DAY_JUGGLER_COLOR;
break;
case PreferencesJDialog.bytS_STRING_LOCAL_PREFERENCE_JUGGLER_NIGHT:
intLtitleStringLanguageIndex = Language.intS_TITLE_NIGHT_JUGGLER_COLOR;
break;
}
if (this.objGcolorChooserJDialog == null) {
// Color chooser dialog title :
// Color chooser dialog :
this.objGjColorChooser = new PreferencesJColorChooser(this.objGcontrolJFrame, this.objGpreferencesJDialog, this.bytGcolorPreferenceType);
this.objGjColorChooser.setOpaque(true);
this.objGcolorChooserJDialog =
JColorChooser.createDialog( this.objGpreferencesJDialog,
Strings.strS_EMPTY,
true,
this.objGjColorChooser,
this.objGjColorChooser.getActionListener(true),
this.objGjColorChooser.getActionListener(false));
Tools.doSetFont(this.objGcolorChooserJDialog, this.objGcontrolJFrame.getFont());
this.objGcolorChooserJDialog.validate();
this.objGcolorChooserJDialog.pack();
final Rectangle objLcolorChooserJDialogRectangle = this.objGcolorChooserJDialog.getBounds();
this.objGcolorChooserJDialog.setBounds( (int) objLcolorChooserJDialogRectangle.getX() - 10,
(int) objLcolorChooserJDialogRectangle.getY() - 20,
(int) objLcolorChooserJDialogRectangle.getWidth() + 20,
(int) objLcolorChooserJDialogRectangle.getHeight() + 20);
this.objGcolorChooserJDialog.setResizable(false);
}
// Display the color chooser dialog :
this.objGjColorChooser.stateChanged(null);
this.objGcolorChooserJDialog.setTitle(this.objGpreferencesJDialog.getLanguageString(intLtitleStringLanguageIndex));
this.objGcolorChooserJDialog.setVisible(true);
}