diff --git a/demo/swingDemo/src/main/java/MaterialDemoSwingFrame.java b/demo/swingDemo/src/main/java/MaterialDemoSwingFrame.java deleted file mode 100644 index e69de29..0000000 diff --git a/demos/swingDemo/.gitignore b/demos/swingDemo/.gitignore new file mode 100644 index 0000000..be3147e --- /dev/null +++ b/demos/swingDemo/.gitignore @@ -0,0 +1,8 @@ +#File ide +.idea +*.iml + +#Sistem costruction files +out +build +.gradle \ No newline at end of file diff --git a/demos/swingDemo/build.gradle b/demos/swingDemo/build.gradle new file mode 100644 index 0000000..79dcab7 --- /dev/null +++ b/demos/swingDemo/build.gradle @@ -0,0 +1,45 @@ +/* + * This build file was generated by the Gradle 'init' task. + * + * This generated file contains a sample Java project to get you started. + * For more details take a look at the Java Quickstart chapter in the Gradle + * user guide available at https://docs.gradle.org/3.4.1/userguide/tutorial_java_projects.html + */ + +// Apply the java plugin to add support for Java +apply plugin: 'java' + +// Apply the application plugin to add support for building an application +apply plugin: 'application' + +// In this section you declare where to find the dependencies of your project +repositories { + // Use jcenter for resolving your dependencies. + // You can declare any Maven/Ivy/file repository here. + jcenter() + flatDir { + dirs '/home/vincenzo/Github/material-ui-swing/target/' + } +} + +dependencies { + // This dependency is found on compile classpath of this component and consumers. + compile 'com.google.guava:guava:20.0' + compile (name:'material-ui-swing-0.9.8-jar-with-dependencies', ext:'jar') + + // Use JUnit test framework + testCompile 'junit:junit:4.12' + testCompile (name:'material-ui-swing-0.9.8-jar-with-dependencies', ext:'jar') + //Material Look and feel + //implementation 'com.github.vincenzopalazzo:material-ui-swing:V0.9.8' +} + +allprojects { + repositories { + maven { url 'https://jitpack.io' } + } +} + +// Define the main class for the application +mainClassName = 'App' + diff --git a/demos/swingDemo/gradle/wrapper/gradle-wrapper.jar b/demos/swingDemo/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..ab010d5 Binary files /dev/null and b/demos/swingDemo/gradle/wrapper/gradle-wrapper.jar differ diff --git a/demos/swingDemo/gradle/wrapper/gradle-wrapper.properties b/demos/swingDemo/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d51661a --- /dev/null +++ b/demos/swingDemo/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sat Mar 23 23:46:56 CET 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip diff --git a/demos/swingDemo/gradlew b/demos/swingDemo/gradlew new file mode 100755 index 0000000..4453cce --- /dev/null +++ b/demos/swingDemo/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save ( ) { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/demos/swingDemo/gradlew.bat b/demos/swingDemo/gradlew.bat new file mode 100644 index 0000000..e95643d --- /dev/null +++ b/demos/swingDemo/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/demos/swingDemo/settings.gradle b/demos/swingDemo/settings.gradle new file mode 100644 index 0000000..6184c09 --- /dev/null +++ b/demos/swingDemo/settings.gradle @@ -0,0 +1,18 @@ +/* + * This settings file was generated by the Gradle 'init' task. + * + * The settings file is used to specify which projects to include in your build. + * In a single project build this file can be empty or even removed. + * + * Detailed information about configuring a multi-project build in Gradle can be found + * in the user guide at https://docs.gradle.org/3.4.1/userguide/multi_project_builds.html + */ + +/* +// To declare projects as part of a multi-project build use the 'include' method +include 'shared' +include 'api' +include 'services:webservice' +*/ + +rootProject.name = 'swingDemo' diff --git a/demos/swingDemo/src/main/java/mdlaf/demo/MaterialDemoSwingApp.java b/demos/swingDemo/src/main/java/mdlaf/demo/MaterialDemoSwingApp.java new file mode 100644 index 0000000..61e23cc --- /dev/null +++ b/demos/swingDemo/src/main/java/mdlaf/demo/MaterialDemoSwingApp.java @@ -0,0 +1,58 @@ +package mdlaf.demo; + +import mdlaf.MaterialLookAndFeel; +import mdlaf.demo.actions.ActionsMenuBar; +import mdlaf.demo.views.MaterialDemoSwingDialogInfo; +import mdlaf.demo.views.MaterialDemoSwingFrame; + +import javax.swing.*; + +/** + * @author https://github.com/vincenzopalazzo + */ +public class MaterialDemoSwingApp { + + private static final MaterialDemoSwingApp SINGLETON = new MaterialDemoSwingApp(); + + public static MaterialDemoSwingApp getIstance(){ + return SINGLETON; + } + + private MaterialDemoSwingApp(){} + + static { + try { + UIManager.setLookAndFeel(new MaterialLookAndFeel()); + } catch (UnsupportedLookAndFeelException e) { + e.printStackTrace(); + } + } + + //Init view component application + private MaterialDemoSwingFrame frame = new MaterialDemoSwingFrame(); + private MaterialDemoSwingDialogInfo dialogInfo = new MaterialDemoSwingDialogInfo(frame, "Info project", true); + + //Init actions component + private ActionsMenuBar actionsMenuBar = new ActionsMenuBar(); + + public MaterialDemoSwingDialogInfo getDialogInfo() { + return dialogInfo; + } + + public MaterialDemoSwingFrame getFrame() { + return frame; + } + + public ActionsMenuBar getActionsMenuBar() { + return actionsMenuBar; + } + + public static void main(String[] args){ + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + SINGLETON.frame.init(); + } + }); + } +} diff --git a/demos/swingDemo/src/main/java/mdlaf/demo/actions/ActionsMenuBar.java b/demos/swingDemo/src/main/java/mdlaf/demo/actions/ActionsMenuBar.java new file mode 100644 index 0000000..4f24043 --- /dev/null +++ b/demos/swingDemo/src/main/java/mdlaf/demo/actions/ActionsMenuBar.java @@ -0,0 +1,61 @@ +package mdlaf.demo.actions; + +import mdlaf.demo.MaterialDemoSwingApp; +import mdlaf.demo.views.MaterialDemoSwingDialogInfo; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.KeyEvent; + +/** + * @author https://github.com/vincenzopalazzo + */ +public class ActionsMenuBar { + + private Action actionExit = new ActionExit(); + private Action actionShowInfo = new ActionShowInfo(); + + public Action getActionExit() { + return actionExit; + } + + public Action getActionShowInfo() { + return actionShowInfo; + } + + /** + * This action close applications + * @author https://github.com/vincenzopalazzo + */ + private class ActionExit extends AbstractAction{ + + public ActionExit() { + putValue(Action.NAME, "Exit"); + putValue(Action.SHORT_DESCRIPTION, "Whit this button exit of the application"); + } + + @Override + public void actionPerformed(ActionEvent e) { + System.exit(0); + } + } + + /** + * This actions show project informations + * @author https://github.com/vincenzopalazzo + */ + private class ActionShowInfo extends AbstractAction{ + + public ActionShowInfo() { + putValue(Action.NAME, "Info"); + putValue(Action.SHORT_DESCRIPTION, "Whit this button show info of the project"); + putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("ctrl I")); + putValue(Action.MNEMONIC_KEY, KeyEvent.VK_I); + } + + @Override + public void actionPerformed(ActionEvent e) { + MaterialDemoSwingApp.getIstance().getDialogInfo().init(); + } + } +} diff --git a/demos/swingDemo/src/main/java/mdlaf/demo/views/MaterialDemoSwingDialogInfo.java b/demos/swingDemo/src/main/java/mdlaf/demo/views/MaterialDemoSwingDialogInfo.java new file mode 100644 index 0000000..2bef0e3 --- /dev/null +++ b/demos/swingDemo/src/main/java/mdlaf/demo/views/MaterialDemoSwingDialogInfo.java @@ -0,0 +1,27 @@ +package mdlaf.demo.views; + +import javax.swing.*; +import java.awt.*; + +/** + * @author https://github.com/vincenzopalazzo + */ +public class MaterialDemoSwingDialogInfo extends JDialog { + + public MaterialDemoSwingDialogInfo(Frame owner, String title, boolean modal) { + super(owner, title, modal); + } + + public void init(){ + initComponent(); + + setLocationRelativeTo(this.getOwner()); + pack(); + setVisible(true); + } + + public void initComponent(){ + JTabbedPane tabbedPane = new JTabbedPane(); + this.add(tabbedPane); + } +} diff --git a/demos/swingDemo/src/main/java/mdlaf/demo/views/MaterialDemoSwingFrame.java b/demos/swingDemo/src/main/java/mdlaf/demo/views/MaterialDemoSwingFrame.java new file mode 100644 index 0000000..8297547 --- /dev/null +++ b/demos/swingDemo/src/main/java/mdlaf/demo/views/MaterialDemoSwingFrame.java @@ -0,0 +1,46 @@ +package mdlaf.demo.views; + +import mdlaf.animation.MaterialUIMovement; +import mdlaf.demo.MaterialDemoSwingApp; + +import javax.swing.*; + +/** + * @author https://github.com/vincenzopalazzo + */ +public class MaterialDemoSwingFrame extends JFrame { + + private JMenuItem jMenuItemExit; + private JMenuItem jMenuItemInfo; + + public void init(){ + initComponent(); + initActionsFrame(); + setLocationRelativeTo(null); + pack(); + setVisible(true); + } + + private void initComponent(){ + JMenuBar menuBar = new JMenuBar(); + this.add(menuBar); + + JMenu jMenuFile = new JMenu("File"); + JMenu jMenuInfo= new JMenu("INFO"); + jMenuItemExit = new JMenuItem(); + jMenuItemInfo = new JMenuItem(); + + jMenuFile.add(jMenuItemExit); + jMenuInfo.add(jMenuItemInfo); + + menuBar.add(jMenuFile); + menuBar.add(jMenuInfo); + } + + private void initActionsFrame(){ + jMenuItemExit.setAction(MaterialDemoSwingApp.getIstance().getActionsMenuBar().getActionExit()); + jMenuItemInfo.setAction(MaterialDemoSwingApp.getIstance().getActionsMenuBar().getActionShowInfo()); + } + + +} diff --git a/src/MaterialUISwingDemo.java b/src/MaterialUISwingDemo.java index 5610cb7..526bed8 100644 --- a/src/MaterialUISwingDemo.java +++ b/src/MaterialUISwingDemo.java @@ -8,17 +8,9 @@ import javax.swing.*; import javax.swing.border.TitledBorder; -import javax.swing.event.TableModelListener; -import javax.swing.event.TreeModelListener; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableModel; import javax.swing.tree.DefaultMutableTreeNode; -import javax.swing.tree.TreeModel; -import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; import java.util.ArrayList; public class MaterialUISwingDemo { @@ -30,7 +22,7 @@ public MaterialUISwingDemo() { } public static void main(String[] args) { - try { + try { UIManager.setLookAndFeel(new MaterialLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); @@ -298,7 +290,7 @@ public void actionPerformed(ActionEvent e) { class InfoMessage extends AbstractAction{ public InfoMessage() { - putValue(Action.NAME, "Info option pane"); + putValue(Action.NAME, "Info option panel"); } @Override @@ -319,7 +311,7 @@ public void actionPerformed(ActionEvent e) { class ErrorMassage extends AbstractAction{ public ErrorMassage() { - putValue(Action.NAME, "Error option pane"); + putValue(Action.NAME, "Error option panel"); } @Override @@ -339,7 +331,7 @@ public void actionPerformed(ActionEvent e) { class QuesuionMessage extends AbstractAction{ public QuesuionMessage() { - putValue(Action.NAME, "Info question pane"); + putValue(Action.NAME, "Info question panel"); } @Override @@ -358,7 +350,7 @@ public void actionPerformed(ActionEvent e) { class WarningMessage extends AbstractAction { public WarningMessage() { - putValue(Action.NAME, "Info warning pane"); + putValue(Action.NAME, "Info warning panel"); } @Override diff --git a/src/mdlaf/utils/MaterialBorders.java b/src/mdlaf/utils/MaterialBorders.java index 4f56dfd..f72e2ff 100644 --- a/src/mdlaf/utils/MaterialBorders.java +++ b/src/mdlaf/utils/MaterialBorders.java @@ -9,7 +9,6 @@ public class MaterialBorders { public static final Border LIGHT_LINE_BORDER = BorderFactory.createLineBorder (MaterialColors.GRAY_200, 1); - public static final Border LIGHT_SHADOW_BORDER = new DropShadowBorder (Color.BLACK, 0, 4, 0.3f, 12, true, true, true, true); public static final Border DEFAULT_SHADOW_BORDER = new DropShadowBorder (Color.BLACK, 5, 5, 0.3f, 12, true, true, true, true);