本文整理匯總了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);
}