use of java.awt.event.ItemEvent in project pcgen by PCGen.
the class PCGenFrame method maybeShowWarningConfirm.
@Override
public Boolean maybeShowWarningConfirm(String title, String message, String checkBoxText, final PropertyContext context, final String contextProp) {
if (!context.getBoolean(contextProp, true)) {
return null;
}
final JCheckBox checkBox = new JCheckBox(checkBoxText, true);
checkBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
context.setBoolean(contextProp, checkBox.isSelected());
}
});
JPanel panel = buildMessageLabelPanel(message, checkBox);
int ret = JOptionPane.showConfirmDialog(this, panel, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
return ret == JOptionPane.YES_OPTION;
}
use of java.awt.event.ItemEvent in project pcgen by PCGen.
the class PCGenFrame method showMatureDialog.
private void showMatureDialog(String text) {
Logging.errorPrint("Warning: The following datasets contains mature themes. User discretion is advised.");
Logging.errorPrint(text);
final JDialog aFrame = new JDialog(this, LanguageBundle.getString("in_matureTitle"), true);
final JPanel jPanel1 = new JPanel();
final JPanel jPanel3 = new JPanel();
final JLabel jLabel1 = new //$NON-NLS-1$
JLabel(//$NON-NLS-1$
LanguageBundle.getString("in_matureWarningLine1"), SwingConstants.CENTER);
final JLabel jLabel2 = new //$NON-NLS-1$
JLabel(//$NON-NLS-1$
LanguageBundle.getString("in_matureWarningLine2"), SwingConstants.CENTER);
//$NON-NLS-1$
final JCheckBox jCheckBox1 = new JCheckBox(LanguageBundle.getString("in_licShowOnLoad"));
//$NON-NLS-1$
final JButton jClose = new JButton(LanguageBundle.getString("in_close"));
//$NON-NLS-1$
jClose.setMnemonic(LanguageBundle.getMnemonic("in_mn_close"));
jPanel1.setLayout(new BorderLayout());
jPanel1.add(jLabel1, BorderLayout.NORTH);
jPanel1.add(jLabel2, BorderLayout.SOUTH);
HtmlPanel htmlPanel = new HtmlPanel();
HtmlRendererContext theRendererContext = new SimpleHtmlRendererContext(htmlPanel, new SimpleUserAgentContext());
htmlPanel.setHtml(text, "", theRendererContext);
jPanel3.add(jCheckBox1);
jPanel3.add(jClose);
final PropertyContext context = PCGenSettings.OPTIONS_CONTEXT;
jCheckBox1.setSelected(context.getBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD));
jClose.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
aFrame.dispose();
}
});
jCheckBox1.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent evt) {
context.setBoolean(PCGenSettings.OPTION_SHOW_MATURE_ON_LOAD, jCheckBox1.isSelected());
}
});
aFrame.getContentPane().setLayout(new BorderLayout());
aFrame.getContentPane().add(jPanel1, BorderLayout.NORTH);
aFrame.getContentPane().add(htmlPanel, BorderLayout.CENTER);
aFrame.getContentPane().add(jPanel3, BorderLayout.SOUTH);
aFrame.setSize(new Dimension(456, 176));
Utility.setComponentRelativeLocation(this, aFrame);
aFrame.setVisible(true);
}
use of java.awt.event.ItemEvent in project voltdb by VoltDB.
the class FontDialogSwing method creatFontDialog.
/**
* Create and display FontDialogSwing Dialog.
*
*/
public static void creatFontDialog(DatabaseManagerSwing owner) {
if (isRunning) {
frame.setVisible(true);
} else {
CommonSwing.setSwingLAF(frame, CommonSwing.Native);
fOwner = owner;
frame.setIconImage(CommonSwing.getIcon("Frame"));
isRunning = true;
frame.setSize(600, 100);
CommonSwing.setFramePositon(frame);
ckbitalic = new JCheckBox(new ImageIcon(CommonSwing.getIcon("ItalicFont")));
ckbitalic.putClientProperty("is3DEnabled", Boolean.TRUE);
ckbitalic.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setStyle();
}
});
ckbbold = new JCheckBox(new ImageIcon(CommonSwing.getIcon("BoldFont")));
ckbbold.putClientProperty("is3DEnabled", Boolean.TRUE);
ckbbold.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setStyle();
}
});
fgColorButton = new JButton("Foreground", new ImageIcon(CommonSwing.getIcon("ColorSelection")));
fgColorButton.putClientProperty("is3DEnabled", Boolean.TRUE);
fgColorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColor(FOREGROUND);
}
});
bgColorButton = new JButton("Background", new ImageIcon(CommonSwing.getIcon("ColorSelection")));
bgColorButton.putClientProperty("is3DEnabled", Boolean.TRUE);
bgColorButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setColor(BACKGROUND);
}
});
closeButton = new JButton("Close", new ImageIcon(CommonSwing.getIcon("Close")));
closeButton.putClientProperty("is3DEnabled", Boolean.TRUE);
closeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.setVisible(false);
}
});
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fontNames = ge.getAvailableFontFamilyNames();
Dimension fontsComboBoxDimension = new Dimension(160, 25);
fontsComboBox = new JComboBox(fontNames);
fontsComboBox.putClientProperty("is3DEnabled", Boolean.TRUE);
fontsComboBox.setMaximumSize(fontsComboBoxDimension);
fontsComboBox.setPreferredSize(fontsComboBoxDimension);
fontsComboBox.setMaximumSize(fontsComboBoxDimension);
fontsComboBox.setEditable(false);
fontsComboBox.setSelectedItem(defaultFont);
fontsComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setFont();
}
});
// weconsultants@users 20050215 - Added for Compatbilty fix for JDK 1.3
fontSizesComboBox = new JComboBox(fontSizes);
Dimension spinnerDimension = new Dimension(45, 25);
fontSizesComboBox.putClientProperty("is3DEnabled", Boolean.TRUE);
fontSizesComboBox.setMinimumSize(spinnerDimension);
fontSizesComboBox.setPreferredSize(spinnerDimension);
fontSizesComboBox.setMaximumSize(spinnerDimension);
fontSizesComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent evt) {
if (evt.getStateChange() == ItemEvent.SELECTED) {
setFontSize((String) evt.getItem());
}
}
});
// weconsultants@users 20050215 - Commented out for Compatbilty fix for JDK 1.3
// Dimension spinnerDimension = new Dimension(50, 25);
// spinnerFontSizes = new JSpinner();
// spinnerFontSizes.putClientProperty("is3DEnabled", Boolean.TRUE);
// spinnerFontSizes.setMinimumSize(spinnerDimension);
// spinnerFontSizes.setPreferredSize(spinnerDimension);
// spinnerFontSizes.setMaximumSize(spinnerDimension);
// spinnerModelSizes = new SpinnerNumberModel(12, 8, 72, 1);
// spinnerFontSizes.setModel(spinnerModelSizes);
// spinnerFontSizes.addChangeListener(new ChangeListener() {
// public void stateChanged(ChangeEvent e) {
// setFontSize();
// }
// });
Container contentPane = frame.getContentPane();
contentPane.setLayout(new FlowLayout());
contentPane.add(fontsComboBox);
// weconsultants@users 20050215 - Commented out for Compatbilty fix for 1.3
// contentPane.add(spinnerFontSizes);
// weconsultants@users 20050215 - Added for Compatbilty fix for 1.3
contentPane.add(fontSizesComboBox);
contentPane.add(ckbbold);
contentPane.add(ckbitalic);
contentPane.add(fgColorButton);
contentPane.add(bgColorButton);
contentPane.add(closeButton);
frame.pack();
frame.setVisible(false);
}
}
use of java.awt.event.ItemEvent in project kotlin by JetBrains.
the class KotlinIntroduceTypeAliasDialog method init.
@Override
protected void init() {
super.init();
//noinspection unchecked
visibilityBox.setModel(new DefaultComboBoxModel(getApplicableVisibilities().toArray()));
//noinspection unchecked
visibilityBox.setRenderer(new DefaultListCellRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
String tokenValue = value != null ? ((KtModifierKeywordToken) value).getValue() : null;
return super.getListCellRendererComponent(list, tokenValue, index, isSelected, cellHasFocus);
}
});
aliasNameField = new NameSuggestionsField(new String[] { originalDescriptor.getName() }, project, KotlinFileType.INSTANCE);
aliasNameField.addDataChangedListener(new NameSuggestionsField.DataChanged() {
@Override
public void dataChanged() {
update();
}
});
aliasNamePanel.add(aliasNameField, BorderLayout.CENTER);
aliasNameLabel.setLabelFor(aliasNameField);
boolean enableVisibility = isVisibilitySectionAvailable();
visibilityBox.setEnabled(enableVisibility);
if (enableVisibility) {
KtModifierKeywordToken defaultVisibility = originalDescriptor.getVisibility();
if (defaultVisibility == null) {
defaultVisibility = KtTokens.PUBLIC_KEYWORD;
}
visibilityBox.setSelectedItem(defaultVisibility);
}
visibilityBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(@NotNull ItemEvent e) {
update();
}
});
if (!originalDescriptor.getTypeParameters().isEmpty()) {
parameterTablePanel = new IntroduceTypeAliasParameterTablePanel() {
@Override
protected void updateSignature() {
KotlinIntroduceTypeAliasDialog.this.update();
}
@Override
protected void onEnterAction() {
doOKAction();
}
@Override
protected void onCancelAction() {
doCancelAction();
}
};
parameterTablePanel.init(originalDescriptor.getTypeParameters());
inputParametersPanel.setText("Type &Parameters");
inputParametersPanel.setLabelFor(parameterTablePanel.getTable());
inputParametersPanel.add(parameterTablePanel);
} else {
inputParametersPanel.setVisible(false);
}
}
use of java.awt.event.ItemEvent in project kotlin by JetBrains.
the class MoveKotlinNestedClassesToUpperLevelDialog method init.
@Override
protected void init() {
classNameField.setText(innerClass.getName());
classNameField.selectAll();
if (innerClass instanceof KtClass && ((KtClass) innerClass).isInner()) {
passOuterClassCheckBox.setSelected(true);
passOuterClassCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
parameterField.setEnabled(passOuterClassCheckBox.isSelected());
}
});
} else {
passOuterClassCheckBox.setSelected(false);
passOuterClassCheckBox.setEnabled(false);
parameterField.setEnabled(false);
}
if (passOuterClassCheckBox.isEnabled()) {
boolean thisNeeded = isThisNeeded();
passOuterClassCheckBox.setSelected(thisNeeded);
parameterField.setEnabled(thisNeeded);
}
passOuterClassCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
boolean selected = passOuterClassCheckBox.isSelected();
parameterField.getComponent().setEnabled(selected);
}
});
if (!(targetContainer instanceof PsiDirectory)) {
packageNameField.setVisible(false);
packageNameLabel.setVisible(false);
}
if (innerClass instanceof KtClass && ((KtClass) innerClass).isInner()) {
KtClassBody innerClassBody = innerClass.getBody();
Function1<String, Boolean> validator = innerClassBody != null ? new NewDeclarationNameValidator(innerClassBody, (PsiElement) null, NewDeclarationNameValidator.Target.VARIABLES, Collections.<KtDeclaration>emptyList()) : new CollectingNameValidator();
List<String> suggestions = KotlinNameSuggester.INSTANCE.suggestNamesByType(getOuterInstanceType(), validator, "outer");
parameterField.setSuggestions(ArrayUtil.toStringArray(suggestions));
} else {
parameterField.getComponent().setEnabled(false);
}
FqName packageFqName = getTargetPackageFqName();
if (packageFqName != null) {
packageNameField.prependItem(packageFqName.asString());
}
KotlinRefactoringSettings settings = KotlinRefactoringSettings.getInstance();
searchForTextOccurrencesCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_FOR_TEXT);
searchInCommentsCheckBox.setSelected(settings.MOVE_TO_UPPER_LEVEL_SEARCH_IN_COMMENTS);
super.init();
}
Aggregations