diff --git a/samples/applicationConfigurable/src/fontConfigurable/IDEDialog.form b/samples/applicationConfigurable/src/fontConfigurable/IDEDialog.form deleted file mode 100644 index 5c0fe57bbe02..000000000000 --- a/samples/applicationConfigurable/src/fontConfigurable/IDEDialog.form +++ /dev/null @@ -1,88 +0,0 @@ - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/samples/applicationConfigurable/src/fontConfigurable/IDEDialog.java b/samples/applicationConfigurable/src/fontConfigurable/IDEDialog.java deleted file mode 100644 index 124521759f54..000000000000 --- a/samples/applicationConfigurable/src/fontConfigurable/IDEDialog.java +++ /dev/null @@ -1,66 +0,0 @@ -package fontConfigurable; - -import com.intellij.ide.ui.UISettings; -import com.intellij.util.ui.UIUtil; - -import javax.swing.*; -import java.awt.event.*; - -public class IDEDialog extends JDialog { - private JPanel contentPane; - public JPanel name; - public JComboBox myFontCombo; - public JComboBox myFontSize; - public JLabel menuFontSettingsLabel; - public JButton buttonRestoreDefaultFont; - - - public IDEDialog() { - setContentPane(contentPane); - setModal(true); - UISettings settings = UISettings.getInstance(); - myFontCombo.setModel(new DefaultComboBoxModel(UIUtil.getValidFontNames(false))); - myFontSize.setModel(new DefaultComboBoxModel(UIUtil.getStandardFontSizes())); - myFontCombo.setSelectedItem(settings.FONT_FACE); - myFontSize.setSelectedItem(String.valueOf(settings.FONT_SIZE)); - -// Configure the Set Default Font myButton listener. - - MyButtonListener actionListener = new MyButtonListener(); - actionListener.myButton = buttonRestoreDefaultFont; - actionListener.myFontCombo = myFontCombo; - actionListener.myFontSize = myFontSize; - buttonRestoreDefaultFont.addActionListener(actionListener); - - -// call onCancel() when cross is clicked - setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); - addWindowListener(new WindowAdapter() { - public void windowClosing(WindowEvent e) { - onCancel(); - } - }); - -// call onCancel() on ESCAPE - contentPane.registerKeyboardAction(new ActionListener() { - public void actionPerformed(ActionEvent e) { - onCancel(); - } - }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - } - - private void onOK() { -// add your code here - - - dispose(); - } - - - private void onCancel() { -// add your code here if necessary - dispose(); - } - - -} diff --git a/samples/applicationConfigurable/src/fontConfigurable/MyButtonListener.java b/samples/applicationConfigurable/src/fontConfigurable/MyButtonListener.java index d37220aa01e4..87e4a624edb0 100644 --- a/samples/applicationConfigurable/src/fontConfigurable/MyButtonListener.java +++ b/samples/applicationConfigurable/src/fontConfigurable/MyButtonListener.java @@ -16,8 +16,7 @@ import java.awt.event.ActionListener; public class MyButtonListener implements ActionListener { - public JButton myButton; - public JComboBox myFontCombo; + public JComboBox myFontName; public JComboBox myFontSize; @@ -28,7 +27,7 @@ public class MyButtonListener implements ActionListener { // Restore default font settings.FONT_FACE = "Segoe UI"; settings.FONT_SIZE = 12; - myFontCombo.setSelectedItem(settings.FONT_FACE); + myFontName.setSelectedItem(settings.FONT_FACE); myFontSize.setSelectedItem(String.valueOf(settings.FONT_SIZE)); settings.fireUISettingsChanged(); lafManager.updateUI(); diff --git a/samples/applicationConfigurable/src/fontConfigurable/MyExtensConfigurable.java b/samples/applicationConfigurable/src/fontConfigurable/MyExtensConfigurable.java index f53725e2be76..2d9b48277924 100644 --- a/samples/applicationConfigurable/src/fontConfigurable/MyExtensConfigurable.java +++ b/samples/applicationConfigurable/src/fontConfigurable/MyExtensConfigurable.java @@ -4,6 +4,7 @@ package fontConfigurable; import com.intellij.ide.ui.LafManager; import com.intellij.ide.ui.UISettings; import com.intellij.openapi.options.Configurable; +import com.intellij.util.ui.UIUtil; import javax.swing.*; @@ -16,7 +17,10 @@ import javax.swing.*; */ public class MyExtensConfigurable implements Configurable { private JComponent myComponent; - private IDEDialog myDialog; + private JComboBox myFontName; + private JComboBox myFontSize; + private JButton MyDefaultFontButton; + private JPanel myPanel; public String getDisplayName() { return "Menu Font"; @@ -29,8 +33,20 @@ public class MyExtensConfigurable implements Configurable { } public JComponent createComponent() { - myDialog = new IDEDialog(); - myComponent = (JComponent) myDialog.getComponent(0); + // Add listener to the Default Font button + MyButtonListener actionListener = new MyButtonListener(); + actionListener.myFontName = myFontName; + actionListener.myFontSize = myFontSize; + MyDefaultFontButton.addActionListener(actionListener); + // Define a set of possible values for combo boxes. + UISettings settings = UISettings.getInstance(); + myFontName.setModel(new DefaultComboBoxModel(UIUtil.getValidFontNames(false))); + myFontSize.setModel(new DefaultComboBoxModel(UIUtil.getStandardFontSizes())); + myFontName.setSelectedItem(settings.FONT_FACE); + myFontSize.setSelectedItem(String.valueOf(settings.FONT_SIZE)); + + + myComponent = (JComponent) myPanel; return myComponent; } @@ -43,8 +59,8 @@ public class MyExtensConfigurable implements Configurable { public void apply() { UISettings settings = UISettings.getInstance(); LafManager lafManager = LafManager.getInstance(); - String _fontFace = (String) myDialog.myFontCombo.getSelectedItem(); - String _fontSize_STR = (String) myDialog.myFontSize.getSelectedItem(); + String _fontFace = (String) myFontName.getSelectedItem(); + String _fontSize_STR = (String) myFontSize.getSelectedItem(); int _fontSize = Integer.parseInt(_fontSize_STR); if (_fontSize != settings.FONT_SIZE || !settings.FONT_FACE.equals(_fontFace)) { @@ -68,4 +84,5 @@ public class MyExtensConfigurable implements Configurable { } + } diff --git a/samples/applicationConfigurable/src/fontConfigurable/MyUIForm.form b/samples/applicationConfigurable/src/fontConfigurable/MyUIForm.form new file mode 100644 index 000000000000..12f0f51e12b6 --- /dev/null +++ b/samples/applicationConfigurable/src/fontConfigurable/MyUIForm.form @@ -0,0 +1,65 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +