mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-12 23:07:15 -06:00
Theme Editor: added "About" dialog
Demo: updated "About" dialog
This commit is contained in:
@@ -18,6 +18,10 @@ package com.formdev.flatlaf.demo;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.time.Year;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.prefs.Preferences;
|
import java.util.prefs.Preferences;
|
||||||
@@ -37,6 +41,7 @@ import com.formdev.flatlaf.extras.FlatSVGUtils;
|
|||||||
import com.formdev.flatlaf.ui.FlatUIUtils;
|
import com.formdev.flatlaf.ui.FlatUIUtils;
|
||||||
import com.formdev.flatlaf.ui.JBRCustomDecorations;
|
import com.formdev.flatlaf.ui.JBRCustomDecorations;
|
||||||
import com.formdev.flatlaf.util.SystemInfo;
|
import com.formdev.flatlaf.util.SystemInfo;
|
||||||
|
import com.formdev.flatlaf.util.UIScale;
|
||||||
import net.miginfocom.layout.ConstraintParser;
|
import net.miginfocom.layout.ConstraintParser;
|
||||||
import net.miginfocom.layout.LC;
|
import net.miginfocom.layout.LC;
|
||||||
import net.miginfocom.layout.UnitValue;
|
import net.miginfocom.layout.UnitValue;
|
||||||
@@ -128,7 +133,36 @@ class DemoFrame
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void aboutActionPerformed() {
|
private void aboutActionPerformed() {
|
||||||
JOptionPane.showMessageDialog( this, "FlatLaf Demo", "About", JOptionPane.PLAIN_MESSAGE );
|
JLabel titleLabel = new JLabel( "FlatLaf Demo" );
|
||||||
|
Font titleFont = titleLabel.getFont();
|
||||||
|
titleLabel.setFont( titleFont.deriveFont( (float) titleFont.getSize() + UIScale.scale( 6 ) ) );
|
||||||
|
|
||||||
|
String link = "https://www.formdev.com/flatlaf/";
|
||||||
|
JLabel linkLabel = new JLabel( "<html><a href=\"#\">" + link + "</a></html>" );
|
||||||
|
linkLabel.setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
|
||||||
|
linkLabel.addMouseListener( new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked( MouseEvent e ) {
|
||||||
|
try {
|
||||||
|
Desktop.getDesktop().browse( new URI( link ) );
|
||||||
|
} catch( IOException | URISyntaxException ex ) {
|
||||||
|
JOptionPane.showMessageDialog( linkLabel,
|
||||||
|
"Failed to open '" + link + "' in browser.",
|
||||||
|
"About", JOptionPane.PLAIN_MESSAGE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
JOptionPane.showMessageDialog( this,
|
||||||
|
new Object[] {
|
||||||
|
titleLabel,
|
||||||
|
"Demonstrates FlatLaf Swing look and feel",
|
||||||
|
" ",
|
||||||
|
"Copyright 2019-" + Year.now() + " FormDev Software GmbH",
|
||||||
|
linkLabel,
|
||||||
|
},
|
||||||
|
"About", JOptionPane.PLAIN_MESSAGE );
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectedTabChanged() {
|
private void selectedTabChanged() {
|
||||||
|
|||||||
@@ -19,7 +19,10 @@ package com.formdev.flatlaf.themeeditor;
|
|||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
|
import java.awt.Cursor;
|
||||||
|
import java.awt.Desktop;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.GraphicsConfiguration;
|
import java.awt.GraphicsConfiguration;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
@@ -30,6 +33,9 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.time.Year;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -669,6 +675,39 @@ public class FlatThemeFileEditor
|
|||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void about() {
|
||||||
|
JLabel titleLabel = new JLabel( "FlatLaf Theme Editor" );
|
||||||
|
Font titleFont = titleLabel.getFont();
|
||||||
|
titleLabel.setFont( titleFont.deriveFont( (float) titleFont.getSize() + UIScale.scale( 6 ) ) );
|
||||||
|
|
||||||
|
String link = "https://www.formdev.com/flatlaf/";
|
||||||
|
JLabel linkLabel = new JLabel( "<html><a href=\"#\">" + link + "</a></html>" );
|
||||||
|
linkLabel.setCursor( Cursor.getPredefinedCursor( Cursor.HAND_CURSOR ) );
|
||||||
|
linkLabel.addMouseListener( new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked( MouseEvent e ) {
|
||||||
|
try {
|
||||||
|
Desktop.getDesktop().browse( new URI( link ) );
|
||||||
|
} catch( IOException | URISyntaxException ex ) {
|
||||||
|
JOptionPane.showMessageDialog( linkLabel,
|
||||||
|
"Failed to open '" + link + "' in browser.",
|
||||||
|
"About", JOptionPane.PLAIN_MESSAGE );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
JOptionPane.showMessageDialog( this,
|
||||||
|
new Object[] {
|
||||||
|
titleLabel,
|
||||||
|
"Edits FlatLaf Swing look and feel theme files",
|
||||||
|
" ",
|
||||||
|
"Copyright 2019-" + Year.now() + " FormDev Software GmbH",
|
||||||
|
linkLabel,
|
||||||
|
},
|
||||||
|
"About", JOptionPane.PLAIN_MESSAGE );
|
||||||
|
}
|
||||||
|
|
||||||
private void restoreState() {
|
private void restoreState() {
|
||||||
state = Preferences.userRoot().node( PREFS_ROOT_PATH );
|
state = Preferences.userRoot().node( PREFS_ROOT_PATH );
|
||||||
|
|
||||||
@@ -804,6 +843,8 @@ public class FlatThemeFileEditor
|
|||||||
activateEditorMenuItem = new JMenuItem();
|
activateEditorMenuItem = new JMenuItem();
|
||||||
nextEditorMenuItem = new JMenuItem();
|
nextEditorMenuItem = new JMenuItem();
|
||||||
previousEditorMenuItem = new JMenuItem();
|
previousEditorMenuItem = new JMenuItem();
|
||||||
|
helpMenu = new JMenu();
|
||||||
|
aboutMenuItem = new JMenuItem();
|
||||||
controlPanel = new JPanel();
|
controlPanel = new JPanel();
|
||||||
directoryLabel = new JLabel();
|
directoryLabel = new JLabel();
|
||||||
directoryField = new JComboBox<>();
|
directoryField = new JComboBox<>();
|
||||||
@@ -975,6 +1016,19 @@ public class FlatThemeFileEditor
|
|||||||
windowMenu.add(previousEditorMenuItem);
|
windowMenu.add(previousEditorMenuItem);
|
||||||
}
|
}
|
||||||
menuBar.add(windowMenu);
|
menuBar.add(windowMenu);
|
||||||
|
|
||||||
|
//======== helpMenu ========
|
||||||
|
{
|
||||||
|
helpMenu.setText("Help");
|
||||||
|
helpMenu.setMnemonic('H');
|
||||||
|
|
||||||
|
//---- aboutMenuItem ----
|
||||||
|
aboutMenuItem.setText("About");
|
||||||
|
aboutMenuItem.setMnemonic('A');
|
||||||
|
aboutMenuItem.addActionListener(e -> about());
|
||||||
|
helpMenu.add(aboutMenuItem);
|
||||||
|
}
|
||||||
|
menuBar.add(helpMenu);
|
||||||
}
|
}
|
||||||
setJMenuBar(menuBar);
|
setJMenuBar(menuBar);
|
||||||
|
|
||||||
@@ -1044,6 +1098,8 @@ public class FlatThemeFileEditor
|
|||||||
private JMenuItem activateEditorMenuItem;
|
private JMenuItem activateEditorMenuItem;
|
||||||
private JMenuItem nextEditorMenuItem;
|
private JMenuItem nextEditorMenuItem;
|
||||||
private JMenuItem previousEditorMenuItem;
|
private JMenuItem previousEditorMenuItem;
|
||||||
|
private JMenu helpMenu;
|
||||||
|
private JMenuItem aboutMenuItem;
|
||||||
private JPanel controlPanel;
|
private JPanel controlPanel;
|
||||||
private JLabel directoryLabel;
|
private JLabel directoryLabel;
|
||||||
private JComboBox<String> directoryField;
|
private JComboBox<String> directoryField;
|
||||||
|
|||||||
@@ -202,6 +202,17 @@ new FormModel {
|
|||||||
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "previousEditor", false ) )
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "previousEditor", false ) )
|
||||||
} )
|
} )
|
||||||
} )
|
} )
|
||||||
|
add( new FormContainer( "javax.swing.JMenu", new FormLayoutManager( class javax.swing.JMenu ) ) {
|
||||||
|
name: "helpMenu"
|
||||||
|
"text": "Help"
|
||||||
|
"mnemonic": 72
|
||||||
|
add( new FormComponent( "javax.swing.JMenuItem" ) {
|
||||||
|
name: "aboutMenuItem"
|
||||||
|
"text": "About"
|
||||||
|
"mnemonic": 65
|
||||||
|
addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "about", false ) )
|
||||||
|
} )
|
||||||
|
} )
|
||||||
}
|
}
|
||||||
}, new FormLayoutConstraints( null ) {
|
}, new FormLayoutConstraints( null ) {
|
||||||
"location": new java.awt.Point( 0, 0 )
|
"location": new java.awt.Point( 0, 0 )
|
||||||
|
|||||||
Reference in New Issue
Block a user