mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2025-12-06 22:10:54 +03:00
Demo: Alt+UP and Alt+DOWN now switch to previous/next theme
This commit is contained in:
@@ -136,6 +136,16 @@ class ControlBar
|
|||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F12, MetalLookAndFeel.class.getName() );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F12, MetalLookAndFeel.class.getName() );
|
||||||
registerSwitchToLookAndFeel( KeyEvent.VK_F11, NimbusLookAndFeel.class.getName() );
|
registerSwitchToLookAndFeel( KeyEvent.VK_F11, NimbusLookAndFeel.class.getName() );
|
||||||
|
|
||||||
|
// register Alt+UP and Alt+DOWN to switch to previous/next theme
|
||||||
|
((JComponent)frame.getContentPane()).registerKeyboardAction(
|
||||||
|
e -> frame.themesPanel.selectPreviousTheme(),
|
||||||
|
KeyStroke.getKeyStroke( KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK ),
|
||||||
|
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
||||||
|
((JComponent)frame.getContentPane()).registerKeyboardAction(
|
||||||
|
e -> frame.themesPanel.selectNextTheme(),
|
||||||
|
KeyStroke.getKeyStroke( KeyEvent.VK_DOWN, KeyEvent.ALT_DOWN_MASK ),
|
||||||
|
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
||||||
|
|
||||||
// register ESC key to close frame
|
// register ESC key to close frame
|
||||||
((JComponent)frame.getContentPane()).registerKeyboardAction(
|
((JComponent)frame.getContentPane()).registerKeyboardAction(
|
||||||
e -> {
|
e -> {
|
||||||
|
|||||||
@@ -749,6 +749,6 @@ class DemoFrame
|
|||||||
private JCheckBoxMenuItem animatedLafChangeMenuItem;
|
private JCheckBoxMenuItem animatedLafChangeMenuItem;
|
||||||
private JTabbedPane tabbedPane;
|
private JTabbedPane tabbedPane;
|
||||||
private ControlBar controlBar;
|
private ControlBar controlBar;
|
||||||
private IJThemesPanel themesPanel;
|
IJThemesPanel themesPanel;
|
||||||
// JFormDesigner - End of variables declaration //GEN-END:variables
|
// JFormDesigner - End of variables declaration //GEN-END:variables
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ new FormModel {
|
|||||||
name: "themesPanel"
|
name: "themesPanel"
|
||||||
auxiliary() {
|
auxiliary() {
|
||||||
"JavaCodeGenerator.variableLocal": false
|
"JavaCodeGenerator.variableLocal": false
|
||||||
|
"JavaCodeGenerator.variableModifiers": 0
|
||||||
}
|
}
|
||||||
}, new FormLayoutConstraints( class java.lang.String ) {
|
}, new FormLayoutConstraints( class java.lang.String ) {
|
||||||
"value": "East"
|
"value": "East"
|
||||||
|
|||||||
@@ -220,6 +220,17 @@ public class IJThemesPanel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void selectPreviousTheme() {
|
||||||
|
int sel = themesList.getSelectedIndex();
|
||||||
|
if( sel > 0 )
|
||||||
|
themesList.setSelectedIndex( sel - 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void selectNextTheme() {
|
||||||
|
int sel = themesList.getSelectedIndex();
|
||||||
|
themesList.setSelectedIndex( sel + 1 );
|
||||||
|
}
|
||||||
|
|
||||||
private void themesListValueChanged( ListSelectionEvent e ) {
|
private void themesListValueChanged( ListSelectionEvent e ) {
|
||||||
IJThemeInfo themeInfo = themesList.getSelectedValue();
|
IJThemeInfo themeInfo = themesList.getSelectedValue();
|
||||||
boolean bundledTheme = (themeInfo != null && themeInfo.resourceName != null);
|
boolean bundledTheme = (themeInfo != null && themeInfo.resourceName != null);
|
||||||
|
|||||||
@@ -198,6 +198,16 @@ public class FlatTestFrame
|
|||||||
KeyStroke.getKeyStroke( KeyEvent.VK_MINUS, menuShortcutKeyMask ),
|
KeyStroke.getKeyStroke( KeyEvent.VK_MINUS, menuShortcutKeyMask ),
|
||||||
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
||||||
|
|
||||||
|
// register Alt+UP and Alt+DOWN to switch to previous/next theme
|
||||||
|
((JComponent)getContentPane()).registerKeyboardAction(
|
||||||
|
e -> themesPanel.selectPreviousTheme(),
|
||||||
|
KeyStroke.getKeyStroke( KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK ),
|
||||||
|
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
||||||
|
((JComponent)getContentPane()).registerKeyboardAction(
|
||||||
|
e -> themesPanel.selectNextTheme(),
|
||||||
|
KeyStroke.getKeyStroke( KeyEvent.VK_DOWN, KeyEvent.ALT_DOWN_MASK ),
|
||||||
|
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
|
||||||
|
|
||||||
// register ESC key to close frame
|
// register ESC key to close frame
|
||||||
((JComponent)getContentPane()).registerKeyboardAction(
|
((JComponent)getContentPane()).registerKeyboardAction(
|
||||||
e -> {
|
e -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user