Demo: moved SVG icons to JFormDesigner forms

This commit is contained in:
Karl Tauber
2023-08-04 12:08:04 +02:00
parent f03725ae36
commit 35fa3197c8
8 changed files with 47 additions and 29 deletions

View File

@@ -70,13 +70,6 @@ class FlatFindReplaceBar
actionMap.put( "editorPageUp", new ConsumerAction( e -> notifyEditorAction( "page-up" ) ) );
actionMap.put( "editorPageDown", new ConsumerAction( e -> notifyEditorAction( "page-down" ) ) );
findPreviousButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/findAndShowPrevMatches.svg" ) );
findNextButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/findAndShowNextMatches.svg" ) );
matchCaseToggleButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/matchCase.svg" ) );
matchWholeWordToggleButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/words.svg" ) );
regexToggleButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/regex.svg" ) );
closeButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/close.svg" ) );
registerKeyboardAction( e -> close(),
KeyStroke.getKeyStroke( KeyEvent.VK_ESCAPE, 0, false ),
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
@@ -335,27 +328,32 @@ class FlatFindReplaceBar
//---- findPreviousButton ----
findPreviousButton.setToolTipText("Previous Occurrence");
findPreviousButton.setIcon(new FlatSVGIcon("com/formdev/flatlaf/themeeditor/icons/findAndShowPrevMatches.svg"));
findPreviousButton.addActionListener(e -> findPrevious());
findToolBar.add(findPreviousButton);
//---- findNextButton ----
findNextButton.setToolTipText("Next Occurrence");
findNextButton.setIcon(new FlatSVGIcon("com/formdev/flatlaf/themeeditor/icons/findAndShowNextMatches.svg"));
findNextButton.addActionListener(e -> findNext());
findToolBar.add(findNextButton);
findToolBar.addSeparator();
//---- matchCaseToggleButton ----
matchCaseToggleButton.setToolTipText("Match Case");
matchCaseToggleButton.setIcon(new FlatSVGIcon("com/formdev/flatlaf/themeeditor/icons/matchCase.svg"));
matchCaseToggleButton.addActionListener(e -> matchCaseChanged());
findToolBar.add(matchCaseToggleButton);
//---- matchWholeWordToggleButton ----
matchWholeWordToggleButton.setToolTipText("Match Whole Word");
matchWholeWordToggleButton.setIcon(new FlatSVGIcon("com/formdev/flatlaf/themeeditor/icons/words.svg"));
matchWholeWordToggleButton.addActionListener(e -> matchWholeWordChanged());
findToolBar.add(matchWholeWordToggleButton);
//---- regexToggleButton ----
regexToggleButton.setToolTipText("Regex");
regexToggleButton.setIcon(new FlatSVGIcon("com/formdev/flatlaf/themeeditor/icons/regex.svg"));
regexToggleButton.addActionListener(e -> regexChanged());
findToolBar.add(regexToggleButton);
}

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.4.0.360" Java: "16" encoding: "UTF-8"
JFDML JFormDesigner: "8.1.0.0.283" Java: "19.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -34,11 +34,13 @@ new FormModel {
add( new FormComponent( "javax.swing.JButton" ) {
name: "findPreviousButton"
"toolTipText": "Previous Occurrence"
"icon": new com.jformdesigner.model.SwingIcon( 0, "/com/formdev/flatlaf/themeeditor/icons/findAndShowPrevMatches.svg" )
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "findPrevious", false ) )
} )
add( new FormComponent( "javax.swing.JButton" ) {
name: "findNextButton"
"toolTipText": "Next Occurrence"
"icon": new com.jformdesigner.model.SwingIcon( 0, "/com/formdev/flatlaf/themeeditor/icons/findAndShowNextMatches.svg" )
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "findNext", false ) )
} )
add( new FormComponent( "javax.swing.JToolBar$Separator" ) {
@@ -47,16 +49,19 @@ new FormModel {
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "matchCaseToggleButton"
"toolTipText": "Match Case"
"icon": new com.jformdesigner.model.SwingIcon( 0, "/com/formdev/flatlaf/themeeditor/icons/matchCase.svg" )
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "matchCaseChanged", false ) )
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "matchWholeWordToggleButton"
"toolTipText": "Match Whole Word"
"icon": new com.jformdesigner.model.SwingIcon( 0, "/com/formdev/flatlaf/themeeditor/icons/words.svg" )
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "matchWholeWordChanged", false ) )
} )
add( new FormComponent( "javax.swing.JToggleButton" ) {
name: "regexToggleButton"
"toolTipText": "Regex"
"icon": new com.jformdesigner.model.SwingIcon( 0, "/com/formdev/flatlaf/themeeditor/icons/regex.svg" )
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "regexChanged", false ) )
} )
}, new FormLayoutConstraints( class net.miginfocom.layout.CC ) {

View File

@@ -140,7 +140,6 @@ class FlatThemeFileEditor
directoryField.setRenderer( new DirectoryRenderer( directoryField ) );
openDirectoryButton.setIcon( new FlatSVGIcon( "com/formdev/flatlaf/themeeditor/icons/menu-open.svg" ) );
if( UIManager.getLookAndFeel() instanceof FlatDarkLaf )
darkLafMenuItem.setSelected( true );
@@ -1045,6 +1044,7 @@ class FlatThemeFileEditor
openDirectoryMenuItem.setText("Open Directory...");
openDirectoryMenuItem.setMnemonic('O');
openDirectoryMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
openDirectoryMenuItem.setIcon(new FlatSVGIcon("com/formdev/flatlaf/themeeditor/icons/menu-open.svg"));
openDirectoryMenuItem.addActionListener(e -> openDirectory());
fileMenu.add(openDirectoryMenuItem);

View File

@@ -1,4 +1,4 @@
JFDML JFormDesigner: "7.0.5.0.382" Java: "16" encoding: "UTF-8"
JFDML JFormDesigner: "8.1.0.0.283" Java: "19.0.2" encoding: "UTF-8"
new FormModel {
contentType: "form/swing"
@@ -65,6 +65,7 @@ new FormModel {
"text": "Open Directory..."
"mnemonic": 79
"accelerator": static javax.swing.KeyStroke getKeyStroke( 79, 4226, false )
"icon": new com.jformdesigner.model.SwingIcon( 0, "/com/formdev/flatlaf/themeeditor/icons/menu-open.svg" )
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "openDirectory", false ) )
} )
add( new FormComponent( "javax.swing.JMenuItem" ) {