├── sample-form ├── .gitignore ├── manifest.mf ├── library │ ├── jna-5.5.0.jar │ ├── miglayout-core.jar │ ├── miglayout-swing.jar │ ├── picture-box-1.2.jar │ ├── flatlaf │ │ ├── jsvg-1.4.0.jar │ │ ├── flatlaf-3.4.1.jar │ │ ├── flatlaf-extras-3.4.1.jar │ │ └── flatlaf-fonts-roboto-2.137.jar │ ├── swing-jnafilechooser.jar │ ├── thumbnailator-0.4.20.jar │ ├── jdbc │ │ ├── commons-dbcp2-2.12.0.jar │ │ ├── commons-logging-1.3.0.jar │ │ ├── commons-pool2-2.12.0.jar │ │ └── mysql-connector-j-8.3.0.jar │ ├── swing-datetime-picker-1.2.0.jar │ ├── swing-glasspane-popup-1.5.0.jar │ └── swing-toast-notifications-1.0.2.jar ├── src │ └── sample │ │ ├── themes │ │ └── FlatLaf.properties │ │ ├── icon │ │ ├── search.svg │ │ └── profile.svg │ │ ├── swing │ │ └── ButtonAction.java │ │ ├── model │ │ ├── other │ │ │ └── ModelProfile.java │ │ ├── ModelPositions.java │ │ └── ModelEmployee.java │ │ ├── table │ │ ├── ProfileTableRenderer.java │ │ ├── TableHeaderAlignment.java │ │ ├── TableCellProfile.form │ │ ├── CheckBoxTableHeaderRenderer.java │ │ └── TableCellProfile.java │ │ ├── service │ │ ├── ServicePositions.java │ │ └── ServiceEmployee.java │ │ ├── connection │ │ └── DatabaseConnection.java │ │ ├── utils │ │ └── SuperEllipse2D.java │ │ └── form │ │ ├── Main.form │ │ ├── Create.form │ │ ├── Create.java │ │ └── Main.java ├── nbproject │ ├── genfiles.properties │ ├── project.xml │ └── project.properties └── build.xml ├── sample-form-use-modal-dialog ├── .gitignore ├── manifest.mf ├── library │ ├── jna-5.5.0.jar │ ├── miglayout-core.jar │ ├── miglayout-swing.jar │ ├── picture-box-1.2.jar │ ├── flatlaf │ │ ├── jsvg-1.5.0.jar │ │ ├── flatlaf-3.5.2.jar │ │ ├── flatlaf-extras-3.5.2.jar │ │ └── flatlaf-fonts-roboto-2.137.jar │ ├── modal-dialog-2.1.0.jar │ ├── swing-jnafilechooser.jar │ ├── thumbnailator-0.4.20.jar │ ├── jdbc │ │ ├── commons-dbcp2-2.12.0.jar │ │ ├── commons-pool2-2.12.0.jar │ │ ├── commons-logging-1.3.0.jar │ │ └── mysql-connector-j-8.3.0.jar │ └── swing-datetime-picker-1.3.0.jar ├── src │ └── sample │ │ ├── themes │ │ └── FlatLaf.properties │ │ ├── icon │ │ ├── search.svg │ │ └── profile.svg │ │ ├── swing │ │ └── ButtonAction.java │ │ ├── table │ │ ├── ProfileTableRenderer.java │ │ ├── TableHeaderAlignment.java │ │ ├── TableCellProfile.form │ │ ├── TableCellProfile.java │ │ └── CheckBoxTableHeaderRenderer.java │ │ ├── model │ │ ├── ModelPositions.java │ │ ├── other │ │ │ └── ModelProfile.java │ │ └── ModelEmployee.java │ │ ├── service │ │ ├── ServicePositions.java │ │ └── ServiceEmployee.java │ │ ├── connection │ │ └── DatabaseConnection.java │ │ └── form │ │ ├── Main.form │ │ ├── Create.form │ │ ├── Create.java │ │ └── Main.java ├── nbproject │ ├── genfiles.properties │ ├── project.xml │ └── project.properties └── build.xml └── README.md /sample-form/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /nbproject/private/ 3 | /dist/ 4 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /nbproject/private/ 3 | /dist/ 4 | -------------------------------------------------------------------------------- /sample-form/manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /sample-form/library/jna-5.5.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/jna-5.5.0.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /sample-form/library/miglayout-core.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/miglayout-core.jar -------------------------------------------------------------------------------- /sample-form/library/miglayout-swing.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/miglayout-swing.jar -------------------------------------------------------------------------------- /sample-form/library/picture-box-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/picture-box-1.2.jar -------------------------------------------------------------------------------- /sample-form/library/flatlaf/jsvg-1.4.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/flatlaf/jsvg-1.4.0.jar -------------------------------------------------------------------------------- /sample-form/library/flatlaf/flatlaf-3.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/flatlaf/flatlaf-3.4.1.jar -------------------------------------------------------------------------------- /sample-form/library/swing-jnafilechooser.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/swing-jnafilechooser.jar -------------------------------------------------------------------------------- /sample-form/library/thumbnailator-0.4.20.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/thumbnailator-0.4.20.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/jna-5.5.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/jna-5.5.0.jar -------------------------------------------------------------------------------- /sample-form/library/jdbc/commons-dbcp2-2.12.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/jdbc/commons-dbcp2-2.12.0.jar -------------------------------------------------------------------------------- /sample-form/library/jdbc/commons-logging-1.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/jdbc/commons-logging-1.3.0.jar -------------------------------------------------------------------------------- /sample-form/library/jdbc/commons-pool2-2.12.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/jdbc/commons-pool2-2.12.0.jar -------------------------------------------------------------------------------- /sample-form/library/swing-datetime-picker-1.2.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/swing-datetime-picker-1.2.0.jar -------------------------------------------------------------------------------- /sample-form/library/swing-glasspane-popup-1.5.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/swing-glasspane-popup-1.5.0.jar -------------------------------------------------------------------------------- /sample-form/library/flatlaf/flatlaf-extras-3.4.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/flatlaf/flatlaf-extras-3.4.1.jar -------------------------------------------------------------------------------- /sample-form/library/jdbc/mysql-connector-j-8.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/jdbc/mysql-connector-j-8.3.0.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/miglayout-core.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/miglayout-core.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/miglayout-swing.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/miglayout-swing.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/picture-box-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/picture-box-1.2.jar -------------------------------------------------------------------------------- /sample-form/library/swing-toast-notifications-1.0.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/swing-toast-notifications-1.0.2.jar -------------------------------------------------------------------------------- /sample-form/library/flatlaf/flatlaf-fonts-roboto-2.137.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form/library/flatlaf/flatlaf-fonts-roboto-2.137.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/flatlaf/jsvg-1.5.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/flatlaf/jsvg-1.5.0.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/modal-dialog-2.1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/modal-dialog-2.1.0.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/swing-jnafilechooser.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/swing-jnafilechooser.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/thumbnailator-0.4.20.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/thumbnailator-0.4.20.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/flatlaf/flatlaf-3.5.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/flatlaf/flatlaf-3.5.2.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/jdbc/commons-dbcp2-2.12.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/jdbc/commons-dbcp2-2.12.0.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/jdbc/commons-pool2-2.12.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/jdbc/commons-pool2-2.12.0.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/jdbc/commons-logging-1.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/jdbc/commons-logging-1.3.0.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/swing-datetime-picker-1.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/swing-datetime-picker-1.3.0.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/flatlaf/flatlaf-extras-3.5.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/flatlaf/flatlaf-extras-3.5.2.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/jdbc/mysql-connector-j-8.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/jdbc/mysql-connector-j-8.3.0.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/library/flatlaf/flatlaf-fonts-roboto-2.137.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DJ-Raven/java-sample-form/HEAD/sample-form-use-modal-dialog/library/flatlaf/flatlaf-fonts-roboto-2.137.jar -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/themes/FlatLaf.properties: -------------------------------------------------------------------------------- 1 | Component.focusWidth=1 2 | Component.arc=10 3 | Button.arc=10 4 | TextComponent.arc=10 5 | Button.margin=5,5,5,5 6 | FormattedTextField.margin=5,5,5,5 7 | TextField.margin=5,5,5,5 8 | ComboBox.padding=5,5,5,5 9 | 10 | ScrollPane.TextComponent.arc=10 11 | TextArea.margin=3,1,3,1 12 | 13 | Toast.background=lighten(@background,5%) 14 | 15 | -------------------------------------------------------------------------------- /sample-form/src/sample/themes/FlatLaf.properties: -------------------------------------------------------------------------------- 1 | Component.focusWidth=1 2 | Component.arc=10 3 | Button.arc=10 4 | TextComponent.arc=10 5 | Button.margin=5,5,5,5 6 | FormattedTextField.margin=5,5,5,5 7 | TextField.margin=5,5,5,5 8 | ComboBox.padding=5,5,5,5 9 | 10 | Popup.forceHeavyWeight=true 11 | 12 | ScrollPane.TextComponent.arc=10 13 | TextArea.margin=3,1,3,1 14 | 15 | Toast.background=lighten(@background,5%) 16 | 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Swing Sample Form with FlatLaf 2 | 3 | sample dark 4 | sample light 5 | sample_1 dark 6 | -------------------------------------------------------------------------------- /sample-form/nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=8fab8ce3 2 | build.xml.script.CRC32=42d1caca 3 | build.xml.stylesheet.CRC32=f85dc8f2@1.110.0.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=8fab8ce3 7 | nbproject/build-impl.xml.script.CRC32=0b600e13 8 | nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.110.0.48 9 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=1db12185 2 | build.xml.script.CRC32=c3af8e2d 3 | build.xml.stylesheet.CRC32=f85dc8f2@1.111.0.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=1db12185 7 | nbproject/build-impl.xml.script.CRC32=7a316a4b 8 | nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.111.0.48 9 | -------------------------------------------------------------------------------- /sample-form/src/sample/icon/search.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/icon/search.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /sample-form/src/sample/swing/ButtonAction.java: -------------------------------------------------------------------------------- 1 | package sample.swing; 2 | 3 | import com.formdev.flatlaf.FlatClientProperties; 4 | import javax.swing.JButton; 5 | 6 | /** 7 | * 8 | * @author RAVEN 9 | */ 10 | public class ButtonAction extends JButton { 11 | 12 | public ButtonAction() { 13 | 14 | putClientProperty(FlatClientProperties.STYLE, "" 15 | + "arc:15;" 16 | + "borderWidth:0;" 17 | + "focusWidth:0;" 18 | + "innerFocusWidth:0;" 19 | + "margin:5,20,5,20;" 20 | + "background:$Panel.background"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/swing/ButtonAction.java: -------------------------------------------------------------------------------- 1 | package sample.swing; 2 | 3 | import com.formdev.flatlaf.FlatClientProperties; 4 | import javax.swing.JButton; 5 | 6 | /** 7 | * 8 | * @author RAVEN 9 | */ 10 | public class ButtonAction extends JButton { 11 | 12 | public ButtonAction() { 13 | 14 | putClientProperty(FlatClientProperties.STYLE, "" 15 | + "arc:15;" 16 | + "borderWidth:0;" 17 | + "focusWidth:0;" 18 | + "innerFocusWidth:0;" 19 | + "margin:5,20,5,20;" 20 | + "background:$Panel.background"); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sample-form/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | sample-form 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | sample-form-use-modal-dialog 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample-form/src/sample/model/other/ModelProfile.java: -------------------------------------------------------------------------------- 1 | package sample.model.other; 2 | 3 | import java.io.File; 4 | import javax.swing.Icon; 5 | import javax.swing.ImageIcon; 6 | 7 | /** 8 | * 9 | * @author RAVEN 10 | */ 11 | public class ModelProfile { 12 | 13 | public Icon getIcon() { 14 | return icon; 15 | } 16 | 17 | public void setIcon(Icon icon) { 18 | this.icon = icon; 19 | } 20 | 21 | public File getPath() { 22 | return path; 23 | } 24 | 25 | public void setPath(File path) { 26 | this.path = path; 27 | } 28 | 29 | public ModelProfile(File path) { 30 | this.path = path; 31 | } 32 | 33 | public ModelProfile(byte[] bytes) { 34 | if (bytes != null) { 35 | icon = new ImageIcon(bytes); 36 | } 37 | } 38 | 39 | public ModelProfile(Icon icon) { 40 | this.icon = icon; 41 | } 42 | 43 | private Icon icon; 44 | private File path; 45 | } 46 | -------------------------------------------------------------------------------- /sample-form/src/sample/table/ProfileTableRenderer.java: -------------------------------------------------------------------------------- 1 | package sample.table; 2 | 3 | import java.awt.Component; 4 | import javax.swing.JTable; 5 | import javax.swing.table.TableCellRenderer; 6 | import sample.model.ModelEmployee; 7 | 8 | /** 9 | * 10 | * @author RAVEN 11 | */ 12 | public class ProfileTableRenderer implements TableCellRenderer { 13 | 14 | private final TableCellRenderer oldCellRenderer; 15 | 16 | public ProfileTableRenderer(JTable table) { 17 | oldCellRenderer = table.getDefaultRenderer(Object.class); 18 | } 19 | 20 | @Override 21 | public Component getTableCellRendererComponent(JTable jtable, Object o, boolean bln, boolean bln1, int i, int i1) { 22 | Component com = oldCellRenderer.getTableCellRendererComponent(jtable, o, bln, bln1, i, i1); 23 | TableCellProfile cell = new TableCellProfile((ModelEmployee) o, com.getFont()); 24 | cell.setBackground(com.getBackground()); 25 | return cell; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sample-form/src/sample/model/ModelPositions.java: -------------------------------------------------------------------------------- 1 | package sample.model; 2 | 3 | /** 4 | * 5 | * @author RAVEN 6 | */ 7 | public class ModelPositions { 8 | 9 | public int getPositionsId() { 10 | return positionsId; 11 | } 12 | 13 | public void setPositionsId(int positionsId) { 14 | this.positionsId = positionsId; 15 | } 16 | 17 | public String getPositionsName() { 18 | return positionsName; 19 | } 20 | 21 | public void setPositionsName(String positionsName) { 22 | this.positionsName = positionsName; 23 | } 24 | 25 | public ModelPositions(int positionsId, String positionsName) { 26 | this.positionsId = positionsId; 27 | this.positionsName = positionsName; 28 | } 29 | 30 | public ModelPositions() { 31 | } 32 | 33 | private int positionsId; 34 | private String positionsName; 35 | 36 | @Override 37 | public String toString() { 38 | return positionsName; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/table/ProfileTableRenderer.java: -------------------------------------------------------------------------------- 1 | package sample.table; 2 | 3 | import java.awt.Component; 4 | import javax.swing.JTable; 5 | import javax.swing.table.TableCellRenderer; 6 | import sample.model.ModelEmployee; 7 | 8 | /** 9 | * 10 | * @author RAVEN 11 | */ 12 | public class ProfileTableRenderer implements TableCellRenderer { 13 | 14 | private final TableCellRenderer oldCellRenderer; 15 | 16 | public ProfileTableRenderer(JTable table) { 17 | oldCellRenderer = table.getDefaultRenderer(Object.class); 18 | } 19 | 20 | @Override 21 | public Component getTableCellRendererComponent(JTable jtable, Object o, boolean bln, boolean bln1, int i, int i1) { 22 | Component com = oldCellRenderer.getTableCellRendererComponent(jtable, o, bln, bln1, i, i1); 23 | TableCellProfile cell = new TableCellProfile((ModelEmployee) o, com.getFont()); 24 | cell.setBackground(com.getBackground()); 25 | return cell; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/model/ModelPositions.java: -------------------------------------------------------------------------------- 1 | package sample.model; 2 | 3 | /** 4 | * 5 | * @author RAVEN 6 | */ 7 | public class ModelPositions { 8 | 9 | public int getPositionsId() { 10 | return positionsId; 11 | } 12 | 13 | public void setPositionsId(int positionsId) { 14 | this.positionsId = positionsId; 15 | } 16 | 17 | public String getPositionsName() { 18 | return positionsName; 19 | } 20 | 21 | public void setPositionsName(String positionsName) { 22 | this.positionsName = positionsName; 23 | } 24 | 25 | public ModelPositions(int positionsId, String positionsName) { 26 | this.positionsId = positionsId; 27 | this.positionsName = positionsName; 28 | } 29 | 30 | public ModelPositions() { 31 | } 32 | 33 | private int positionsId; 34 | private String positionsName; 35 | 36 | @Override 37 | public String toString() { 38 | return positionsName; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /sample-form/src/sample/service/ServicePositions.java: -------------------------------------------------------------------------------- 1 | package sample.service; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import sample.connection.DatabaseConnection; 10 | import sample.model.ModelPositions; 11 | 12 | /** 13 | * 14 | * @author RAVEN 15 | */ 16 | public class ServicePositions { 17 | 18 | public List getAll() throws SQLException { 19 | Connection con = null; 20 | PreparedStatement p = null; 21 | ResultSet r = null; 22 | try { 23 | con = DatabaseConnection.getInstance().createConnection(); 24 | p = con.prepareStatement("select * from positions"); 25 | r = p.executeQuery(); 26 | List list = new ArrayList<>(); 27 | while (r.next()) { 28 | int positionId = r.getInt("positions_id"); 29 | String positionsName = r.getString("positions_name"); 30 | list.add(new ModelPositions(positionId, positionsName)); 31 | } 32 | return list; 33 | } finally { 34 | DatabaseConnection.getInstance().close(r, p, con); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/service/ServicePositions.java: -------------------------------------------------------------------------------- 1 | package sample.service; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | import sample.connection.DatabaseConnection; 10 | import sample.model.ModelPositions; 11 | 12 | /** 13 | * 14 | * @author RAVEN 15 | */ 16 | public class ServicePositions { 17 | 18 | public List getAll() throws SQLException { 19 | Connection con = null; 20 | PreparedStatement p = null; 21 | ResultSet r = null; 22 | try { 23 | con = DatabaseConnection.getInstance().createConnection(); 24 | p = con.prepareStatement("select * from positions"); 25 | r = p.executeQuery(); 26 | List list = new ArrayList<>(); 27 | while (r.next()) { 28 | int positionId = r.getInt("positions_id"); 29 | String positionsName = r.getString("positions_name"); 30 | list.add(new ModelPositions(positionId, positionsName)); 31 | } 32 | return list; 33 | } finally { 34 | DatabaseConnection.getInstance().close(r, p, con); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/model/other/ModelProfile.java: -------------------------------------------------------------------------------- 1 | package sample.model.other; 2 | 3 | import java.io.File; 4 | import javax.swing.Icon; 5 | import javax.swing.ImageIcon; 6 | import raven.extras.AvatarIcon; 7 | 8 | /** 9 | * 10 | * @author RAVEN 11 | */ 12 | public class ModelProfile { 13 | 14 | public Icon getIcon() { 15 | return icon; 16 | } 17 | 18 | public void setIcon(Icon icon) { 19 | this.icon = icon; 20 | } 21 | 22 | public File getPath() { 23 | return path; 24 | } 25 | 26 | public void setPath(File path) { 27 | this.path = path; 28 | } 29 | 30 | public ModelProfile(File path) { 31 | this.path = path; 32 | } 33 | 34 | public ModelProfile(byte[] bytes) { 35 | if (bytes != null) { 36 | icon = new ImageIcon(bytes); 37 | } 38 | } 39 | 40 | public ModelProfile(Icon icon) { 41 | this.icon = icon; 42 | } 43 | 44 | private Icon icon; 45 | private Icon avatar; 46 | private File path; 47 | 48 | public Icon getAvatarIcon() { 49 | if (icon == null) { 50 | return null; 51 | } 52 | if (avatar == null) { 53 | AvatarIcon ai = new AvatarIcon(icon, 50, 50, 3f); 54 | ai.setType(AvatarIcon.Type.MASK_SQUIRCLE); 55 | avatar = ai; 56 | } 57 | return avatar; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /sample-form/src/sample/connection/DatabaseConnection.java: -------------------------------------------------------------------------------- 1 | package sample.connection; 2 | 3 | 4 | import org.apache.commons.dbcp2.BasicDataSource; 5 | 6 | import java.sql.Connection; 7 | import java.sql.SQLException; 8 | 9 | public class DatabaseConnection { 10 | 11 | private static DatabaseConnection instance; 12 | private BasicDataSource dataSource; 13 | private String host = "localhost"; 14 | private String port = "3305"; 15 | private String database = "sample_db"; 16 | private String username = "raven"; 17 | private String password = "123"; 18 | 19 | 20 | public static DatabaseConnection getInstance() { 21 | if (instance == null) { 22 | instance = new DatabaseConnection(); 23 | } 24 | return instance; 25 | } 26 | 27 | private DatabaseConnection() { 28 | 29 | } 30 | 31 | public void connectToDatabase() throws SQLException { 32 | dataSource = new BasicDataSource(); 33 | dataSource.setUrl("jdbc:mysql://" + host + ":" + port + "/" + database); 34 | dataSource.setUsername(username); 35 | dataSource.setPassword(password); 36 | dataSource.start(); 37 | } 38 | 39 | public Connection createConnection() throws SQLException { 40 | return dataSource.getConnection(); 41 | } 42 | 43 | public void close(AutoCloseable... close) throws SQLException { 44 | try { 45 | for (AutoCloseable c : close) { 46 | if (c != null) { 47 | c.close(); 48 | } 49 | } 50 | } catch (Exception e) { 51 | throw new SQLException("Error on closing"); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/connection/DatabaseConnection.java: -------------------------------------------------------------------------------- 1 | package sample.connection; 2 | 3 | 4 | import org.apache.commons.dbcp2.BasicDataSource; 5 | 6 | import java.sql.Connection; 7 | import java.sql.SQLException; 8 | 9 | public class DatabaseConnection { 10 | 11 | private static DatabaseConnection instance; 12 | private BasicDataSource dataSource; 13 | private String host = "localhost"; 14 | private String port = "3305"; 15 | private String database = "sample_db"; 16 | private String username = "raven"; 17 | private String password = "123"; 18 | 19 | 20 | public static DatabaseConnection getInstance() { 21 | if (instance == null) { 22 | instance = new DatabaseConnection(); 23 | } 24 | return instance; 25 | } 26 | 27 | private DatabaseConnection() { 28 | 29 | } 30 | 31 | public void connectToDatabase() throws SQLException { 32 | dataSource = new BasicDataSource(); 33 | dataSource.setUrl("jdbc:mysql://" + host + ":" + port + "/" + database); 34 | dataSource.setUsername(username); 35 | dataSource.setPassword(password); 36 | dataSource.start(); 37 | } 38 | 39 | public Connection createConnection() throws SQLException { 40 | return dataSource.getConnection(); 41 | } 42 | 43 | public void close(AutoCloseable... close) throws SQLException { 44 | try { 45 | for (AutoCloseable c : close) { 46 | if (c != null) { 47 | c.close(); 48 | } 49 | } 50 | } catch (Exception e) { 51 | throw new SQLException("Error on closing"); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /sample-form/src/sample/icon/profile.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /sample-form/src/sample/table/TableHeaderAlignment.java: -------------------------------------------------------------------------------- 1 | package sample.table; 2 | 3 | import java.awt.Component; 4 | import javax.swing.JLabel; 5 | import javax.swing.JTable; 6 | import javax.swing.SwingConstants; 7 | import javax.swing.table.TableCellRenderer; 8 | 9 | /** 10 | * 11 | * @author RAVEN 12 | */ 13 | public class TableHeaderAlignment implements TableCellRenderer { 14 | 15 | private final TableCellRenderer oldHeaderRenderer; 16 | private final TableCellRenderer oldCellRenderer; 17 | 18 | public TableHeaderAlignment(JTable table) { 19 | this.oldHeaderRenderer = table.getTableHeader().getDefaultRenderer(); 20 | this.oldCellRenderer = table.getDefaultRenderer(Object.class); 21 | table.setDefaultRenderer(Object.class, new TableCellRenderer() { 22 | @Override 23 | public Component getTableCellRendererComponent(JTable jtable, Object o, boolean bln, boolean bln1, int row, int column) { 24 | JLabel label = (JLabel) oldCellRenderer.getTableCellRendererComponent(jtable, o, bln, bln1, row, column); 25 | label.setHorizontalAlignment(getAlignment(column)); 26 | return label; 27 | } 28 | }); 29 | } 30 | 31 | @Override 32 | public Component getTableCellRendererComponent(JTable jtable, Object o, boolean bln, boolean bln1, int row, int column) { 33 | JLabel label = (JLabel) oldHeaderRenderer.getTableCellRendererComponent(jtable, o, bln, bln1, row, column); 34 | label.setHorizontalAlignment(getAlignment(column)); 35 | return label; 36 | } 37 | 38 | protected int getAlignment(int column) { 39 | if (column == 1) { 40 | return SwingConstants.CENTER; 41 | } 42 | return SwingConstants.LEADING; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/icon/profile.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/table/TableHeaderAlignment.java: -------------------------------------------------------------------------------- 1 | package sample.table; 2 | 3 | import java.awt.Component; 4 | import javax.swing.JLabel; 5 | import javax.swing.JTable; 6 | import javax.swing.SwingConstants; 7 | import javax.swing.table.TableCellRenderer; 8 | 9 | /** 10 | * 11 | * @author RAVEN 12 | */ 13 | public class TableHeaderAlignment implements TableCellRenderer { 14 | 15 | private final TableCellRenderer oldHeaderRenderer; 16 | private final TableCellRenderer oldCellRenderer; 17 | 18 | public TableHeaderAlignment(JTable table) { 19 | this.oldHeaderRenderer = table.getTableHeader().getDefaultRenderer(); 20 | this.oldCellRenderer = table.getDefaultRenderer(Object.class); 21 | table.setDefaultRenderer(Object.class, new TableCellRenderer() { 22 | @Override 23 | public Component getTableCellRendererComponent(JTable jtable, Object o, boolean bln, boolean bln1, int row, int column) { 24 | JLabel label = (JLabel) oldCellRenderer.getTableCellRendererComponent(jtable, o, bln, bln1, row, column); 25 | label.setHorizontalAlignment(getAlignment(column)); 26 | return label; 27 | } 28 | }); 29 | } 30 | 31 | @Override 32 | public Component getTableCellRendererComponent(JTable jtable, Object o, boolean bln, boolean bln1, int row, int column) { 33 | JLabel label = (JLabel) oldHeaderRenderer.getTableCellRendererComponent(jtable, o, bln, bln1, row, column); 34 | label.setHorizontalAlignment(getAlignment(column)); 35 | return label; 36 | } 37 | 38 | protected int getAlignment(int column) { 39 | if (column == 1) { 40 | return SwingConstants.CENTER; 41 | } 42 | return SwingConstants.LEADING; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /sample-form/src/sample/utils/SuperEllipse2D.java: -------------------------------------------------------------------------------- 1 | package sample.utils; 2 | 3 | import java.awt.Shape; 4 | import java.awt.geom.GeneralPath; 5 | 6 | public class SuperEllipse2D { 7 | 8 | double x, y, width, height, eccentricity; 9 | 10 | GeneralPath path; 11 | 12 | /** 13 | * eccentricity must be between 0 and infinity 14 | */ 15 | public SuperEllipse2D(double x, double y, double width, double height, double eccentricity) { 16 | if (eccentricity < 0.0) { 17 | throw new IllegalArgumentException("eccentricity must be between 0 and infinity"); 18 | } 19 | 20 | this.x = x; 21 | this.y = y; 22 | this.width = width; 23 | this.height = height; 24 | this.eccentricity = eccentricity; 25 | 26 | initialise(); 27 | } 28 | 29 | private void initialise() { 30 | 31 | path = new GeneralPath(); 32 | 33 | if (eccentricity == Double.POSITIVE_INFINITY) { 34 | // special case! 35 | path.moveTo((float) x, (float) y); 36 | path.lineTo((float) x, (float) (y + height)); 37 | path.lineTo((float) (x + width), (float) (y + height)); 38 | path.lineTo((float) (x + width), (float) y); 39 | path.closePath(); 40 | } else { 41 | 42 | double halfWidth = width / 2.0; 43 | double halfHeight = height / 2.0; 44 | 45 | double centreX = x + halfWidth; 46 | double centreY = y + halfHeight; 47 | 48 | double TWO_PI = Math.PI * 2.0; 49 | int resolution = 100; 50 | 51 | path.moveTo((float) (x + width), (float) centreY); 52 | 53 | for (double theta = 0.0; theta < TWO_PI; theta += TWO_PI / resolution) { 54 | double sineTheta = Math.sin(theta); 55 | double cosineTheta = Math.cos(theta); 56 | double r 57 | = Math.pow(1 / (Math.pow(Math.abs(cosineTheta) / halfWidth, eccentricity) + Math.pow(Math.abs(sineTheta) / halfHeight, eccentricity)), 58 | 1 / eccentricity); 59 | path.lineTo((float) (centreX + r * cosineTheta), (float) (centreY + r * sineTheta)); 60 | } 61 | } 62 | } 63 | 64 | public Shape getShape() { 65 | return path; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /sample-form/src/sample/model/ModelEmployee.java: -------------------------------------------------------------------------------- 1 | package sample.model; 2 | 3 | import java.sql.Date; 4 | import java.text.DateFormat; 5 | import java.text.DecimalFormat; 6 | import java.text.NumberFormat; 7 | import java.text.SimpleDateFormat; 8 | import sample.model.other.ModelProfile; 9 | 10 | /** 11 | * 12 | * @author RAVEN 13 | */ 14 | public class ModelEmployee { 15 | 16 | public ModelProfile getProfile() { 17 | return profile; 18 | } 19 | 20 | public void setProfile(ModelProfile profile) { 21 | this.profile = profile; 22 | } 23 | 24 | public int getEmployeeId() { 25 | return employeeId; 26 | } 27 | 28 | public void setEmployeeId(int employeeId) { 29 | this.employeeId = employeeId; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public String getLocation() { 41 | return location; 42 | } 43 | 44 | public void setLocation(String location) { 45 | this.location = location; 46 | } 47 | 48 | public Date getDate() { 49 | return date; 50 | } 51 | 52 | public void setDate(Date date) { 53 | this.date = date; 54 | } 55 | 56 | public double getSalary() { 57 | return salary; 58 | } 59 | 60 | public void setSalary(double salary) { 61 | this.salary = salary; 62 | } 63 | 64 | public String getDescription() { 65 | return description; 66 | } 67 | 68 | public void setDescription(String description) { 69 | this.description = description; 70 | } 71 | 72 | public ModelPositions getPositions() { 73 | return positions; 74 | } 75 | 76 | public void setPositions(ModelPositions positions) { 77 | this.positions = positions; 78 | } 79 | 80 | public ModelEmployee(int employeeId, String name, String location, Date date, double salary, String description, ModelProfile profile, ModelPositions positions) { 81 | this.employeeId = employeeId; 82 | this.name = name; 83 | this.location = location; 84 | this.date = date; 85 | this.salary = salary; 86 | this.description = description; 87 | this.profile = profile; 88 | this.positions = positions; 89 | } 90 | 91 | public ModelEmployee() { 92 | } 93 | 94 | private int employeeId; 95 | private String name; 96 | private String location; 97 | private Date date; 98 | private double salary; 99 | private String description; 100 | private ModelProfile profile; 101 | private ModelPositions positions; 102 | 103 | public Object[] toTableRow(int rowNum) { 104 | DateFormat df = new SimpleDateFormat("dd-MMMM-yyyy"); 105 | NumberFormat nf = new DecimalFormat("$ #,##0.##"); 106 | return new Object[]{false, rowNum, this, date == null ? "" : df.format(date), nf.format(salary), positions, description}; 107 | } 108 | 109 | @Override 110 | public String toString() { 111 | return name; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/model/ModelEmployee.java: -------------------------------------------------------------------------------- 1 | package sample.model; 2 | 3 | import java.sql.Date; 4 | import java.text.DateFormat; 5 | import java.text.DecimalFormat; 6 | import java.text.NumberFormat; 7 | import java.text.SimpleDateFormat; 8 | import sample.model.other.ModelProfile; 9 | 10 | /** 11 | * 12 | * @author RAVEN 13 | */ 14 | public class ModelEmployee { 15 | 16 | public ModelProfile getProfile() { 17 | return profile; 18 | } 19 | 20 | public void setProfile(ModelProfile profile) { 21 | this.profile = profile; 22 | } 23 | 24 | public int getEmployeeId() { 25 | return employeeId; 26 | } 27 | 28 | public void setEmployeeId(int employeeId) { 29 | this.employeeId = employeeId; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public String getLocation() { 41 | return location; 42 | } 43 | 44 | public void setLocation(String location) { 45 | this.location = location; 46 | } 47 | 48 | public Date getDate() { 49 | return date; 50 | } 51 | 52 | public void setDate(Date date) { 53 | this.date = date; 54 | } 55 | 56 | public double getSalary() { 57 | return salary; 58 | } 59 | 60 | public void setSalary(double salary) { 61 | this.salary = salary; 62 | } 63 | 64 | public String getDescription() { 65 | return description; 66 | } 67 | 68 | public void setDescription(String description) { 69 | this.description = description; 70 | } 71 | 72 | public ModelPositions getPositions() { 73 | return positions; 74 | } 75 | 76 | public void setPositions(ModelPositions positions) { 77 | this.positions = positions; 78 | } 79 | 80 | public ModelEmployee(int employeeId, String name, String location, Date date, double salary, String description, ModelProfile profile, ModelPositions positions) { 81 | this.employeeId = employeeId; 82 | this.name = name; 83 | this.location = location; 84 | this.date = date; 85 | this.salary = salary; 86 | this.description = description; 87 | this.profile = profile; 88 | this.positions = positions; 89 | } 90 | 91 | public ModelEmployee() { 92 | } 93 | 94 | private int employeeId; 95 | private String name; 96 | private String location; 97 | private Date date; 98 | private double salary; 99 | private String description; 100 | private ModelProfile profile; 101 | private ModelPositions positions; 102 | 103 | public Object[] toTableRow(int rowNum) { 104 | DateFormat df = new SimpleDateFormat("dd-MMMM-yyyy"); 105 | NumberFormat nf = new DecimalFormat("$ #,##0.##"); 106 | return new Object[]{false, rowNum, this, date == null ? "" : df.format(date), nf.format(salary), positions, description}; 107 | } 108 | 109 | @Override 110 | public String toString() { 111 | return name; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/table/TableCellProfile.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 |
63 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/table/TableCellProfile.java: -------------------------------------------------------------------------------- 1 | package sample.table; 2 | 3 | import com.formdev.flatlaf.FlatClientProperties; 4 | import java.awt.Font; 5 | import sample.model.ModelEmployee; 6 | 7 | /** 8 | * 9 | * @author RAVEN 10 | */ 11 | public class TableCellProfile extends javax.swing.JPanel { 12 | 13 | public TableCellProfile(ModelEmployee data, Font font) { 14 | initComponents(); 15 | lbName.setFont(font); 16 | lbLocation.setFont(font); 17 | lbName.setText(data.getName()); 18 | lbLocation.setText(data.getLocation()); 19 | lbLocation.putClientProperty(FlatClientProperties.STYLE, "" 20 | + "foreground:$Label.disabledForeground"); 21 | if (data.getProfile().getIcon() != null) { 22 | pic.setIcon(data.getProfile().getAvatarIcon()); 23 | } 24 | } 25 | 26 | @SuppressWarnings("unchecked") 27 | // //GEN-BEGIN:initComponents 28 | private void initComponents() { 29 | 30 | lbName = new javax.swing.JLabel(); 31 | lbLocation = new javax.swing.JLabel(); 32 | pic = new javax.swing.JLabel(); 33 | 34 | lbName.setText("Name"); 35 | 36 | lbLocation.setText("Location"); 37 | 38 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); 39 | this.setLayout(layout); 40 | layout.setHorizontalGroup( 41 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 42 | .addGroup(layout.createSequentialGroup() 43 | .addGap(5, 5, 5) 44 | .addComponent(pic, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) 45 | .addGap(11, 11, 11) 46 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 47 | .addComponent(lbName) 48 | .addComponent(lbLocation)) 49 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 50 | ); 51 | layout.setVerticalGroup( 52 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 53 | .addGroup(layout.createSequentialGroup() 54 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 55 | .addComponent(lbName) 56 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 57 | .addComponent(lbLocation) 58 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 59 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 60 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 61 | .addComponent(pic, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) 62 | .addContainerGap()) 63 | ); 64 | }// //GEN-END:initComponents 65 | 66 | 67 | // Variables declaration - do not modify//GEN-BEGIN:variables 68 | private javax.swing.JLabel lbLocation; 69 | private javax.swing.JLabel lbName; 70 | private javax.swing.JLabel pic; 71 | // End of variables declaration//GEN-END:variables 72 | } 73 | -------------------------------------------------------------------------------- /sample-form/src/sample/table/TableCellProfile.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |
68 | -------------------------------------------------------------------------------- /sample-form/src/sample/table/CheckBoxTableHeaderRenderer.java: -------------------------------------------------------------------------------- 1 | package sample.table; 2 | 3 | import com.formdev.flatlaf.FlatClientProperties; 4 | import com.formdev.flatlaf.util.UIScale; 5 | import java.awt.Component; 6 | import java.awt.Graphics; 7 | import java.awt.Graphics2D; 8 | import java.awt.event.MouseAdapter; 9 | import java.awt.event.MouseEvent; 10 | import java.awt.geom.Rectangle2D; 11 | import javax.swing.JCheckBox; 12 | import javax.swing.JTable; 13 | import javax.swing.SwingConstants; 14 | import javax.swing.SwingUtilities; 15 | import javax.swing.UIManager; 16 | import javax.swing.event.TableModelEvent; 17 | import javax.swing.table.TableCellRenderer; 18 | 19 | /** 20 | * 21 | * @author RAVEN 22 | */ 23 | public class CheckBoxTableHeaderRenderer extends JCheckBox implements TableCellRenderer { 24 | 25 | private final JTable table; 26 | private final int column; 27 | 28 | public CheckBoxTableHeaderRenderer(JTable table, int column) { 29 | this.table = table; 30 | this.column = column; 31 | init(); 32 | } 33 | 34 | private void init() { 35 | putClientProperty(FlatClientProperties.STYLE, "" 36 | + "background:$Table.background"); 37 | setHorizontalAlignment(SwingConstants.CENTER); 38 | 39 | table.getTableHeader().addMouseListener(new MouseAdapter() { 40 | @Override 41 | public void mousePressed(MouseEvent me) { 42 | if (SwingUtilities.isLeftMouseButton(me)) { 43 | int col = table.columnAtPoint(me.getPoint()); 44 | if (col == column) { 45 | putClientProperty(FlatClientProperties.SELECTED_STATE, null); 46 | setSelected(!isSelected()); 47 | selectedTableRow(isSelected()); 48 | } 49 | } 50 | } 51 | }); 52 | 53 | table.getModel().addTableModelListener((tme) -> { 54 | if (tme.getColumn() == column || tme.getType() == TableModelEvent.DELETE) { 55 | checkRow(); 56 | } 57 | }); 58 | } 59 | 60 | private void checkRow() { 61 | boolean initValue = table.getRowCount() == 0 ? false : (boolean) table.getValueAt(0, column); 62 | for (int i = 1; i < table.getRowCount(); i++) { 63 | boolean v = (boolean) table.getValueAt(i, column); 64 | if (initValue != v) { 65 | putClientProperty(FlatClientProperties.SELECTED_STATE, FlatClientProperties.SELECTED_STATE_INDETERMINATE); 66 | table.getTableHeader().repaint(); 67 | return; 68 | } 69 | } 70 | putClientProperty(FlatClientProperties.SELECTED_STATE, null); 71 | setSelected(initValue); 72 | table.getTableHeader().repaint(); 73 | } 74 | 75 | private void selectedTableRow(boolean selected) { 76 | for (int i = 0; i < table.getRowCount(); i++) { 77 | table.setValueAt(selected, i, column); 78 | } 79 | } 80 | 81 | @Override 82 | public Component getTableCellRendererComponent(JTable jtable, Object o, boolean bln, boolean bln1, int i, int i1) { 83 | return this; 84 | } 85 | 86 | @Override 87 | protected void paintComponent(Graphics grphcs) { 88 | Graphics2D g2 = (Graphics2D) grphcs.create(); 89 | g2.setColor(UIManager.getColor("TableHeader.bottomSeparatorColor")); 90 | float size = UIScale.scale(1f); 91 | g2.fill(new Rectangle2D.Float(0, getHeight() - size, getWidth(), size)); 92 | g2.dispose(); 93 | super.paintComponent(grphcs); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/table/CheckBoxTableHeaderRenderer.java: -------------------------------------------------------------------------------- 1 | package sample.table; 2 | 3 | import com.formdev.flatlaf.FlatClientProperties; 4 | import com.formdev.flatlaf.util.UIScale; 5 | import java.awt.Component; 6 | import java.awt.Graphics; 7 | import java.awt.Graphics2D; 8 | import java.awt.event.MouseAdapter; 9 | import java.awt.event.MouseEvent; 10 | import java.awt.geom.Rectangle2D; 11 | import javax.swing.JCheckBox; 12 | import javax.swing.JTable; 13 | import javax.swing.SwingConstants; 14 | import javax.swing.SwingUtilities; 15 | import javax.swing.UIManager; 16 | import javax.swing.event.TableModelEvent; 17 | import javax.swing.table.TableCellRenderer; 18 | 19 | /** 20 | * 21 | * @author RAVEN 22 | */ 23 | public class CheckBoxTableHeaderRenderer extends JCheckBox implements TableCellRenderer { 24 | 25 | private final JTable table; 26 | private final int column; 27 | 28 | public CheckBoxTableHeaderRenderer(JTable table, int column) { 29 | this.table = table; 30 | this.column = column; 31 | init(); 32 | } 33 | 34 | private void init() { 35 | putClientProperty(FlatClientProperties.STYLE, "" 36 | + "background:$Table.background"); 37 | setHorizontalAlignment(SwingConstants.CENTER); 38 | 39 | table.getTableHeader().addMouseListener(new MouseAdapter() { 40 | @Override 41 | public void mousePressed(MouseEvent me) { 42 | if (SwingUtilities.isLeftMouseButton(me)) { 43 | int col = table.columnAtPoint(me.getPoint()); 44 | if (col == column) { 45 | putClientProperty(FlatClientProperties.SELECTED_STATE, null); 46 | setSelected(!isSelected()); 47 | selectedTableRow(isSelected()); 48 | } 49 | } 50 | } 51 | }); 52 | 53 | table.getModel().addTableModelListener((tme) -> { 54 | if (tme.getColumn() == column || tme.getType() == TableModelEvent.DELETE) { 55 | checkRow(); 56 | } 57 | }); 58 | } 59 | 60 | private void checkRow() { 61 | boolean initValue = table.getRowCount() == 0 ? false : (boolean) table.getValueAt(0, column); 62 | for (int i = 1; i < table.getRowCount(); i++) { 63 | boolean v = (boolean) table.getValueAt(i, column); 64 | if (initValue != v) { 65 | putClientProperty(FlatClientProperties.SELECTED_STATE, FlatClientProperties.SELECTED_STATE_INDETERMINATE); 66 | table.getTableHeader().repaint(); 67 | return; 68 | } 69 | } 70 | putClientProperty(FlatClientProperties.SELECTED_STATE, null); 71 | setSelected(initValue); 72 | table.getTableHeader().repaint(); 73 | } 74 | 75 | private void selectedTableRow(boolean selected) { 76 | for (int i = 0; i < table.getRowCount(); i++) { 77 | table.setValueAt(selected, i, column); 78 | } 79 | } 80 | 81 | @Override 82 | public Component getTableCellRendererComponent(JTable jtable, Object o, boolean bln, boolean bln1, int i, int i1) { 83 | return this; 84 | } 85 | 86 | @Override 87 | protected void paintComponent(Graphics grphcs) { 88 | Graphics2D g2 = (Graphics2D) grphcs.create(); 89 | g2.setColor(UIManager.getColor("TableHeader.bottomSeparatorColor")); 90 | float size = UIScale.scale(1f); 91 | g2.fill(new Rectangle2D.Float(0, getHeight() - size, getWidth(), size)); 92 | g2.dispose(); 93 | super.paintComponent(grphcs); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /sample-form/src/sample/table/TableCellProfile.java: -------------------------------------------------------------------------------- 1 | package sample.table; 2 | 3 | import com.formdev.flatlaf.FlatClientProperties; 4 | import java.awt.Font; 5 | import java.awt.Rectangle; 6 | import java.awt.Shape; 7 | import javaswingdev.picturebox.DefaultPictureBoxRender; 8 | import sample.model.ModelEmployee; 9 | import sample.utils.SuperEllipse2D; 10 | 11 | /** 12 | * 13 | * @author RAVEN 14 | */ 15 | public class TableCellProfile extends javax.swing.JPanel { 16 | 17 | public TableCellProfile(ModelEmployee data, Font font) { 18 | initComponents(); 19 | lbName.setFont(font); 20 | lbLocation.setFont(font); 21 | lbName.setText(data.getName()); 22 | lbLocation.setText(data.getLocation()); 23 | lbLocation.putClientProperty(FlatClientProperties.STYLE, "" 24 | + "foreground:$Label.disabledForeground"); 25 | if (data.getProfile().getIcon() != null) { 26 | pic.setImage(data.getProfile().getIcon()); 27 | } 28 | 29 | pic.setPictureBoxRender(new DefaultPictureBoxRender() { 30 | @Override 31 | public Shape render(Rectangle rec) { 32 | return new SuperEllipse2D(rec.x, rec.y, rec.width, rec.height, 3f).getShape(); 33 | } 34 | }); 35 | } 36 | 37 | @SuppressWarnings("unchecked") 38 | // //GEN-BEGIN:initComponents 39 | private void initComponents() { 40 | 41 | pic = new javaswingdev.picturebox.PictureBox(); 42 | lbName = new javax.swing.JLabel(); 43 | lbLocation = new javax.swing.JLabel(); 44 | 45 | lbName.setText("Name"); 46 | 47 | lbLocation.setText("Location"); 48 | 49 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); 50 | this.setLayout(layout); 51 | layout.setHorizontalGroup( 52 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 53 | .addGroup(layout.createSequentialGroup() 54 | .addContainerGap() 55 | .addComponent(pic, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) 56 | .addGap(10, 10, 10) 57 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 58 | .addComponent(lbName) 59 | .addComponent(lbLocation)) 60 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 61 | ); 62 | layout.setVerticalGroup( 63 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 64 | .addGroup(layout.createSequentialGroup() 65 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 66 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 67 | .addGroup(layout.createSequentialGroup() 68 | .addComponent(lbName) 69 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 70 | .addComponent(lbLocation) 71 | .addGap(4, 4, 4)) 72 | .addComponent(pic, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)) 73 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 74 | ); 75 | }// //GEN-END:initComponents 76 | 77 | 78 | // Variables declaration - do not modify//GEN-BEGIN:variables 79 | private javax.swing.JLabel lbLocation; 80 | private javax.swing.JLabel lbName; 81 | private javaswingdev.picturebox.PictureBox pic; 82 | // End of variables declaration//GEN-END:variables 83 | } 84 | -------------------------------------------------------------------------------- /sample-form/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project sample-form. 12 | 13 | 73 | 74 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project sample-form-use-modal-dialog. 12 | 13 | 73 | 74 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processors.list= 4 | annotation.processing.run.all.processors=true 5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 6 | application.title=sample-form-use-modal-dialog 7 | application.vendor=RAVEN 8 | build.classes.dir=${build.dir}/classes 9 | build.classes.excludes=**/*.java,**/*.form 10 | # This directory is removed when the project is cleaned: 11 | build.dir=build 12 | build.generated.dir=${build.dir}/generated 13 | build.generated.sources.dir=${build.dir}/generated-sources 14 | # Only compile against the classpath explicitly listed here: 15 | build.sysclasspath=ignore 16 | build.test.classes.dir=${build.dir}/test/classes 17 | build.test.results.dir=${build.dir}/test/results 18 | # Uncomment to specify the preferred debugger connection transport: 19 | #debug.transport=dt_socket 20 | debug.classpath=\ 21 | ${run.classpath} 22 | debug.modulepath=\ 23 | ${run.modulepath} 24 | debug.test.classpath=\ 25 | ${run.test.classpath} 26 | debug.test.modulepath=\ 27 | ${run.test.modulepath} 28 | # Files in build.classes.dir which should be excluded from distribution jar 29 | dist.archive.excludes= 30 | # This directory is removed when the project is cleaned: 31 | dist.dir=dist 32 | dist.jar=${dist.dir}/sample-form-use-modal-dialog.jar 33 | dist.javadoc.dir=${dist.dir}/javadoc 34 | dist.jlink.dir=${dist.dir}/jlink 35 | dist.jlink.output=${dist.jlink.dir}/sample-form-use-modal-dialog 36 | endorsed.classpath= 37 | excludes= 38 | file.reference.commons-dbcp2-2.12.0.jar=library/jdbc/commons-dbcp2-2.12.0.jar 39 | file.reference.commons-logging-1.3.0.jar=library/jdbc/commons-logging-1.3.0.jar 40 | file.reference.commons-pool2-2.12.0.jar=library/jdbc/commons-pool2-2.12.0.jar 41 | file.reference.flatlaf-3.5.2.jar=library\\flatlaf\\flatlaf-3.5.2.jar 42 | file.reference.flatlaf-extras-3.5.2.jar=library\\flatlaf\\flatlaf-extras-3.5.2.jar 43 | file.reference.flatlaf-fonts-roboto-2.137.jar=library/flatlaf/flatlaf-fonts-roboto-2.137.jar 44 | file.reference.jna-5.5.0.jar=library/jna-5.5.0.jar 45 | file.reference.jsvg-1.5.0.jar=library\\flatlaf\\jsvg-1.5.0.jar 46 | file.reference.miglayout-core.jar=library/miglayout-core.jar 47 | file.reference.miglayout-swing.jar=library/miglayout-swing.jar 48 | file.reference.modal-dialog-2.1.0.jar=library\\modal-dialog-2.1.0.jar 49 | file.reference.mysql-connector-j-8.3.0.jar=library/jdbc/mysql-connector-j-8.3.0.jar 50 | file.reference.picture-box-1.2.jar=library/picture-box-1.2.jar 51 | file.reference.swing-datetime-picker-1.3.0.jar=library\\swing-datetime-picker-1.3.0.jar 52 | file.reference.swing-jnafilechooser.jar=library/swing-jnafilechooser.jar 53 | file.reference.thumbnailator-0.4.20.jar=library/thumbnailator-0.4.20.jar 54 | includes=** 55 | jar.archive.disabled=${jnlp.enabled} 56 | jar.compress=false 57 | jar.index=${jnlp.enabled} 58 | javac.classpath=\ 59 | ${file.reference.flatlaf-fonts-roboto-2.137.jar}:\ 60 | ${file.reference.commons-dbcp2-2.12.0.jar}:\ 61 | ${file.reference.commons-logging-1.3.0.jar}:\ 62 | ${file.reference.commons-pool2-2.12.0.jar}:\ 63 | ${file.reference.mysql-connector-j-8.3.0.jar}:\ 64 | ${file.reference.miglayout-core.jar}:\ 65 | ${file.reference.miglayout-swing.jar}:\ 66 | ${file.reference.jna-5.5.0.jar}:\ 67 | ${file.reference.picture-box-1.2.jar}:\ 68 | ${file.reference.swing-jnafilechooser.jar}:\ 69 | ${file.reference.thumbnailator-0.4.20.jar}:\ 70 | ${file.reference.swing-datetime-picker-1.3.0.jar}:\ 71 | ${file.reference.modal-dialog-2.1.0.jar}:\ 72 | ${file.reference.flatlaf-3.5.2.jar}:\ 73 | ${file.reference.flatlaf-extras-3.5.2.jar}:\ 74 | ${file.reference.jsvg-1.5.0.jar} 75 | # Space-separated list of extra javac options 76 | javac.compilerargs= 77 | javac.deprecation=false 78 | javac.external.vm=true 79 | javac.modulepath= 80 | javac.processormodulepath= 81 | javac.processorpath=\ 82 | ${javac.classpath} 83 | javac.source=1.8 84 | javac.target=1.8 85 | javac.test.classpath=\ 86 | ${javac.classpath}:\ 87 | ${build.classes.dir} 88 | javac.test.modulepath=\ 89 | ${javac.modulepath} 90 | javac.test.processorpath=\ 91 | ${javac.test.classpath} 92 | javadoc.additionalparam= 93 | javadoc.author=false 94 | javadoc.encoding=${source.encoding} 95 | javadoc.html5=false 96 | javadoc.noindex=false 97 | javadoc.nonavbar=false 98 | javadoc.notree=false 99 | javadoc.private=false 100 | javadoc.splitindex=true 101 | javadoc.use=true 102 | javadoc.version=false 103 | javadoc.windowtitle= 104 | # The jlink additional root modules to resolve 105 | jlink.additionalmodules= 106 | # The jlink additional command line parameters 107 | jlink.additionalparam= 108 | jlink.launcher=true 109 | jlink.launcher.name=sample-form-use-modal-dialog 110 | jnlp.codebase.type=no.codebase 111 | jnlp.descriptor=application 112 | jnlp.enabled=false 113 | jnlp.mixed.code=default 114 | jnlp.offline-allowed=false 115 | jnlp.signed=false 116 | jnlp.signing= 117 | jnlp.signing.alias= 118 | jnlp.signing.keystore= 119 | main.class=sample.form.Main 120 | # Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found. 121 | manifest.custom.application.library.allowable.codebase= 122 | # Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts. 123 | manifest.custom.caller.allowable.codebase= 124 | # Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed 125 | manifest.custom.codebase= 126 | # Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) 127 | manifest.custom.permissions= 128 | manifest.file=manifest.mf 129 | meta.inf.dir=${src.dir}/META-INF 130 | mkdist.disabled=false 131 | platform.active=JDK_1.8 132 | run.classpath=\ 133 | ${javac.classpath}:\ 134 | ${build.classes.dir} 135 | # Space-separated list of JVM arguments used when running the project. 136 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. 137 | # To set system properties for unit tests define test-sys-prop.name=value: 138 | run.jvmargs= 139 | run.modulepath=\ 140 | ${javac.modulepath} 141 | run.test.classpath=\ 142 | ${javac.test.classpath}:\ 143 | ${build.test.classes.dir} 144 | run.test.modulepath=\ 145 | ${javac.test.modulepath} 146 | source.encoding=UTF-8 147 | src.dir=src 148 | test.src.dir=test 149 | -------------------------------------------------------------------------------- /sample-form/nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processors.list= 4 | annotation.processing.run.all.processors=true 5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 6 | application.title=sample-form 7 | application.vendor=RAVEN 8 | build.classes.dir=${build.dir}/classes 9 | build.classes.excludes=**/*.java,**/*.form 10 | # This directory is removed when the project is cleaned: 11 | build.dir=build 12 | build.generated.dir=${build.dir}/generated 13 | build.generated.sources.dir=${build.dir}/generated-sources 14 | # Only compile against the classpath explicitly listed here: 15 | build.sysclasspath=ignore 16 | build.test.classes.dir=${build.dir}/test/classes 17 | build.test.results.dir=${build.dir}/test/results 18 | # Uncomment to specify the preferred debugger connection transport: 19 | #debug.transport=dt_socket 20 | debug.classpath=\ 21 | ${run.classpath} 22 | debug.modulepath=\ 23 | ${run.modulepath} 24 | debug.test.classpath=\ 25 | ${run.test.classpath} 26 | debug.test.modulepath=\ 27 | ${run.test.modulepath} 28 | # Files in build.classes.dir which should be excluded from distribution jar 29 | dist.archive.excludes= 30 | # This directory is removed when the project is cleaned: 31 | dist.dir=dist 32 | dist.jar=${dist.dir}/sample-form.jar 33 | dist.javadoc.dir=${dist.dir}/javadoc 34 | dist.jlink.dir=${dist.dir}/jlink 35 | dist.jlink.output=${dist.jlink.dir}/sample-form 36 | endorsed.classpath= 37 | excludes= 38 | file.reference.commons-dbcp2-2.12.0.jar=library\\jdbc\\commons-dbcp2-2.12.0.jar 39 | file.reference.commons-logging-1.3.0.jar=library\\jdbc\\commons-logging-1.3.0.jar 40 | file.reference.commons-pool2-2.12.0.jar=library\\jdbc\\commons-pool2-2.12.0.jar 41 | file.reference.flatlaf-3.4.1.jar=library\\flatlaf\\flatlaf-3.4.1.jar 42 | file.reference.flatlaf-extras-3.4.1.jar=library\\flatlaf\\flatlaf-extras-3.4.1.jar 43 | file.reference.flatlaf-fonts-roboto-2.137.jar=library\\flatlaf\\flatlaf-fonts-roboto-2.137.jar 44 | file.reference.jna-5.5.0.jar=library\\jna-5.5.0.jar 45 | file.reference.jsvg-1.4.0.jar=library\\flatlaf\\jsvg-1.4.0.jar 46 | file.reference.miglayout-core.jar=library\\miglayout-core.jar 47 | file.reference.miglayout-swing.jar=library\\miglayout-swing.jar 48 | file.reference.mysql-connector-j-8.3.0.jar=library\\jdbc\\mysql-connector-j-8.3.0.jar 49 | file.reference.picture-box-1.2.jar=library\\picture-box-1.2.jar 50 | file.reference.swing-datetime-picker-1.2.0.jar=library\\swing-datetime-picker-1.2.0.jar 51 | file.reference.swing-glasspane-popup-1.5.0.jar=library\\swing-glasspane-popup-1.5.0.jar 52 | file.reference.swing-jnafilechooser.jar=library\\swing-jnafilechooser.jar 53 | file.reference.swing-toast-notifications-1.0.2.jar=library\\swing-toast-notifications-1.0.2.jar 54 | file.reference.thumbnailator-0.4.20.jar=library\\thumbnailator-0.4.20.jar 55 | includes=** 56 | jar.archive.disabled=${jnlp.enabled} 57 | jar.compress=false 58 | jar.index=${jnlp.enabled} 59 | javac.classpath=\ 60 | ${file.reference.flatlaf-3.4.1.jar}:\ 61 | ${file.reference.flatlaf-extras-3.4.1.jar}:\ 62 | ${file.reference.flatlaf-fonts-roboto-2.137.jar}:\ 63 | ${file.reference.jsvg-1.4.0.jar}:\ 64 | ${file.reference.commons-dbcp2-2.12.0.jar}:\ 65 | ${file.reference.commons-logging-1.3.0.jar}:\ 66 | ${file.reference.commons-pool2-2.12.0.jar}:\ 67 | ${file.reference.mysql-connector-j-8.3.0.jar}:\ 68 | ${file.reference.miglayout-core.jar}:\ 69 | ${file.reference.miglayout-swing.jar}:\ 70 | ${file.reference.swing-datetime-picker-1.2.0.jar}:\ 71 | ${file.reference.swing-glasspane-popup-1.5.0.jar}:\ 72 | ${file.reference.swing-toast-notifications-1.0.2.jar}:\ 73 | ${file.reference.jna-5.5.0.jar}:\ 74 | ${file.reference.picture-box-1.2.jar}:\ 75 | ${file.reference.swing-jnafilechooser.jar}:\ 76 | ${file.reference.thumbnailator-0.4.20.jar} 77 | # Space-separated list of extra javac options 78 | javac.compilerargs= 79 | javac.deprecation=false 80 | javac.external.vm=true 81 | javac.modulepath= 82 | javac.processormodulepath= 83 | javac.processorpath=\ 84 | ${javac.classpath} 85 | javac.source=1.8 86 | javac.target=1.8 87 | javac.test.classpath=\ 88 | ${javac.classpath}:\ 89 | ${build.classes.dir} 90 | javac.test.modulepath=\ 91 | ${javac.modulepath} 92 | javac.test.processorpath=\ 93 | ${javac.test.classpath} 94 | javadoc.additionalparam= 95 | javadoc.author=false 96 | javadoc.encoding=${source.encoding} 97 | javadoc.html5=false 98 | javadoc.noindex=false 99 | javadoc.nonavbar=false 100 | javadoc.notree=false 101 | javadoc.private=false 102 | javadoc.splitindex=true 103 | javadoc.use=true 104 | javadoc.version=false 105 | javadoc.windowtitle= 106 | # The jlink additional root modules to resolve 107 | jlink.additionalmodules= 108 | # The jlink additional command line parameters 109 | jlink.additionalparam= 110 | jlink.launcher=true 111 | jlink.launcher.name=sample-form 112 | jnlp.codebase.type=no.codebase 113 | jnlp.descriptor=application 114 | jnlp.enabled=false 115 | jnlp.mixed.code=default 116 | jnlp.offline-allowed=false 117 | jnlp.signed=false 118 | jnlp.signing= 119 | jnlp.signing.alias= 120 | jnlp.signing.keystore= 121 | main.class=sample.form.Main 122 | # Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found. 123 | manifest.custom.application.library.allowable.codebase= 124 | # Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts. 125 | manifest.custom.caller.allowable.codebase= 126 | # Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed 127 | manifest.custom.codebase= 128 | # Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) 129 | manifest.custom.permissions= 130 | manifest.file=manifest.mf 131 | meta.inf.dir=${src.dir}/META-INF 132 | mkdist.disabled=false 133 | platform.active=JDK_8 134 | run.classpath=\ 135 | ${javac.classpath}:\ 136 | ${build.classes.dir} 137 | # Space-separated list of JVM arguments used when running the project. 138 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. 139 | # To set system properties for unit tests define test-sys-prop.name=value: 140 | run.jvmargs= 141 | run.modulepath=\ 142 | ${javac.modulepath} 143 | run.test.classpath=\ 144 | ${javac.test.classpath}:\ 145 | ${build.test.classes.dir} 146 | run.test.modulepath=\ 147 | ${javac.test.modulepath} 148 | source.encoding=UTF-8 149 | src.dir=src 150 | test.src.dir=test 151 | -------------------------------------------------------------------------------- /sample-form/src/sample/service/ServiceEmployee.java: -------------------------------------------------------------------------------- 1 | package sample.service; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.sql.Connection; 8 | import java.sql.Date; 9 | import java.sql.PreparedStatement; 10 | import java.sql.ResultSet; 11 | import java.sql.SQLException; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import javax.imageio.ImageIO; 15 | import net.coobird.thumbnailator.Thumbnails; 16 | import sample.connection.DatabaseConnection; 17 | import sample.model.ModelEmployee; 18 | import sample.model.ModelPositions; 19 | import sample.model.other.ModelProfile; 20 | 21 | /** 22 | * 23 | * @author RAVEN 24 | */ 25 | public class ServiceEmployee { 26 | 27 | public List getAll() throws SQLException { 28 | Connection con = null; 29 | PreparedStatement p = null; 30 | ResultSet r = null; 31 | try { 32 | con = DatabaseConnection.getInstance().createConnection(); 33 | p = con.prepareStatement("select * from employee join positions using (positions_id) order by positions_name, employee_name"); 34 | r = p.executeQuery(); 35 | List list = new ArrayList<>(); 36 | while (r.next()) { 37 | int employeeId = r.getInt("employee_id"); 38 | String name = r.getString("employee_name"); 39 | String location = r.getString("location"); 40 | Date date = r.getDate("date"); 41 | double salary = r.getDouble("salary"); 42 | String description = r.getString("description"); 43 | int positionId = r.getInt("positions_id"); 44 | String positionsName = r.getString("positions_name"); 45 | ModelProfile profile = new ModelProfile(r.getBytes("profile")); 46 | list.add(new ModelEmployee(employeeId, name, location, date, salary, description, profile, new ModelPositions(positionId, positionsName))); 47 | } 48 | return list; 49 | } finally { 50 | DatabaseConnection.getInstance().close(r, p, con); 51 | } 52 | } 53 | 54 | public List search(String search) throws SQLException { 55 | Connection con = null; 56 | PreparedStatement p = null; 57 | ResultSet r = null; 58 | try { 59 | con = DatabaseConnection.getInstance().createConnection(); 60 | p = con.prepareStatement("select * from employee join positions using (positions_id) where (positions_name like ? or employee_name like ? or description like ? or location like ?) order by positions_name, employee_name"); 61 | p.setString(1, "%" + search + "%"); 62 | p.setString(2, "%" + search + "%"); 63 | p.setString(3, "%" + search + "%"); 64 | p.setString(4, "%" + search + "%"); 65 | r = p.executeQuery(); 66 | List list = new ArrayList<>(); 67 | while (r.next()) { 68 | int employeeId = r.getInt("employee_id"); 69 | String name = r.getString("employee_name"); 70 | String location = r.getString("location"); 71 | Date date = r.getDate("date"); 72 | double salary = r.getDouble("salary"); 73 | String description = r.getString("description"); 74 | int positionId = r.getInt("positions_id"); 75 | String positionsName = r.getString("positions_name"); 76 | ModelProfile profile = new ModelProfile(r.getBytes("profile")); 77 | list.add(new ModelEmployee(employeeId, name, location, date, salary, description, profile, new ModelPositions(positionId, positionsName))); 78 | } 79 | return list; 80 | } finally { 81 | DatabaseConnection.getInstance().close(r, p, con); 82 | } 83 | } 84 | 85 | public void create(ModelEmployee data) throws SQLException, IOException { 86 | Connection con = null; 87 | PreparedStatement p = null; 88 | try { 89 | con = DatabaseConnection.getInstance().createConnection(); 90 | p = con.prepareStatement("insert into employee (employee_name, location, date, salary, description, positions_id, profile) values (?,?,?,?,?,?,?)"); 91 | p.setString(1, data.getName()); 92 | p.setString(2, data.getLocation()); 93 | p.setDate(3, data.getDate()); 94 | p.setDouble(4, data.getSalary()); 95 | p.setString(5, data.getDescription()); 96 | p.setInt(6, data.getPositions().getPositionsId()); 97 | if (data.getProfile() != null) { 98 | p.setBytes(7, getByteImage(data.getProfile().getPath())); 99 | } else { 100 | p.setBytes(7, null); 101 | } 102 | p.execute(); 103 | } finally { 104 | DatabaseConnection.getInstance().close(p, con); 105 | } 106 | } 107 | 108 | public void edit(ModelEmployee data) throws SQLException, IOException { 109 | Connection con = null; 110 | PreparedStatement p = null; 111 | try { 112 | boolean isEditProfile = data.getProfile() == null || data.getProfile().getPath() != null; 113 | String sql = isEditProfile ? "update employee set employee_name=?, location=?, date=?, salary=?, description=?, positions_id=?, profile=? where employee_id=? limit 1" 114 | : "update employee set employee_name=?, location=?, date=?, salary=?, description=?, positions_id=? where employee_id=? limit 1"; 115 | con = DatabaseConnection.getInstance().createConnection(); 116 | p = con.prepareStatement(sql); 117 | p.setString(1, data.getName()); 118 | p.setString(2, data.getLocation()); 119 | p.setDate(3, data.getDate()); 120 | p.setDouble(4, data.getSalary()); 121 | p.setString(5, data.getDescription()); 122 | p.setInt(6, data.getPositions().getPositionsId()); 123 | if (isEditProfile) { 124 | if (data.getProfile() != null) { 125 | p.setBytes(7, getByteImage(data.getProfile().getPath())); 126 | } else { 127 | p.setBytes(7, null); 128 | } 129 | p.setInt(8, data.getEmployeeId()); 130 | } else { 131 | p.setInt(7, data.getEmployeeId()); 132 | } 133 | 134 | p.execute(); 135 | } finally { 136 | DatabaseConnection.getInstance().close(p, con); 137 | } 138 | } 139 | 140 | public void delete(int id) throws SQLException { 141 | Connection con = null; 142 | PreparedStatement p = null; 143 | try { 144 | con = DatabaseConnection.getInstance().createConnection(); 145 | p = con.prepareStatement("delete from employee where employee_id=? limit 1"); 146 | p.setInt(1, id); 147 | p.execute(); 148 | } finally { 149 | DatabaseConnection.getInstance().close(p, con); 150 | } 151 | } 152 | 153 | public ServicePositions getServicePositions() { 154 | if (servicePositions == null) { 155 | servicePositions = new ServicePositions(); 156 | } 157 | return servicePositions; 158 | } 159 | 160 | private byte[] getByteImage(File file) throws IOException { 161 | BufferedImage image = Thumbnails.of(file) 162 | .width(500) 163 | .outputQuality(0.7f) 164 | .asBufferedImage(); 165 | ByteArrayOutputStream out = null; 166 | try { 167 | out = new ByteArrayOutputStream(); 168 | ImageIO.write(image, "jpg", out); 169 | byte[] data = out.toByteArray(); 170 | return data; 171 | } finally { 172 | if (out != null) { 173 | out.close(); 174 | } 175 | } 176 | } 177 | 178 | private ServicePositions servicePositions; 179 | } 180 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/service/ServiceEmployee.java: -------------------------------------------------------------------------------- 1 | package sample.service; 2 | 3 | import java.awt.image.BufferedImage; 4 | import java.io.ByteArrayOutputStream; 5 | import java.io.File; 6 | import java.io.IOException; 7 | import java.sql.Connection; 8 | import java.sql.Date; 9 | import java.sql.PreparedStatement; 10 | import java.sql.ResultSet; 11 | import java.sql.SQLException; 12 | import java.util.ArrayList; 13 | import java.util.List; 14 | import javax.imageio.ImageIO; 15 | import net.coobird.thumbnailator.Thumbnails; 16 | import sample.connection.DatabaseConnection; 17 | import sample.model.ModelEmployee; 18 | import sample.model.ModelPositions; 19 | import sample.model.other.ModelProfile; 20 | 21 | /** 22 | * 23 | * @author RAVEN 24 | */ 25 | public class ServiceEmployee { 26 | 27 | public List getAll() throws SQLException { 28 | Connection con = null; 29 | PreparedStatement p = null; 30 | ResultSet r = null; 31 | try { 32 | con = DatabaseConnection.getInstance().createConnection(); 33 | p = con.prepareStatement("select * from employee join positions using (positions_id) order by positions_name, employee_name"); 34 | r = p.executeQuery(); 35 | List list = new ArrayList<>(); 36 | while (r.next()) { 37 | int employeeId = r.getInt("employee_id"); 38 | String name = r.getString("employee_name"); 39 | String location = r.getString("location"); 40 | Date date = r.getDate("date"); 41 | double salary = r.getDouble("salary"); 42 | String description = r.getString("description"); 43 | int positionId = r.getInt("positions_id"); 44 | String positionsName = r.getString("positions_name"); 45 | ModelProfile profile = new ModelProfile(r.getBytes("profile")); 46 | list.add(new ModelEmployee(employeeId, name, location, date, salary, description, profile, new ModelPositions(positionId, positionsName))); 47 | } 48 | return list; 49 | } finally { 50 | DatabaseConnection.getInstance().close(r, p, con); 51 | } 52 | } 53 | 54 | public List search(String search) throws SQLException { 55 | Connection con = null; 56 | PreparedStatement p = null; 57 | ResultSet r = null; 58 | try { 59 | con = DatabaseConnection.getInstance().createConnection(); 60 | p = con.prepareStatement("select * from employee join positions using (positions_id) where (positions_name like ? or employee_name like ? or description like ? or location like ?) order by positions_name, employee_name"); 61 | p.setString(1, "%" + search + "%"); 62 | p.setString(2, "%" + search + "%"); 63 | p.setString(3, "%" + search + "%"); 64 | p.setString(4, "%" + search + "%"); 65 | r = p.executeQuery(); 66 | List list = new ArrayList<>(); 67 | while (r.next()) { 68 | int employeeId = r.getInt("employee_id"); 69 | String name = r.getString("employee_name"); 70 | String location = r.getString("location"); 71 | Date date = r.getDate("date"); 72 | double salary = r.getDouble("salary"); 73 | String description = r.getString("description"); 74 | int positionId = r.getInt("positions_id"); 75 | String positionsName = r.getString("positions_name"); 76 | ModelProfile profile = new ModelProfile(r.getBytes("profile")); 77 | list.add(new ModelEmployee(employeeId, name, location, date, salary, description, profile, new ModelPositions(positionId, positionsName))); 78 | } 79 | return list; 80 | } finally { 81 | DatabaseConnection.getInstance().close(r, p, con); 82 | } 83 | } 84 | 85 | public void create(ModelEmployee data) throws SQLException, IOException { 86 | Connection con = null; 87 | PreparedStatement p = null; 88 | try { 89 | con = DatabaseConnection.getInstance().createConnection(); 90 | p = con.prepareStatement("insert into employee (employee_name, location, date, salary, description, positions_id, profile) values (?,?,?,?,?,?,?)"); 91 | p.setString(1, data.getName()); 92 | p.setString(2, data.getLocation()); 93 | p.setDate(3, data.getDate()); 94 | p.setDouble(4, data.getSalary()); 95 | p.setString(5, data.getDescription()); 96 | p.setInt(6, data.getPositions().getPositionsId()); 97 | if (data.getProfile() != null) { 98 | p.setBytes(7, getByteImage(data.getProfile().getPath())); 99 | } else { 100 | p.setBytes(7, null); 101 | } 102 | p.execute(); 103 | } finally { 104 | DatabaseConnection.getInstance().close(p, con); 105 | } 106 | } 107 | 108 | public void edit(ModelEmployee data) throws SQLException, IOException { 109 | Connection con = null; 110 | PreparedStatement p = null; 111 | try { 112 | boolean isEditProfile = data.getProfile() == null || data.getProfile().getPath() != null; 113 | String sql = isEditProfile ? "update employee set employee_name=?, location=?, date=?, salary=?, description=?, positions_id=?, profile=? where employee_id=? limit 1" 114 | : "update employee set employee_name=?, location=?, date=?, salary=?, description=?, positions_id=? where employee_id=? limit 1"; 115 | con = DatabaseConnection.getInstance().createConnection(); 116 | p = con.prepareStatement(sql); 117 | p.setString(1, data.getName()); 118 | p.setString(2, data.getLocation()); 119 | p.setDate(3, data.getDate()); 120 | p.setDouble(4, data.getSalary()); 121 | p.setString(5, data.getDescription()); 122 | p.setInt(6, data.getPositions().getPositionsId()); 123 | if (isEditProfile) { 124 | if (data.getProfile() != null) { 125 | p.setBytes(7, getByteImage(data.getProfile().getPath())); 126 | } else { 127 | p.setBytes(7, null); 128 | } 129 | p.setInt(8, data.getEmployeeId()); 130 | } else { 131 | p.setInt(7, data.getEmployeeId()); 132 | } 133 | 134 | p.execute(); 135 | } finally { 136 | DatabaseConnection.getInstance().close(p, con); 137 | } 138 | } 139 | 140 | public void delete(int id) throws SQLException { 141 | Connection con = null; 142 | PreparedStatement p = null; 143 | try { 144 | con = DatabaseConnection.getInstance().createConnection(); 145 | p = con.prepareStatement("delete from employee where employee_id=? limit 1"); 146 | p.setInt(1, id); 147 | p.execute(); 148 | } finally { 149 | DatabaseConnection.getInstance().close(p, con); 150 | } 151 | } 152 | 153 | public ServicePositions getServicePositions() { 154 | if (servicePositions == null) { 155 | servicePositions = new ServicePositions(); 156 | } 157 | return servicePositions; 158 | } 159 | 160 | private byte[] getByteImage(File file) throws IOException { 161 | BufferedImage image = Thumbnails.of(file) 162 | .width(500) 163 | .outputQuality(0.7f) 164 | .asBufferedImage(); 165 | ByteArrayOutputStream out = null; 166 | try { 167 | out = new ByteArrayOutputStream(); 168 | ImageIO.write(image, "jpg", out); 169 | byte[] data = out.toByteArray(); 170 | return data; 171 | } finally { 172 | if (out != null) { 173 | out.close(); 174 | } 175 | } 176 | } 177 | 178 | private ServicePositions servicePositions; 179 | } 180 | -------------------------------------------------------------------------------- /sample-form/src/sample/form/Main.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 |
117 |
118 | 119 | 120 | 121 | 122 | <Editor/> 123 | <Renderer/> 124 | </Column> 125 | <Column maxWidth="40" minWidth="-1" prefWidth="-1" resizable="true"> 126 | <Title/> 127 | <Editor/> 128 | <Renderer/> 129 | </Column> 130 | <Column maxWidth="-1" minWidth="-1" prefWidth="200" resizable="true"> 131 | <Title/> 132 | <Editor/> 133 | <Renderer/> 134 | </Column> 135 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 136 | <Title/> 137 | <Editor/> 138 | <Renderer/> 139 | </Column> 140 | <Column maxWidth="-1" minWidth="-1" prefWidth="50" resizable="true"> 141 | <Title/> 142 | <Editor/> 143 | <Renderer/> 144 | </Column> 145 | <Column maxWidth="-1" minWidth="-1" prefWidth="150" resizable="true"> 146 | <Title/> 147 | <Editor/> 148 | <Renderer/> 149 | </Column> 150 | <Column maxWidth="-1" minWidth="-1" prefWidth="150" resizable="true"> 151 | <Title/> 152 | <Editor/> 153 | <Renderer/> 154 | </Column> 155 | </TableColumnModel> 156 | </Property> 157 | <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> 158 | <TableHeader reorderingAllowed="false" resizingAllowed="true"/> 159 | </Property> 160 | </Properties> 161 | </Component> 162 | </SubComponents> 163 | </Container> 164 | <Component class="javax.swing.JSeparator" name="jSeparator1"> 165 | </Component> 166 | <Component class="javax.swing.JTextField" name="txtSearch"> 167 | <Events> 168 | <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtSearchKeyReleased"/> 169 | </Events> 170 | </Component> 171 | <Component class="javax.swing.JLabel" name="lbTitle"> 172 | <Properties> 173 | <Property name="text" type="java.lang.String" value="EMPLOYEE"/> 174 | </Properties> 175 | </Component> 176 | <Component class="sample.swing.ButtonAction" name="cmdDelete"> 177 | <Properties> 178 | <Property name="text" type="java.lang.String" value="Delete"/> 179 | </Properties> 180 | <Events> 181 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdDeleteActionPerformed"/> 182 | </Events> 183 | </Component> 184 | <Component class="sample.swing.ButtonAction" name="cmdEdit"> 185 | <Properties> 186 | <Property name="text" type="java.lang.String" value="Edit"/> 187 | </Properties> 188 | <Events> 189 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdEditActionPerformed"/> 190 | </Events> 191 | </Component> 192 | <Component class="sample.swing.ButtonAction" name="cmdNew"> 193 | <Properties> 194 | <Property name="text" type="java.lang.String" value="New"/> 195 | </Properties> 196 | <Events> 197 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdNewActionPerformed"/> 198 | </Events> 199 | </Component> 200 | </SubComponents> 201 | </Container> 202 | </SubComponents> 203 | </Form> 204 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/form/Main.form: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8" ?> 2 | 3 | <Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> 4 | <Properties> 5 | <Property name="defaultCloseOperation" type="int" value="3"/> 6 | </Properties> 7 | <SyntheticProperties> 8 | <SyntheticProperty name="formSizePolicy" type="int" value="1"/> 9 | <SyntheticProperty name="generateCenter" type="boolean" value="true"/> 10 | </SyntheticProperties> 11 | <AuxValues> 12 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> 13 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> 14 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> 15 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> 16 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> 17 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> 18 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> 19 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> 20 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> 21 | </AuxValues> 22 | 23 | <Layout> 24 | <DimensionLayout dim="0"> 25 | <Group type="103" groupAlignment="0" attributes="0"> 26 | <Group type="102" alignment="0" attributes="0"> 27 | <EmptySpace min="-2" pref="52" max="-2" attributes="0"/> 28 | <Component id="panel" max="32767" attributes="0"/> 29 | <EmptySpace min="-2" pref="38" max="-2" attributes="0"/> 30 | </Group> 31 | </Group> 32 | </DimensionLayout> 33 | <DimensionLayout dim="1"> 34 | <Group type="103" groupAlignment="0" attributes="0"> 35 | <Group type="102" alignment="0" attributes="0"> 36 | <EmptySpace min="-2" pref="47" max="-2" attributes="0"/> 37 | <Component id="panel" max="32767" attributes="0"/> 38 | <EmptySpace min="-2" pref="40" max="-2" attributes="0"/> 39 | </Group> 40 | </Group> 41 | </DimensionLayout> 42 | </Layout> 43 | <SubComponents> 44 | <Container class="javax.swing.JPanel" name="panel"> 45 | 46 | <Layout> 47 | <DimensionLayout dim="0"> 48 | <Group type="103" groupAlignment="0" attributes="0"> 49 | <Component id="scroll" alignment="0" pref="1190" max="32767" attributes="0"/> 50 | <Component id="jSeparator1" alignment="0" max="32767" attributes="0"/> 51 | <Group type="102" alignment="0" attributes="0"> 52 | <EmptySpace min="-2" pref="20" max="-2" attributes="0"/> 53 | <Group type="103" groupAlignment="0" attributes="0"> 54 | <Group type="102" attributes="0"> 55 | <Component id="txtSearch" min="-2" pref="239" max="-2" attributes="0"/> 56 | <EmptySpace max="32767" attributes="0"/> 57 | <Component id="cmdNew" min="-2" pref="101" max="-2" attributes="0"/> 58 | <EmptySpace max="-2" attributes="0"/> 59 | <Component id="cmdEdit" min="-2" pref="101" max="-2" attributes="0"/> 60 | <EmptySpace max="-2" attributes="0"/> 61 | <Component id="cmdDelete" min="-2" pref="101" max="-2" attributes="0"/> 62 | </Group> 63 | <Component id="lbTitle" min="-2" max="-2" attributes="0"/> 64 | </Group> 65 | <EmptySpace min="-2" pref="20" max="-2" attributes="0"/> 66 | </Group> 67 | </Group> 68 | </DimensionLayout> 69 | <DimensionLayout dim="1"> 70 | <Group type="103" groupAlignment="0" attributes="0"> 71 | <Group type="102" alignment="1" attributes="0"> 72 | <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> 73 | <Component id="lbTitle" min="-2" max="-2" attributes="0"/> 74 | <EmptySpace max="-2" attributes="0"/> 75 | <Group type="103" groupAlignment="3" attributes="0"> 76 | <Component id="txtSearch" alignment="3" min="-2" max="-2" attributes="0"/> 77 | <Component id="cmdDelete" alignment="3" min="-2" max="-2" attributes="0"/> 78 | <Component id="cmdEdit" alignment="3" min="-2" max="-2" attributes="0"/> 79 | <Component id="cmdNew" alignment="3" min="-2" max="-2" attributes="0"/> 80 | </Group> 81 | <EmptySpace type="unrelated" max="-2" attributes="0"/> 82 | <Component id="jSeparator1" min="-2" max="-2" attributes="0"/> 83 | <EmptySpace min="0" pref="0" max="-2" attributes="0"/> 84 | <Component id="scroll" pref="528" max="32767" attributes="0"/> 85 | <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> 86 | </Group> 87 | </Group> 88 | </DimensionLayout> 89 | </Layout> 90 | <SubComponents> 91 | <Container class="javax.swing.JScrollPane" name="scroll"> 92 | <Properties> 93 | <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> 94 | <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> 95 | <EmptyBorder bottom="0" left="0" right="0" top="0"/> 96 | </Border> 97 | </Property> 98 | </Properties> 99 | <AuxValues> 100 | <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> 101 | </AuxValues> 102 | 103 | <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> 104 | <SubComponents> 105 | <Component class="javax.swing.JTable" name="table"> 106 | <Properties> 107 | <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> 108 | <Table columnCount="7" rowCount="0"> 109 | <Column editable="true" title="SELECT" type="java.lang.Boolean"/> 110 | <Column editable="false" title="#" type="java.lang.Object"/> 111 | <Column editable="false" title="NAME" type="java.lang.Object"/> 112 | <Column editable="false" title="DATE" type="java.lang.Object"/> 113 | <Column editable="false" title="SALARY" type="java.lang.Object"/> 114 | <Column editable="false" title="POSITIONS" type="java.lang.Object"/> 115 | <Column editable="false" title="DESCRIPTION" type="java.lang.Object"/> 116 | </Table> 117 | </Property> 118 | <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> 119 | <TableColumnModel selectionModel="0"> 120 | <Column maxWidth="50" minWidth="-1" prefWidth="-1" resizable="true"> 121 | <Title/> 122 | <Editor/> 123 | <Renderer/> 124 | </Column> 125 | <Column maxWidth="40" minWidth="-1" prefWidth="-1" resizable="true"> 126 | <Title/> 127 | <Editor/> 128 | <Renderer/> 129 | </Column> 130 | <Column maxWidth="-1" minWidth="-1" prefWidth="200" resizable="true"> 131 | <Title/> 132 | <Editor/> 133 | <Renderer/> 134 | </Column> 135 | <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> 136 | <Title/> 137 | <Editor/> 138 | <Renderer/> 139 | </Column> 140 | <Column maxWidth="-1" minWidth="-1" prefWidth="50" resizable="true"> 141 | <Title/> 142 | <Editor/> 143 | <Renderer/> 144 | </Column> 145 | <Column maxWidth="-1" minWidth="-1" prefWidth="150" resizable="true"> 146 | <Title/> 147 | <Editor/> 148 | <Renderer/> 149 | </Column> 150 | <Column maxWidth="-1" minWidth="-1" prefWidth="150" resizable="true"> 151 | <Title/> 152 | <Editor/> 153 | <Renderer/> 154 | </Column> 155 | </TableColumnModel> 156 | </Property> 157 | <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> 158 | <TableHeader reorderingAllowed="false" resizingAllowed="true"/> 159 | </Property> 160 | </Properties> 161 | </Component> 162 | </SubComponents> 163 | </Container> 164 | <Component class="javax.swing.JSeparator" name="jSeparator1"> 165 | </Component> 166 | <Component class="javax.swing.JTextField" name="txtSearch"> 167 | <Events> 168 | <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="txtSearchKeyReleased"/> 169 | </Events> 170 | </Component> 171 | <Component class="javax.swing.JLabel" name="lbTitle"> 172 | <Properties> 173 | <Property name="text" type="java.lang.String" value="EMPLOYEE"/> 174 | </Properties> 175 | </Component> 176 | <Component class="sample.swing.ButtonAction" name="cmdDelete"> 177 | <Properties> 178 | <Property name="text" type="java.lang.String" value="Delete"/> 179 | </Properties> 180 | <Events> 181 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdDeleteActionPerformed"/> 182 | </Events> 183 | </Component> 184 | <Component class="sample.swing.ButtonAction" name="cmdEdit"> 185 | <Properties> 186 | <Property name="text" type="java.lang.String" value="Edit"/> 187 | </Properties> 188 | <Events> 189 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdEditActionPerformed"/> 190 | </Events> 191 | </Component> 192 | <Component class="sample.swing.ButtonAction" name="cmdNew"> 193 | <Properties> 194 | <Property name="text" type="java.lang.String" value="New"/> 195 | </Properties> 196 | <Events> 197 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdNewActionPerformed"/> 198 | </Events> 199 | </Component> 200 | </SubComponents> 201 | </Container> 202 | </SubComponents> 203 | </Form> 204 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/form/Create.form: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8" ?> 2 | 3 | <Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> 4 | <NonVisualComponents> 5 | <Component class="raven.datetime.component.date.DatePicker" name="datePicker"> 6 | </Component> 7 | </NonVisualComponents> 8 | <AuxValues> 9 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> 10 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> 11 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> 12 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> 13 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> 14 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> 15 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> 16 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> 17 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> 18 | </AuxValues> 19 | 20 | <Layout> 21 | <DimensionLayout dim="0"> 22 | <Group type="103" groupAlignment="0" attributes="0"> 23 | <Group type="102" attributes="0"> 24 | <EmptySpace max="-2" attributes="0"/> 25 | <Group type="103" groupAlignment="0" max="-2" attributes="0"> 26 | <Component id="jLabel1" alignment="0" pref="100" max="32767" attributes="0"/> 27 | <Component id="jLabel2" pref="100" max="32767" attributes="0"/> 28 | <Component id="jLabel3" alignment="0" pref="100" max="32767" attributes="0"/> 29 | <Component id="jLabel4" alignment="0" pref="100" max="32767" attributes="0"/> 30 | <Component id="jLabel5" alignment="0" pref="100" max="32767" attributes="0"/> 31 | <Component id="jLabel7" alignment="0" pref="100" max="32767" attributes="0"/> 32 | <Component id="jLabel6" alignment="0" max="32767" attributes="0"/> 33 | </Group> 34 | <Group type="103" groupAlignment="0" attributes="0"> 35 | <Group type="102" attributes="0"> 36 | <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> 37 | <Group type="103" groupAlignment="0" attributes="0"> 38 | <Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/> 39 | <Component id="comboPosition" alignment="0" max="32767" attributes="0"/> 40 | <Component id="txtSalary" alignment="0" max="32767" attributes="0"/> 41 | <Component id="txtDate" alignment="0" max="32767" attributes="0"/> 42 | <Component id="txtLocation" alignment="0" max="32767" attributes="0"/> 43 | <Component id="txtName" alignment="0" max="32767" attributes="0"/> 44 | </Group> 45 | </Group> 46 | <Group type="102" attributes="0"> 47 | <EmptySpace type="unrelated" max="-2" attributes="0"/> 48 | <Component id="panelPic" max="32767" attributes="0"/> 49 | </Group> 50 | </Group> 51 | <EmptySpace min="-2" pref="30" max="-2" attributes="0"/> 52 | </Group> 53 | </Group> 54 | </DimensionLayout> 55 | <DimensionLayout dim="1"> 56 | <Group type="103" groupAlignment="0" attributes="0"> 57 | <Group type="102" alignment="0" attributes="0"> 58 | <EmptySpace min="-2" pref="20" max="-2" attributes="0"/> 59 | <Group type="103" groupAlignment="3" attributes="0"> 60 | <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> 61 | <Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/> 62 | </Group> 63 | <EmptySpace max="-2" attributes="0"/> 64 | <Group type="103" groupAlignment="3" attributes="0"> 65 | <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> 66 | <Component id="txtLocation" alignment="3" min="-2" max="-2" attributes="0"/> 67 | </Group> 68 | <EmptySpace max="-2" attributes="0"/> 69 | <Group type="103" groupAlignment="3" attributes="0"> 70 | <Component id="txtDate" alignment="3" min="-2" max="-2" attributes="0"/> 71 | <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> 72 | </Group> 73 | <EmptySpace max="-2" attributes="0"/> 74 | <Group type="103" groupAlignment="3" attributes="0"> 75 | <Component id="txtSalary" alignment="3" min="-2" max="-2" attributes="0"/> 76 | <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> 77 | </Group> 78 | <EmptySpace max="-2" attributes="0"/> 79 | <Group type="103" groupAlignment="3" attributes="0"> 80 | <Component id="comboPosition" alignment="3" min="-2" max="-2" attributes="0"/> 81 | <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> 82 | </Group> 83 | <EmptySpace max="-2" attributes="0"/> 84 | <Group type="103" groupAlignment="0" attributes="0"> 85 | <Component id="jLabel7" min="-2" pref="31" max="-2" attributes="0"/> 86 | <Component id="panelPic" min="-2" pref="150" max="-2" attributes="0"/> 87 | </Group> 88 | <EmptySpace max="-2" attributes="0"/> 89 | <Group type="103" groupAlignment="0" attributes="0"> 90 | <Component id="jLabel6" min="-2" pref="31" max="-2" attributes="0"/> 91 | <Component id="jScrollPane1" min="-2" pref="150" max="-2" attributes="0"/> 92 | </Group> 93 | <EmptySpace max="-2" attributes="0"/> 94 | </Group> 95 | </Group> 96 | </DimensionLayout> 97 | </Layout> 98 | <SubComponents> 99 | <Component class="javax.swing.JLabel" name="jLabel1"> 100 | <Properties> 101 | <Property name="horizontalAlignment" type="int" value="11"/> 102 | <Property name="text" type="java.lang.String" value="Name"/> 103 | </Properties> 104 | </Component> 105 | <Component class="javax.swing.JTextField" name="txtName"> 106 | </Component> 107 | <Component class="javax.swing.JLabel" name="jLabel2"> 108 | <Properties> 109 | <Property name="horizontalAlignment" type="int" value="11"/> 110 | <Property name="text" type="java.lang.String" value="Location"/> 111 | </Properties> 112 | </Component> 113 | <Component class="javax.swing.JTextField" name="txtLocation"> 114 | </Component> 115 | <Component class="javax.swing.JLabel" name="jLabel3"> 116 | <Properties> 117 | <Property name="horizontalAlignment" type="int" value="11"/> 118 | <Property name="text" type="java.lang.String" value="Date"/> 119 | </Properties> 120 | </Component> 121 | <Component class="javax.swing.JFormattedTextField" name="txtDate"> 122 | </Component> 123 | <Component class="javax.swing.JLabel" name="jLabel4"> 124 | <Properties> 125 | <Property name="horizontalAlignment" type="int" value="11"/> 126 | <Property name="text" type="java.lang.String" value="Salary"/> 127 | </Properties> 128 | </Component> 129 | <Component class="javax.swing.JFormattedTextField" name="txtSalary"> 130 | <Properties> 131 | <Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor"> 132 | <Format format="#,##0.##" subtype="-1" type="0"/> 133 | </Property> 134 | </Properties> 135 | </Component> 136 | <Component class="javax.swing.JLabel" name="jLabel5"> 137 | <Properties> 138 | <Property name="horizontalAlignment" type="int" value="11"/> 139 | <Property name="text" type="java.lang.String" value="Position"/> 140 | </Properties> 141 | </Component> 142 | <Component class="javax.swing.JComboBox" name="comboPosition"> 143 | <Properties> 144 | <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> 145 | <StringArray count="0"/> 146 | </Property> 147 | </Properties> 148 | <AuxValues> 149 | <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<Object>"/> 150 | </AuxValues> 151 | </Component> 152 | <Component class="javax.swing.JLabel" name="jLabel6"> 153 | <Properties> 154 | <Property name="horizontalAlignment" type="int" value="11"/> 155 | <Property name="text" type="java.lang.String" value="Description"/> 156 | </Properties> 157 | </Component> 158 | <Container class="javax.swing.JScrollPane" name="jScrollPane1"> 159 | <AuxValues> 160 | <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> 161 | </AuxValues> 162 | 163 | <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> 164 | <SubComponents> 165 | <Component class="javax.swing.JTextArea" name="txtDescription"> 166 | <Properties> 167 | <Property name="columns" type="int" value="20"/> 168 | <Property name="lineWrap" type="boolean" value="true"/> 169 | <Property name="rows" type="int" value="5"/> 170 | <Property name="wrapStyleWord" type="boolean" value="true"/> 171 | </Properties> 172 | </Component> 173 | </SubComponents> 174 | </Container> 175 | <Component class="javax.swing.JLabel" name="jLabel7"> 176 | <Properties> 177 | <Property name="horizontalAlignment" type="int" value="11"/> 178 | <Property name="text" type="java.lang.String" value="Position"/> 179 | </Properties> 180 | </Component> 181 | <Container class="javax.swing.JPanel" name="panelPic"> 182 | 183 | <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> 184 | <SubComponents> 185 | <Container class="javaswingdev.picturebox.PictureBox" name="pic"> 186 | <Constraints> 187 | <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> 188 | <BorderConstraints direction="Center"/> 189 | </Constraint> 190 | </Constraints> 191 | 192 | <Layout> 193 | <DimensionLayout dim="0"> 194 | <Group type="103" groupAlignment="0" attributes="0"> 195 | <Group type="102" alignment="1" attributes="0"> 196 | <EmptySpace pref="222" max="32767" attributes="0"/> 197 | <Component id="jToolBar1" min="-2" max="-2" attributes="0"/> 198 | <EmptySpace max="-2" attributes="0"/> 199 | </Group> 200 | </Group> 201 | </DimensionLayout> 202 | <DimensionLayout dim="1"> 203 | <Group type="103" groupAlignment="0" attributes="0"> 204 | <Group type="102" alignment="0" attributes="0"> 205 | <EmptySpace max="-2" attributes="0"/> 206 | <Component id="jToolBar1" min="-2" pref="25" max="-2" attributes="0"/> 207 | <EmptySpace pref="119" max="32767" attributes="0"/> 208 | </Group> 209 | </Group> 210 | </DimensionLayout> 211 | </Layout> 212 | <SubComponents> 213 | <Container class="javax.swing.JToolBar" name="jToolBar1"> 214 | <Properties> 215 | <Property name="rollover" type="boolean" value="true"/> 216 | <Property name="opaque" type="boolean" value="false"/> 217 | </Properties> 218 | 219 | <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> 220 | <SubComponents> 221 | <Component class="javax.swing.JButton" name="cmdBrowse"> 222 | <Properties> 223 | <Property name="text" type="java.lang.String" value="Browse"/> 224 | <Property name="focusable" type="boolean" value="false"/> 225 | <Property name="horizontalTextPosition" type="int" value="0"/> 226 | <Property name="verticalTextPosition" type="int" value="3"/> 227 | </Properties> 228 | <Events> 229 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdBrowseActionPerformed"/> 230 | </Events> 231 | </Component> 232 | <Component class="javax.swing.JButton" name="cmdDelete"> 233 | <Properties> 234 | <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> 235 | <Color blue="0" green="0" red="ff" type="rgb"/> 236 | </Property> 237 | <Property name="text" type="java.lang.String" value="Delete"/> 238 | <Property name="focusable" type="boolean" value="false"/> 239 | <Property name="horizontalTextPosition" type="int" value="0"/> 240 | <Property name="verticalTextPosition" type="int" value="3"/> 241 | </Properties> 242 | <Events> 243 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdDeleteActionPerformed"/> 244 | </Events> 245 | </Component> 246 | </SubComponents> 247 | </Container> 248 | </SubComponents> 249 | </Container> 250 | </SubComponents> 251 | </Container> 252 | </SubComponents> 253 | </Form> 254 | -------------------------------------------------------------------------------- /sample-form/src/sample/form/Create.form: -------------------------------------------------------------------------------- 1 | <?xml version="1.0" encoding="UTF-8" ?> 2 | 3 | <Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> 4 | <NonVisualComponents> 5 | <Component class="raven.datetime.component.date.DatePicker" name="datePicker"> 6 | </Component> 7 | </NonVisualComponents> 8 | <AuxValues> 9 | <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> 10 | <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> 11 | <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> 12 | <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> 13 | <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> 14 | <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> 15 | <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> 16 | <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> 17 | <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> 18 | </AuxValues> 19 | 20 | <Layout> 21 | <DimensionLayout dim="0"> 22 | <Group type="103" groupAlignment="0" attributes="0"> 23 | <Group type="102" attributes="0"> 24 | <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> 25 | <Group type="103" groupAlignment="0" attributes="0"> 26 | <Component id="jLabel1" alignment="0" min="-2" pref="100" max="-2" attributes="0"/> 27 | <Component id="jLabel2" min="-2" pref="100" max="-2" attributes="0"/> 28 | <Component id="jLabel3" alignment="0" min="-2" pref="100" max="-2" attributes="0"/> 29 | <Component id="jLabel4" alignment="0" min="-2" pref="100" max="-2" attributes="0"/> 30 | <Component id="jLabel5" alignment="0" min="-2" pref="100" max="-2" attributes="0"/> 31 | <Component id="jLabel6" alignment="0" min="-2" pref="100" max="-2" attributes="0"/> 32 | <Component id="jLabel7" alignment="1" min="-2" pref="100" max="-2" attributes="0"/> 33 | </Group> 34 | <Group type="103" groupAlignment="0" attributes="0"> 35 | <Group type="102" attributes="0"> 36 | <EmptySpace min="-2" pref="10" max="-2" attributes="0"/> 37 | <Group type="103" groupAlignment="0" attributes="0"> 38 | <Component id="jScrollPane1" alignment="0" max="32767" attributes="0"/> 39 | <Component id="comboPosition" alignment="0" max="32767" attributes="0"/> 40 | <Component id="txtSalary" alignment="0" max="32767" attributes="0"/> 41 | <Component id="txtDate" alignment="0" max="32767" attributes="0"/> 42 | <Component id="txtLocation" alignment="0" max="32767" attributes="0"/> 43 | <Component id="txtName" alignment="0" max="32767" attributes="0"/> 44 | </Group> 45 | </Group> 46 | <Group type="102" attributes="0"> 47 | <EmptySpace type="unrelated" max="-2" attributes="0"/> 48 | <Component id="panelPic" max="32767" attributes="0"/> 49 | </Group> 50 | </Group> 51 | <EmptySpace min="-2" pref="50" max="-2" attributes="0"/> 52 | </Group> 53 | </Group> 54 | </DimensionLayout> 55 | <DimensionLayout dim="1"> 56 | <Group type="103" groupAlignment="0" attributes="0"> 57 | <Group type="102" alignment="0" attributes="0"> 58 | <EmptySpace min="-2" pref="30" max="-2" attributes="0"/> 59 | <Group type="103" groupAlignment="3" attributes="0"> 60 | <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> 61 | <Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/> 62 | </Group> 63 | <EmptySpace max="-2" attributes="0"/> 64 | <Group type="103" groupAlignment="3" attributes="0"> 65 | <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> 66 | <Component id="txtLocation" alignment="3" min="-2" max="-2" attributes="0"/> 67 | </Group> 68 | <EmptySpace max="-2" attributes="0"/> 69 | <Group type="103" groupAlignment="3" attributes="0"> 70 | <Component id="txtDate" alignment="3" min="-2" max="-2" attributes="0"/> 71 | <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> 72 | </Group> 73 | <EmptySpace max="-2" attributes="0"/> 74 | <Group type="103" groupAlignment="3" attributes="0"> 75 | <Component id="txtSalary" alignment="3" min="-2" max="-2" attributes="0"/> 76 | <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> 77 | </Group> 78 | <EmptySpace max="-2" attributes="0"/> 79 | <Group type="103" groupAlignment="3" attributes="0"> 80 | <Component id="comboPosition" alignment="3" min="-2" max="-2" attributes="0"/> 81 | <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> 82 | </Group> 83 | <EmptySpace max="-2" attributes="0"/> 84 | <Group type="103" groupAlignment="0" attributes="0"> 85 | <Component id="jLabel7" min="-2" pref="31" max="-2" attributes="0"/> 86 | <Component id="panelPic" min="-2" pref="150" max="-2" attributes="0"/> 87 | </Group> 88 | <EmptySpace max="-2" attributes="0"/> 89 | <Group type="103" groupAlignment="0" attributes="0"> 90 | <Component id="jLabel6" min="-2" pref="31" max="-2" attributes="0"/> 91 | <Component id="jScrollPane1" min="-2" pref="150" max="-2" attributes="0"/> 92 | </Group> 93 | <EmptySpace pref="16" max="32767" attributes="0"/> 94 | </Group> 95 | </Group> 96 | </DimensionLayout> 97 | </Layout> 98 | <SubComponents> 99 | <Component class="javax.swing.JLabel" name="jLabel1"> 100 | <Properties> 101 | <Property name="horizontalAlignment" type="int" value="11"/> 102 | <Property name="text" type="java.lang.String" value="Name"/> 103 | </Properties> 104 | </Component> 105 | <Component class="javax.swing.JTextField" name="txtName"> 106 | </Component> 107 | <Component class="javax.swing.JLabel" name="jLabel2"> 108 | <Properties> 109 | <Property name="horizontalAlignment" type="int" value="11"/> 110 | <Property name="text" type="java.lang.String" value="Location"/> 111 | </Properties> 112 | </Component> 113 | <Component class="javax.swing.JTextField" name="txtLocation"> 114 | </Component> 115 | <Component class="javax.swing.JLabel" name="jLabel3"> 116 | <Properties> 117 | <Property name="horizontalAlignment" type="int" value="11"/> 118 | <Property name="text" type="java.lang.String" value="Date"/> 119 | </Properties> 120 | </Component> 121 | <Component class="javax.swing.JFormattedTextField" name="txtDate"> 122 | </Component> 123 | <Component class="javax.swing.JLabel" name="jLabel4"> 124 | <Properties> 125 | <Property name="horizontalAlignment" type="int" value="11"/> 126 | <Property name="text" type="java.lang.String" value="Salary"/> 127 | </Properties> 128 | </Component> 129 | <Component class="javax.swing.JFormattedTextField" name="txtSalary"> 130 | <Properties> 131 | <Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor"> 132 | <Format format="#,##0.##" subtype="-1" type="0"/> 133 | </Property> 134 | </Properties> 135 | </Component> 136 | <Component class="javax.swing.JLabel" name="jLabel5"> 137 | <Properties> 138 | <Property name="horizontalAlignment" type="int" value="11"/> 139 | <Property name="text" type="java.lang.String" value="Position"/> 140 | </Properties> 141 | </Component> 142 | <Component class="javax.swing.JComboBox" name="comboPosition"> 143 | <Properties> 144 | <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> 145 | <StringArray count="0"/> 146 | </Property> 147 | </Properties> 148 | <AuxValues> 149 | <AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<Object>"/> 150 | </AuxValues> 151 | </Component> 152 | <Component class="javax.swing.JLabel" name="jLabel6"> 153 | <Properties> 154 | <Property name="horizontalAlignment" type="int" value="11"/> 155 | <Property name="text" type="java.lang.String" value="Description"/> 156 | </Properties> 157 | </Component> 158 | <Container class="javax.swing.JScrollPane" name="jScrollPane1"> 159 | <AuxValues> 160 | <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> 161 | </AuxValues> 162 | 163 | <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> 164 | <SubComponents> 165 | <Component class="javax.swing.JTextArea" name="txtDescription"> 166 | <Properties> 167 | <Property name="columns" type="int" value="20"/> 168 | <Property name="lineWrap" type="boolean" value="true"/> 169 | <Property name="rows" type="int" value="5"/> 170 | <Property name="wrapStyleWord" type="boolean" value="true"/> 171 | </Properties> 172 | </Component> 173 | </SubComponents> 174 | </Container> 175 | <Component class="javax.swing.JLabel" name="jLabel7"> 176 | <Properties> 177 | <Property name="horizontalAlignment" type="int" value="11"/> 178 | <Property name="text" type="java.lang.String" value="Position"/> 179 | </Properties> 180 | </Component> 181 | <Container class="javax.swing.JPanel" name="panelPic"> 182 | 183 | <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> 184 | <SubComponents> 185 | <Container class="javaswingdev.picturebox.PictureBox" name="pic"> 186 | <Constraints> 187 | <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> 188 | <BorderConstraints direction="Center"/> 189 | </Constraint> 190 | </Constraints> 191 | 192 | <Layout> 193 | <DimensionLayout dim="0"> 194 | <Group type="103" groupAlignment="0" attributes="0"> 195 | <Group type="102" alignment="1" attributes="0"> 196 | <EmptySpace pref="220" max="32767" attributes="0"/> 197 | <Component id="jToolBar1" min="-2" max="-2" attributes="0"/> 198 | <EmptySpace max="-2" attributes="0"/> 199 | </Group> 200 | </Group> 201 | </DimensionLayout> 202 | <DimensionLayout dim="1"> 203 | <Group type="103" groupAlignment="0" attributes="0"> 204 | <Group type="102" alignment="0" attributes="0"> 205 | <EmptySpace max="-2" attributes="0"/> 206 | <Component id="jToolBar1" min="-2" pref="25" max="-2" attributes="0"/> 207 | <EmptySpace pref="119" max="32767" attributes="0"/> 208 | </Group> 209 | </Group> 210 | </DimensionLayout> 211 | </Layout> 212 | <SubComponents> 213 | <Container class="javax.swing.JToolBar" name="jToolBar1"> 214 | <Properties> 215 | <Property name="rollover" type="boolean" value="true"/> 216 | <Property name="opaque" type="boolean" value="false"/> 217 | </Properties> 218 | 219 | <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBoxLayout"/> 220 | <SubComponents> 221 | <Component class="javax.swing.JButton" name="cmdBrowse"> 222 | <Properties> 223 | <Property name="text" type="java.lang.String" value="Browse"/> 224 | <Property name="focusable" type="boolean" value="false"/> 225 | <Property name="horizontalTextPosition" type="int" value="0"/> 226 | <Property name="verticalTextPosition" type="int" value="3"/> 227 | </Properties> 228 | <Events> 229 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdBrowseActionPerformed"/> 230 | </Events> 231 | </Component> 232 | <Component class="javax.swing.JButton" name="cmdDelete"> 233 | <Properties> 234 | <Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> 235 | <Color blue="0" green="0" red="ff" type="rgb"/> 236 | </Property> 237 | <Property name="text" type="java.lang.String" value="Delete"/> 238 | <Property name="focusable" type="boolean" value="false"/> 239 | <Property name="horizontalTextPosition" type="int" value="0"/> 240 | <Property name="verticalTextPosition" type="int" value="3"/> 241 | </Properties> 242 | <Events> 243 | <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cmdDeleteActionPerformed"/> 244 | </Events> 245 | </Component> 246 | </SubComponents> 247 | </Container> 248 | </SubComponents> 249 | </Container> 250 | </SubComponents> 251 | </Container> 252 | </SubComponents> 253 | </Form> 254 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/form/Create.java: -------------------------------------------------------------------------------- 1 | package sample.form; 2 | 3 | import com.formdev.flatlaf.FlatClientProperties; 4 | import com.formdev.flatlaf.extras.FlatSVGIcon; 5 | import com.formdev.flatlaf.util.UIScale; 6 | import java.awt.Rectangle; 7 | import java.awt.Shape; 8 | import java.io.File; 9 | import java.sql.Date; 10 | import javaswingdev.picturebox.DefaultPictureBoxRender; 11 | import javax.swing.ImageIcon; 12 | import javax.swing.SwingUtilities; 13 | import jnafilechooser.api.JnaFileChooser; 14 | import sample.model.ModelEmployee; 15 | import sample.model.ModelPositions; 16 | import sample.model.other.ModelProfile; 17 | import sample.service.ServiceEmployee; 18 | 19 | /** 20 | * 21 | * @author RAVEN 22 | */ 23 | public class Create extends javax.swing.JPanel { 24 | 25 | /** 26 | * Creates new form Create 27 | */ 28 | public Create() { 29 | initComponents(); 30 | datePicker.setCloseAfterSelected(true); 31 | datePicker.setEditor(txtDate); 32 | pic.setPictureBoxRender(new DefaultPictureBoxRender() { 33 | @Override 34 | public Shape render(Rectangle rectangle) { 35 | return createRound(rectangle, UIScale.scale(10)); 36 | } 37 | }); 38 | pic.setImage(new FlatSVGIcon("sample/icon/profile.svg", 5f)); 39 | panelPic.putClientProperty(FlatClientProperties.STYLE, "" 40 | + "border:0,0,0,0,$Component.borderColor,,10;" 41 | + "background:$TextArea.background"); 42 | } 43 | 44 | public void loadData(ServiceEmployee service, ModelEmployee data) { 45 | try { 46 | for (ModelPositions pos : service.getServicePositions().getAll()) { 47 | comboPosition.addItem(pos); 48 | if (data != null && data.getPositions().getPositionsId() == pos.getPositionsId()) { 49 | comboPosition.setSelectedItem(pos); 50 | } 51 | } 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | } 55 | 56 | if (data != null) { 57 | txtName.setText(data.getName()); 58 | txtLocation.setText(data.getLocation()); 59 | if (data.getDate() != null) { 60 | datePicker.setSelectedDate(data.getDate().toLocalDate()); 61 | } 62 | txtSalary.setValue(data.getSalary()); 63 | txtDescription.setText(data.getDescription()); 64 | profile = new ModelProfile(data.getProfile().getIcon()); 65 | if (profile.getIcon() != null) { 66 | pic.setImage(profile.getIcon()); 67 | } 68 | } 69 | } 70 | 71 | /** 72 | * This method is called from within the constructor to initialize the form. 73 | * WARNING: Do NOT modify this code. The content of this method is always 74 | * regenerated by the Form Editor. 75 | */ 76 | @SuppressWarnings("unchecked") 77 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 78 | private void initComponents() { 79 | 80 | datePicker = new raven.datetime.component.date.DatePicker(); 81 | jLabel1 = new javax.swing.JLabel(); 82 | txtName = new javax.swing.JTextField(); 83 | jLabel2 = new javax.swing.JLabel(); 84 | txtLocation = new javax.swing.JTextField(); 85 | jLabel3 = new javax.swing.JLabel(); 86 | txtDate = new javax.swing.JFormattedTextField(); 87 | jLabel4 = new javax.swing.JLabel(); 88 | txtSalary = new javax.swing.JFormattedTextField(); 89 | jLabel5 = new javax.swing.JLabel(); 90 | comboPosition = new javax.swing.JComboBox<>(); 91 | jLabel6 = new javax.swing.JLabel(); 92 | jScrollPane1 = new javax.swing.JScrollPane(); 93 | txtDescription = new javax.swing.JTextArea(); 94 | jLabel7 = new javax.swing.JLabel(); 95 | panelPic = new javax.swing.JPanel(); 96 | pic = new javaswingdev.picturebox.PictureBox(); 97 | jToolBar1 = new javax.swing.JToolBar(); 98 | cmdBrowse = new javax.swing.JButton(); 99 | cmdDelete = new javax.swing.JButton(); 100 | 101 | jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 102 | jLabel1.setText("Name"); 103 | 104 | jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 105 | jLabel2.setText("Location"); 106 | 107 | jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 108 | jLabel3.setText("Date"); 109 | 110 | jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 111 | jLabel4.setText("Salary"); 112 | 113 | txtSalary.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.##")))); 114 | 115 | jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 116 | jLabel5.setText("Position"); 117 | 118 | jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 119 | jLabel6.setText("Description"); 120 | 121 | txtDescription.setColumns(20); 122 | txtDescription.setLineWrap(true); 123 | txtDescription.setRows(5); 124 | txtDescription.setWrapStyleWord(true); 125 | jScrollPane1.setViewportView(txtDescription); 126 | 127 | jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 128 | jLabel7.setText("Position"); 129 | 130 | panelPic.setLayout(new java.awt.BorderLayout()); 131 | 132 | jToolBar1.setRollover(true); 133 | jToolBar1.setOpaque(false); 134 | 135 | cmdBrowse.setText("Browse"); 136 | cmdBrowse.setFocusable(false); 137 | cmdBrowse.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); 138 | cmdBrowse.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); 139 | cmdBrowse.addActionListener(new java.awt.event.ActionListener() { 140 | public void actionPerformed(java.awt.event.ActionEvent evt) { 141 | cmdBrowseActionPerformed(evt); 142 | } 143 | }); 144 | jToolBar1.add(cmdBrowse); 145 | 146 | cmdDelete.setForeground(new java.awt.Color(255, 0, 0)); 147 | cmdDelete.setText("Delete"); 148 | cmdDelete.setFocusable(false); 149 | cmdDelete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); 150 | cmdDelete.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); 151 | cmdDelete.addActionListener(new java.awt.event.ActionListener() { 152 | public void actionPerformed(java.awt.event.ActionEvent evt) { 153 | cmdDeleteActionPerformed(evt); 154 | } 155 | }); 156 | jToolBar1.add(cmdDelete); 157 | 158 | javax.swing.GroupLayout picLayout = new javax.swing.GroupLayout(pic); 159 | pic.setLayout(picLayout); 160 | picLayout.setHorizontalGroup( 161 | picLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 162 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, picLayout.createSequentialGroup() 163 | .addContainerGap(222, Short.MAX_VALUE) 164 | .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 165 | .addContainerGap()) 166 | ); 167 | picLayout.setVerticalGroup( 168 | picLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 169 | .addGroup(picLayout.createSequentialGroup() 170 | .addContainerGap() 171 | .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) 172 | .addContainerGap(119, Short.MAX_VALUE)) 173 | ); 174 | 175 | panelPic.add(pic, java.awt.BorderLayout.CENTER); 176 | 177 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); 178 | this.setLayout(layout); 179 | layout.setHorizontalGroup( 180 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 181 | .addGroup(layout.createSequentialGroup() 182 | .addContainerGap() 183 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 184 | .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE) 185 | .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE) 186 | .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE) 187 | .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE) 188 | .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE) 189 | .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, 100, Short.MAX_VALUE) 190 | .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 191 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 192 | .addGroup(layout.createSequentialGroup() 193 | .addGap(10, 10, 10) 194 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 195 | .addComponent(jScrollPane1) 196 | .addComponent(comboPosition, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 197 | .addComponent(txtSalary) 198 | .addComponent(txtDate) 199 | .addComponent(txtLocation) 200 | .addComponent(txtName))) 201 | .addGroup(layout.createSequentialGroup() 202 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 203 | .addComponent(panelPic, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) 204 | .addGap(30, 30, 30)) 205 | ); 206 | layout.setVerticalGroup( 207 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 208 | .addGroup(layout.createSequentialGroup() 209 | .addGap(20, 20, 20) 210 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 211 | .addComponent(jLabel1) 212 | .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 213 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 214 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 215 | .addComponent(jLabel2) 216 | .addComponent(txtLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 217 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 218 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 219 | .addComponent(txtDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 220 | .addComponent(jLabel3)) 221 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 222 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 223 | .addComponent(txtSalary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 224 | .addComponent(jLabel4)) 225 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 226 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 227 | .addComponent(comboPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 228 | .addComponent(jLabel5)) 229 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 230 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 231 | .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) 232 | .addComponent(panelPic, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) 233 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 234 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 235 | .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) 236 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) 237 | .addContainerGap()) 238 | ); 239 | }// </editor-fold>//GEN-END:initComponents 240 | 241 | private void cmdBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdBrowseActionPerformed 242 | JnaFileChooser ch = new JnaFileChooser(); 243 | ch.addFilter("Image", "png", "jpg"); 244 | boolean act = ch.showOpenDialog(SwingUtilities.getWindowAncestor(this)); 245 | if (act) { 246 | File file = ch.getSelectedFile(); 247 | pic.setImage(new ImageIcon(file.getAbsolutePath())); 248 | profile = new ModelProfile(file); 249 | } 250 | }//GEN-LAST:event_cmdBrowseActionPerformed 251 | 252 | private ModelProfile profile; 253 | 254 | private void cmdDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdDeleteActionPerformed 255 | pic.setImage(new FlatSVGIcon("sample/icon/profile.svg", 5f)); 256 | profile = null; 257 | }//GEN-LAST:event_cmdDeleteActionPerformed 258 | 259 | public ModelEmployee getData() { 260 | String name = txtName.getText().trim(); 261 | String location = txtLocation.getText().trim(); 262 | Date date = datePicker.isDateSelected() ? Date.valueOf(datePicker.getSelectedDate()) : null; 263 | double salary = Double.parseDouble(txtSalary.getValue().toString()); 264 | String description = txtDescription.getText().trim(); 265 | ModelPositions positions = (ModelPositions) comboPosition.getSelectedItem(); 266 | return new ModelEmployee(0, name, location, date, salary, description, profile, positions); 267 | } 268 | 269 | public void init() { 270 | txtName.grabFocus(); 271 | } 272 | 273 | // Variables declaration - do not modify//GEN-BEGIN:variables 274 | private javax.swing.JButton cmdBrowse; 275 | private javax.swing.JButton cmdDelete; 276 | private javax.swing.JComboBox<Object> comboPosition; 277 | private raven.datetime.component.date.DatePicker datePicker; 278 | private javax.swing.JLabel jLabel1; 279 | private javax.swing.JLabel jLabel2; 280 | private javax.swing.JLabel jLabel3; 281 | private javax.swing.JLabel jLabel4; 282 | private javax.swing.JLabel jLabel5; 283 | private javax.swing.JLabel jLabel6; 284 | private javax.swing.JLabel jLabel7; 285 | private javax.swing.JScrollPane jScrollPane1; 286 | private javax.swing.JToolBar jToolBar1; 287 | private javax.swing.JPanel panelPic; 288 | private javaswingdev.picturebox.PictureBox pic; 289 | private javax.swing.JFormattedTextField txtDate; 290 | private javax.swing.JTextArea txtDescription; 291 | private javax.swing.JTextField txtLocation; 292 | private javax.swing.JTextField txtName; 293 | private javax.swing.JFormattedTextField txtSalary; 294 | // End of variables declaration//GEN-END:variables 295 | } 296 | -------------------------------------------------------------------------------- /sample-form/src/sample/form/Create.java: -------------------------------------------------------------------------------- 1 | package sample.form; 2 | 3 | import com.formdev.flatlaf.FlatClientProperties; 4 | import com.formdev.flatlaf.extras.FlatSVGIcon; 5 | import com.formdev.flatlaf.util.UIScale; 6 | import java.awt.Rectangle; 7 | import java.awt.Shape; 8 | import java.io.File; 9 | import java.sql.Date; 10 | import javaswingdev.picturebox.DefaultPictureBoxRender; 11 | import javax.swing.ImageIcon; 12 | import javax.swing.SwingUtilities; 13 | import jnafilechooser.api.JnaFileChooser; 14 | import sample.model.ModelEmployee; 15 | import sample.model.ModelPositions; 16 | import sample.model.other.ModelProfile; 17 | import sample.service.ServiceEmployee; 18 | 19 | /** 20 | * 21 | * @author RAVEN 22 | */ 23 | public class Create extends javax.swing.JPanel { 24 | 25 | /** 26 | * Creates new form Create 27 | */ 28 | public Create() { 29 | initComponents(); 30 | datePicker.setCloseAfterSelected(true); 31 | datePicker.setEditor(txtDate); 32 | pic.setPictureBoxRender(new DefaultPictureBoxRender() { 33 | @Override 34 | public Shape render(Rectangle rectangle) { 35 | return createRound(rectangle, UIScale.scale(10)); 36 | } 37 | }); 38 | pic.setImage(new FlatSVGIcon("sample/icon/profile.svg", 5f)); 39 | panelPic.putClientProperty(FlatClientProperties.STYLE, "" 40 | + "border:0,0,0,0,$Component.borderColor,,10;" 41 | + "background:$TextArea.background"); 42 | } 43 | 44 | public void loadData(ServiceEmployee service, ModelEmployee data) { 45 | try { 46 | for (ModelPositions pos : service.getServicePositions().getAll()) { 47 | comboPosition.addItem(pos); 48 | if (data != null && data.getPositions().getPositionsId() == pos.getPositionsId()) { 49 | comboPosition.setSelectedItem(pos); 50 | } 51 | } 52 | } catch (Exception e) { 53 | e.printStackTrace(); 54 | } 55 | 56 | if (data != null) { 57 | txtName.setText(data.getName()); 58 | txtLocation.setText(data.getLocation()); 59 | if (data.getDate() != null) { 60 | datePicker.setSelectedDate(data.getDate().toLocalDate()); 61 | } 62 | txtSalary.setValue(data.getSalary()); 63 | txtDescription.setText(data.getDescription()); 64 | profile = new ModelProfile(data.getProfile().getIcon()); 65 | if (profile.getIcon() != null) { 66 | pic.setImage(profile.getIcon()); 67 | } 68 | } 69 | } 70 | 71 | /** 72 | * This method is called from within the constructor to initialize the form. 73 | * WARNING: Do NOT modify this code. The content of this method is always 74 | * regenerated by the Form Editor. 75 | */ 76 | @SuppressWarnings("unchecked") 77 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 78 | private void initComponents() { 79 | 80 | datePicker = new raven.datetime.component.date.DatePicker(); 81 | jLabel1 = new javax.swing.JLabel(); 82 | txtName = new javax.swing.JTextField(); 83 | jLabel2 = new javax.swing.JLabel(); 84 | txtLocation = new javax.swing.JTextField(); 85 | jLabel3 = new javax.swing.JLabel(); 86 | txtDate = new javax.swing.JFormattedTextField(); 87 | jLabel4 = new javax.swing.JLabel(); 88 | txtSalary = new javax.swing.JFormattedTextField(); 89 | jLabel5 = new javax.swing.JLabel(); 90 | comboPosition = new javax.swing.JComboBox<>(); 91 | jLabel6 = new javax.swing.JLabel(); 92 | jScrollPane1 = new javax.swing.JScrollPane(); 93 | txtDescription = new javax.swing.JTextArea(); 94 | jLabel7 = new javax.swing.JLabel(); 95 | panelPic = new javax.swing.JPanel(); 96 | pic = new javaswingdev.picturebox.PictureBox(); 97 | jToolBar1 = new javax.swing.JToolBar(); 98 | cmdBrowse = new javax.swing.JButton(); 99 | cmdDelete = new javax.swing.JButton(); 100 | 101 | jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 102 | jLabel1.setText("Name"); 103 | 104 | jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 105 | jLabel2.setText("Location"); 106 | 107 | jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 108 | jLabel3.setText("Date"); 109 | 110 | jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 111 | jLabel4.setText("Salary"); 112 | 113 | txtSalary.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0.##")))); 114 | 115 | jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 116 | jLabel5.setText("Position"); 117 | 118 | jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 119 | jLabel6.setText("Description"); 120 | 121 | txtDescription.setColumns(20); 122 | txtDescription.setLineWrap(true); 123 | txtDescription.setRows(5); 124 | txtDescription.setWrapStyleWord(true); 125 | jScrollPane1.setViewportView(txtDescription); 126 | 127 | jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); 128 | jLabel7.setText("Position"); 129 | 130 | panelPic.setLayout(new java.awt.BorderLayout()); 131 | 132 | jToolBar1.setRollover(true); 133 | jToolBar1.setOpaque(false); 134 | 135 | cmdBrowse.setText("Browse"); 136 | cmdBrowse.setFocusable(false); 137 | cmdBrowse.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); 138 | cmdBrowse.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); 139 | cmdBrowse.addActionListener(new java.awt.event.ActionListener() { 140 | public void actionPerformed(java.awt.event.ActionEvent evt) { 141 | cmdBrowseActionPerformed(evt); 142 | } 143 | }); 144 | jToolBar1.add(cmdBrowse); 145 | 146 | cmdDelete.setForeground(new java.awt.Color(255, 0, 0)); 147 | cmdDelete.setText("Delete"); 148 | cmdDelete.setFocusable(false); 149 | cmdDelete.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); 150 | cmdDelete.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); 151 | cmdDelete.addActionListener(new java.awt.event.ActionListener() { 152 | public void actionPerformed(java.awt.event.ActionEvent evt) { 153 | cmdDeleteActionPerformed(evt); 154 | } 155 | }); 156 | jToolBar1.add(cmdDelete); 157 | 158 | javax.swing.GroupLayout picLayout = new javax.swing.GroupLayout(pic); 159 | pic.setLayout(picLayout); 160 | picLayout.setHorizontalGroup( 161 | picLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 162 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, picLayout.createSequentialGroup() 163 | .addContainerGap(220, Short.MAX_VALUE) 164 | .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 165 | .addContainerGap()) 166 | ); 167 | picLayout.setVerticalGroup( 168 | picLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 169 | .addGroup(picLayout.createSequentialGroup() 170 | .addContainerGap() 171 | .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) 172 | .addContainerGap(119, Short.MAX_VALUE)) 173 | ); 174 | 175 | panelPic.add(pic, java.awt.BorderLayout.CENTER); 176 | 177 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); 178 | this.setLayout(layout); 179 | layout.setHorizontalGroup( 180 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 181 | .addGroup(layout.createSequentialGroup() 182 | .addGap(10, 10, 10) 183 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 184 | .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) 185 | .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) 186 | .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) 187 | .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) 188 | .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) 189 | .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) 190 | .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) 191 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 192 | .addGroup(layout.createSequentialGroup() 193 | .addGap(10, 10, 10) 194 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 195 | .addComponent(jScrollPane1) 196 | .addComponent(comboPosition, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 197 | .addComponent(txtSalary) 198 | .addComponent(txtDate) 199 | .addComponent(txtLocation) 200 | .addComponent(txtName))) 201 | .addGroup(layout.createSequentialGroup() 202 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 203 | .addComponent(panelPic, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) 204 | .addGap(50, 50, 50)) 205 | ); 206 | layout.setVerticalGroup( 207 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 208 | .addGroup(layout.createSequentialGroup() 209 | .addGap(30, 30, 30) 210 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 211 | .addComponent(jLabel1) 212 | .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 213 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 214 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 215 | .addComponent(jLabel2) 216 | .addComponent(txtLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 217 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 218 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 219 | .addComponent(txtDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 220 | .addComponent(jLabel3)) 221 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 222 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 223 | .addComponent(txtSalary, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 224 | .addComponent(jLabel4)) 225 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 226 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 227 | .addComponent(comboPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 228 | .addComponent(jLabel5)) 229 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 230 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 231 | .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) 232 | .addComponent(panelPic, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) 233 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 234 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 235 | .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE) 236 | .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)) 237 | .addContainerGap(16, Short.MAX_VALUE)) 238 | ); 239 | }// </editor-fold>//GEN-END:initComponents 240 | 241 | private void cmdBrowseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdBrowseActionPerformed 242 | JnaFileChooser ch = new JnaFileChooser(); 243 | ch.addFilter("Image", "png", "jpg"); 244 | boolean act = ch.showOpenDialog(SwingUtilities.getWindowAncestor(this)); 245 | if (act) { 246 | File file = ch.getSelectedFile(); 247 | pic.setImage(new ImageIcon(file.getAbsolutePath())); 248 | profile = new ModelProfile(file); 249 | } 250 | }//GEN-LAST:event_cmdBrowseActionPerformed 251 | 252 | private ModelProfile profile; 253 | 254 | private void cmdDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdDeleteActionPerformed 255 | pic.setImage(new FlatSVGIcon("sample/icon/profile.svg", 5f)); 256 | profile = null; 257 | }//GEN-LAST:event_cmdDeleteActionPerformed 258 | 259 | public ModelEmployee getData() { 260 | String name = txtName.getText().trim(); 261 | String location = txtLocation.getText().trim(); 262 | Date date = datePicker.isDateSelected() ? Date.valueOf(datePicker.getSelectedDate()) : null; 263 | double salary = Double.parseDouble(txtSalary.getValue().toString()); 264 | String description = txtDescription.getText().trim(); 265 | ModelPositions positions = (ModelPositions) comboPosition.getSelectedItem(); 266 | return new ModelEmployee(0, name, location, date, salary, description, profile, positions); 267 | } 268 | 269 | // Variables declaration - do not modify//GEN-BEGIN:variables 270 | private javax.swing.JButton cmdBrowse; 271 | private javax.swing.JButton cmdDelete; 272 | private javax.swing.JComboBox<Object> comboPosition; 273 | private raven.datetime.component.date.DatePicker datePicker; 274 | private javax.swing.JLabel jLabel1; 275 | private javax.swing.JLabel jLabel2; 276 | private javax.swing.JLabel jLabel3; 277 | private javax.swing.JLabel jLabel4; 278 | private javax.swing.JLabel jLabel5; 279 | private javax.swing.JLabel jLabel6; 280 | private javax.swing.JLabel jLabel7; 281 | private javax.swing.JScrollPane jScrollPane1; 282 | private javax.swing.JToolBar jToolBar1; 283 | private javax.swing.JPanel panelPic; 284 | private javaswingdev.picturebox.PictureBox pic; 285 | private javax.swing.JFormattedTextField txtDate; 286 | private javax.swing.JTextArea txtDescription; 287 | private javax.swing.JTextField txtLocation; 288 | private javax.swing.JTextField txtName; 289 | private javax.swing.JFormattedTextField txtSalary; 290 | // End of variables declaration//GEN-END:variables 291 | } 292 | -------------------------------------------------------------------------------- /sample-form-use-modal-dialog/src/sample/form/Main.java: -------------------------------------------------------------------------------- 1 | package sample.form; 2 | 3 | import com.formdev.flatlaf.FlatClientProperties; 4 | import com.formdev.flatlaf.FlatLaf; 5 | import com.formdev.flatlaf.extras.FlatSVGIcon; 6 | import com.formdev.flatlaf.fonts.roboto.FlatRobotoFont; 7 | import com.formdev.flatlaf.themes.FlatMacDarkLaf; 8 | import java.awt.Font; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | import javax.swing.JLabel; 12 | import javax.swing.UIManager; 13 | import javax.swing.border.EmptyBorder; 14 | import javax.swing.table.DefaultTableModel; 15 | import raven.modal.ModalDialog; 16 | import raven.modal.Toast; 17 | import raven.modal.component.SimpleModalBorder; 18 | import raven.modal.option.BorderOption; 19 | import sample.connection.DatabaseConnection; 20 | import sample.model.ModelEmployee; 21 | import sample.service.ServiceEmployee; 22 | import sample.table.CheckBoxTableHeaderRenderer; 23 | import sample.table.ProfileTableRenderer; 24 | import sample.table.TableHeaderAlignment; 25 | 26 | /** 27 | * 28 | * @author RAVEN 29 | */ 30 | public class Main extends javax.swing.JFrame { 31 | 32 | private ServiceEmployee service = new ServiceEmployee(); 33 | 34 | public Main() { 35 | initComponents(); 36 | init(); 37 | } 38 | 39 | private void init() { 40 | panel.putClientProperty(FlatClientProperties.STYLE, "" 41 | + "arc:25;" 42 | + "background:$Table.background"); 43 | 44 | table.getTableHeader().putClientProperty(FlatClientProperties.STYLE, "" 45 | + "height:30;" 46 | + "hoverBackground:null;" 47 | + "pressedBackground:null;" 48 | + "separatorColor:$TableHeader.background;" 49 | + "font:bold;"); 50 | 51 | table.putClientProperty(FlatClientProperties.STYLE, "" 52 | + "rowHeight:70;" 53 | + "showHorizontalLines:true;" 54 | + "intercellSpacing:0,1;" 55 | + "cellFocusColor:$TableHeader.hoverBackground;" 56 | + "selectionBackground:$TableHeader.hoverBackground;" 57 | + "selectionForeground:$Table.foreground;"); 58 | 59 | scroll.getVerticalScrollBar().putClientProperty(FlatClientProperties.STYLE, "" 60 | + "trackArc:999;" 61 | + "trackInsets:3,3,3,3;" 62 | + "thumbInsets:3,3,3,3;" 63 | + "background:$Table.background;"); 64 | 65 | lbTitle.putClientProperty(FlatClientProperties.STYLE, "" 66 | + "font:bold +5;"); 67 | 68 | txtSearch.putClientProperty(FlatClientProperties.PLACEHOLDER_TEXT, "Search..."); 69 | txtSearch.putClientProperty(FlatClientProperties.TEXT_FIELD_LEADING_ICON, new FlatSVGIcon("sample/icon/search.svg",0.8f)); 70 | txtSearch.putClientProperty(FlatClientProperties.STYLE, "" 71 | + "arc:15;" 72 | + "borderWidth:0;" 73 | + "focusWidth:0;" 74 | + "innerFocusWidth:0;" 75 | + "margin:5,20,5,20;" 76 | + "background:$Panel.background"); 77 | 78 | table.getColumnModel().getColumn(0).setHeaderRenderer(new CheckBoxTableHeaderRenderer(table, 0)); 79 | table.getTableHeader().setDefaultRenderer(new TableHeaderAlignment(table)); 80 | table.getColumnModel().getColumn(2).setCellRenderer(new ProfileTableRenderer(table)); 81 | 82 | // init default modal 83 | ModalDialog.getDefaultOption() 84 | .setOpacity(0.3f) 85 | .getLayoutOption().setAnimateScale(0.1f); 86 | ModalDialog.getDefaultOption() 87 | .getBorderOption() 88 | .setShadow(BorderOption.Shadow.MEDIUM); 89 | 90 | try { 91 | DatabaseConnection.getInstance().connectToDatabase(); 92 | loadData(); 93 | } catch (Exception e) { 94 | e.printStackTrace(); 95 | } 96 | } 97 | 98 | private void loadData() { 99 | try { 100 | DefaultTableModel model = (DefaultTableModel) table.getModel(); 101 | if (table.isEditing()) { 102 | table.getCellEditor().stopCellEditing(); 103 | } 104 | model.setRowCount(0); 105 | List<ModelEmployee> list = service.getAll(); 106 | for (ModelEmployee d : list) { 107 | model.addRow(d.toTableRow(table.getRowCount() + 1)); 108 | } 109 | } catch (Exception e) { 110 | e.printStackTrace(); 111 | } 112 | } 113 | 114 | private void searchData(String search) { 115 | try { 116 | DefaultTableModel model = (DefaultTableModel) table.getModel(); 117 | if (table.isEditing()) { 118 | table.getCellEditor().stopCellEditing(); 119 | } 120 | model.setRowCount(0); 121 | List<ModelEmployee> list = service.search(search); 122 | for (ModelEmployee d : list) { 123 | model.addRow(d.toTableRow(table.getRowCount() + 1)); 124 | } 125 | } catch (Exception e) { 126 | e.printStackTrace(); 127 | } 128 | } 129 | 130 | @SuppressWarnings("unchecked") 131 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 132 | private void initComponents() { 133 | 134 | panel = new javax.swing.JPanel(); 135 | scroll = new javax.swing.JScrollPane(); 136 | table = new javax.swing.JTable(); 137 | jSeparator1 = new javax.swing.JSeparator(); 138 | txtSearch = new javax.swing.JTextField(); 139 | lbTitle = new javax.swing.JLabel(); 140 | cmdDelete = new sample.swing.ButtonAction(); 141 | cmdEdit = new sample.swing.ButtonAction(); 142 | cmdNew = new sample.swing.ButtonAction(); 143 | 144 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 145 | 146 | scroll.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 147 | 148 | table.setModel(new javax.swing.table.DefaultTableModel( 149 | new Object [][] { 150 | 151 | }, 152 | new String [] { 153 | "SELECT", "#", "NAME", "DATE", "SALARY", "POSITIONS", "DESCRIPTION" 154 | } 155 | ) { 156 | Class[] types = new Class [] { 157 | java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class 158 | }; 159 | boolean[] canEdit = new boolean [] { 160 | true, false, false, false, false, false, false 161 | }; 162 | 163 | public Class getColumnClass(int columnIndex) { 164 | return types [columnIndex]; 165 | } 166 | 167 | public boolean isCellEditable(int rowIndex, int columnIndex) { 168 | return canEdit [columnIndex]; 169 | } 170 | }); 171 | table.getTableHeader().setReorderingAllowed(false); 172 | scroll.setViewportView(table); 173 | if (table.getColumnModel().getColumnCount() > 0) { 174 | table.getColumnModel().getColumn(0).setMaxWidth(50); 175 | table.getColumnModel().getColumn(1).setMaxWidth(40); 176 | table.getColumnModel().getColumn(2).setPreferredWidth(200); 177 | table.getColumnModel().getColumn(4).setPreferredWidth(50); 178 | table.getColumnModel().getColumn(5).setPreferredWidth(150); 179 | table.getColumnModel().getColumn(6).setPreferredWidth(150); 180 | } 181 | 182 | txtSearch.addKeyListener(new java.awt.event.KeyAdapter() { 183 | public void keyReleased(java.awt.event.KeyEvent evt) { 184 | txtSearchKeyReleased(evt); 185 | } 186 | }); 187 | 188 | lbTitle.setText("EMPLOYEE"); 189 | 190 | cmdDelete.setText("Delete"); 191 | cmdDelete.addActionListener(new java.awt.event.ActionListener() { 192 | public void actionPerformed(java.awt.event.ActionEvent evt) { 193 | cmdDeleteActionPerformed(evt); 194 | } 195 | }); 196 | 197 | cmdEdit.setText("Edit"); 198 | cmdEdit.addActionListener(new java.awt.event.ActionListener() { 199 | public void actionPerformed(java.awt.event.ActionEvent evt) { 200 | cmdEditActionPerformed(evt); 201 | } 202 | }); 203 | 204 | cmdNew.setText("New"); 205 | cmdNew.addActionListener(new java.awt.event.ActionListener() { 206 | public void actionPerformed(java.awt.event.ActionEvent evt) { 207 | cmdNewActionPerformed(evt); 208 | } 209 | }); 210 | 211 | javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel); 212 | panel.setLayout(panelLayout); 213 | panelLayout.setHorizontalGroup( 214 | panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 215 | .addComponent(scroll, javax.swing.GroupLayout.DEFAULT_SIZE, 1190, Short.MAX_VALUE) 216 | .addComponent(jSeparator1) 217 | .addGroup(panelLayout.createSequentialGroup() 218 | .addGap(20, 20, 20) 219 | .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 220 | .addGroup(panelLayout.createSequentialGroup() 221 | .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE) 222 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 223 | .addComponent(cmdNew, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) 224 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 225 | .addComponent(cmdEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) 226 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 227 | .addComponent(cmdDelete, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)) 228 | .addComponent(lbTitle)) 229 | .addGap(20, 20, 20)) 230 | ); 231 | panelLayout.setVerticalGroup( 232 | panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 233 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLayout.createSequentialGroup() 234 | .addGap(10, 10, 10) 235 | .addComponent(lbTitle) 236 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 237 | .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 238 | .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 239 | .addComponent(cmdDelete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 240 | .addComponent(cmdEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 241 | .addComponent(cmdNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 242 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 243 | .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 244 | .addGap(0, 0, 0) 245 | .addComponent(scroll, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE) 246 | .addGap(10, 10, 10)) 247 | ); 248 | 249 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 250 | getContentPane().setLayout(layout); 251 | layout.setHorizontalGroup( 252 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 253 | .addGroup(layout.createSequentialGroup() 254 | .addGap(52, 52, 52) 255 | .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 256 | .addGap(38, 38, 38)) 257 | ); 258 | layout.setVerticalGroup( 259 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 260 | .addGroup(layout.createSequentialGroup() 261 | .addGap(47, 47, 47) 262 | .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 263 | .addGap(40, 40, 40)) 264 | ); 265 | 266 | pack(); 267 | setLocationRelativeTo(null); 268 | }// </editor-fold>//GEN-END:initComponents 269 | 270 | private void cmdNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdNewActionPerformed 271 | Create create = new Create(); 272 | create.loadData(service, null); 273 | 274 | SimpleModalBorder.Option[] options = new SimpleModalBorder.Option[]{ 275 | new SimpleModalBorder.Option("Cancel", SimpleModalBorder.CANCEL_OPTION), 276 | new SimpleModalBorder.Option("Save", SimpleModalBorder.OK_OPTION) 277 | }; 278 | ModalDialog.showModal(this, new SimpleModalBorder(create, "Create Employee", options, (mc, i) -> { 279 | if (i == SimpleModalBorder.OK_OPTION) { 280 | // save 281 | try { 282 | service.create(create.getData()); 283 | Toast.show(this, Toast.Type.SUCCESS, "Employee has been created"); 284 | loadData(); 285 | } catch (Exception e) { 286 | e.printStackTrace(); 287 | } 288 | } else if (i == SimpleModalBorder.OPENED) { 289 | create.init(); 290 | } 291 | })); 292 | }//GEN-LAST:event_cmdNewActionPerformed 293 | 294 | private void txtSearchKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtSearchKeyReleased 295 | searchData(txtSearch.getText().trim()); 296 | }//GEN-LAST:event_txtSearchKeyReleased 297 | 298 | private void cmdEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdEditActionPerformed 299 | List<ModelEmployee> list = getSelectedData(); 300 | if (!list.isEmpty()) { 301 | if (list.size() == 1) { 302 | ModelEmployee data = list.get(0); 303 | Create create = new Create(); 304 | create.loadData(service, data); 305 | SimpleModalBorder.Option[] options = new SimpleModalBorder.Option[]{ 306 | new SimpleModalBorder.Option("Cancel", SimpleModalBorder.CANCEL_OPTION), 307 | new SimpleModalBorder.Option("Update", SimpleModalBorder.OK_OPTION) 308 | }; 309 | ModalDialog.showModal(this, new SimpleModalBorder(create, "Edit Employee [" + data.getName() + "]", options, (mc, i) -> { 310 | if (i == SimpleModalBorder.OK_OPTION) { 311 | // edit 312 | try { 313 | ModelEmployee dataEdit = create.getData(); 314 | dataEdit.setEmployeeId(data.getEmployeeId()); 315 | service.edit(dataEdit); 316 | Toast.show(this, Toast.Type.SUCCESS, "Employee has been updated"); 317 | loadData(); 318 | } catch (Exception e) { 319 | e.printStackTrace(); 320 | } 321 | } else if (i == SimpleModalBorder.OPENED) { 322 | create.init(); 323 | } 324 | })); 325 | } else { 326 | Toast.show(this, Toast.Type.WARNING, "Please select only one employee"); 327 | } 328 | } else { 329 | Toast.show(this, Toast.Type.WARNING, "Please select employee to edit"); 330 | } 331 | }//GEN-LAST:event_cmdEditActionPerformed 332 | 333 | private void cmdDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdDeleteActionPerformed 334 | List<ModelEmployee> list = getSelectedData(); 335 | if (!list.isEmpty()) { 336 | SimpleModalBorder.Option[] options = new SimpleModalBorder.Option[]{ 337 | new SimpleModalBorder.Option("Cancel", SimpleModalBorder.CANCEL_OPTION), 338 | new SimpleModalBorder.Option("Delete", SimpleModalBorder.OK_OPTION) 339 | }; 340 | 341 | JLabel label = new JLabel("Are you sure to delete " + list.size() + " employee ?"); 342 | label.setBorder(new EmptyBorder(5, 25, 5, 25)); 343 | ModalDialog.showModal(this, new SimpleModalBorder(label, "Confirm Delete", options, (mc, i) -> { 344 | if (i == SimpleModalBorder.OK_OPTION) { 345 | // delete 346 | try { 347 | for (ModelEmployee d : list) { 348 | service.delete(d.getEmployeeId()); 349 | } 350 | Toast.show(this, Toast.Type.SUCCESS, "Employee has been deleted"); 351 | } catch (Exception e) { 352 | e.printStackTrace(); 353 | } 354 | loadData(); 355 | } 356 | })); 357 | } else { 358 | Toast.show(this, Toast.Type.WARNING, "Please select employee to delete"); 359 | } 360 | }//GEN-LAST:event_cmdDeleteActionPerformed 361 | 362 | private List<ModelEmployee> getSelectedData() { 363 | List<ModelEmployee> list = new ArrayList<>(); 364 | for (int i = 0; i < table.getRowCount(); i++) { 365 | if ((boolean) table.getValueAt(i, 0)) { 366 | ModelEmployee data = (ModelEmployee) table.getValueAt(i, 2); 367 | list.add(data); 368 | } 369 | } 370 | return list; 371 | } 372 | 373 | public static void main(String args[]) { 374 | FlatRobotoFont.install(); 375 | FlatLaf.registerCustomDefaultsSource("sample.themes"); 376 | UIManager.put("defaultFont", new Font(FlatRobotoFont.FAMILY, Font.PLAIN, 13)); 377 | FlatMacDarkLaf.setup(); 378 | 379 | java.awt.EventQueue.invokeLater(new Runnable() { 380 | public void run() { 381 | new Main().setVisible(true); 382 | } 383 | }); 384 | } 385 | 386 | // Variables declaration - do not modify//GEN-BEGIN:variables 387 | private sample.swing.ButtonAction cmdDelete; 388 | private sample.swing.ButtonAction cmdEdit; 389 | private sample.swing.ButtonAction cmdNew; 390 | private javax.swing.JSeparator jSeparator1; 391 | private javax.swing.JLabel lbTitle; 392 | private javax.swing.JPanel panel; 393 | private javax.swing.JScrollPane scroll; 394 | private javax.swing.JTable table; 395 | private javax.swing.JTextField txtSearch; 396 | // End of variables declaration//GEN-END:variables 397 | } 398 | -------------------------------------------------------------------------------- /sample-form/src/sample/form/Main.java: -------------------------------------------------------------------------------- 1 | package sample.form; 2 | 3 | import com.formdev.flatlaf.FlatClientProperties; 4 | import com.formdev.flatlaf.FlatLaf; 5 | import com.formdev.flatlaf.extras.FlatSVGIcon; 6 | import com.formdev.flatlaf.fonts.roboto.FlatRobotoFont; 7 | import com.formdev.flatlaf.themes.FlatMacDarkLaf; 8 | import java.awt.Font; 9 | import java.util.ArrayList; 10 | import java.util.List; 11 | import javax.swing.JLabel; 12 | import javax.swing.UIManager; 13 | import javax.swing.border.EmptyBorder; 14 | import javax.swing.table.DefaultTableModel; 15 | import raven.popup.DefaultOption; 16 | import raven.popup.GlassPanePopup; 17 | import raven.popup.component.SimplePopupBorder; 18 | import raven.toast.Notifications; 19 | import sample.connection.DatabaseConnection; 20 | import sample.model.ModelEmployee; 21 | import sample.service.ServiceEmployee; 22 | import sample.table.CheckBoxTableHeaderRenderer; 23 | import sample.table.ProfileTableRenderer; 24 | import sample.table.TableHeaderAlignment; 25 | 26 | /** 27 | * 28 | * @author RAVEN 29 | */ 30 | public class Main extends javax.swing.JFrame { 31 | 32 | private ServiceEmployee service = new ServiceEmployee(); 33 | 34 | public Main() { 35 | initComponents(); 36 | init(); 37 | } 38 | 39 | private void init() { 40 | GlassPanePopup.install(this); 41 | Notifications.getInstance().setJFrame(this); 42 | panel.putClientProperty(FlatClientProperties.STYLE, "" 43 | + "arc:25;" 44 | + "background:$Table.background"); 45 | 46 | table.getTableHeader().putClientProperty(FlatClientProperties.STYLE, "" 47 | + "height:30;" 48 | + "hoverBackground:null;" 49 | + "pressedBackground:null;" 50 | + "separatorColor:$TableHeader.background;" 51 | + "font:bold;"); 52 | 53 | table.putClientProperty(FlatClientProperties.STYLE, "" 54 | + "rowHeight:70;" 55 | + "showHorizontalLines:true;" 56 | + "intercellSpacing:0,1;" 57 | + "cellFocusColor:$TableHeader.hoverBackground;" 58 | + "selectionBackground:$TableHeader.hoverBackground;" 59 | + "selectionForeground:$Table.foreground;"); 60 | 61 | scroll.getVerticalScrollBar().putClientProperty(FlatClientProperties.STYLE, "" 62 | + "trackArc:999;" 63 | + "trackInsets:3,3,3,3;" 64 | + "thumbInsets:3,3,3,3;" 65 | + "background:$Table.background;"); 66 | 67 | lbTitle.putClientProperty(FlatClientProperties.STYLE, "" 68 | + "font:bold +5;"); 69 | 70 | txtSearch.putClientProperty(FlatClientProperties.PLACEHOLDER_TEXT, "Search..."); 71 | txtSearch.putClientProperty(FlatClientProperties.TEXT_FIELD_LEADING_ICON, new FlatSVGIcon("sample/icon/search.svg")); 72 | txtSearch.putClientProperty(FlatClientProperties.STYLE, "" 73 | + "arc:15;" 74 | + "borderWidth:0;" 75 | + "focusWidth:0;" 76 | + "innerFocusWidth:0;" 77 | + "margin:5,20,5,20;" 78 | + "background:$Panel.background"); 79 | 80 | table.getColumnModel().getColumn(0).setHeaderRenderer(new CheckBoxTableHeaderRenderer(table, 0)); 81 | table.getTableHeader().setDefaultRenderer(new TableHeaderAlignment(table)); 82 | table.getColumnModel().getColumn(2).setCellRenderer(new ProfileTableRenderer(table)); 83 | 84 | try { 85 | DatabaseConnection.getInstance().connectToDatabase(); 86 | loadData(); 87 | } catch (Exception e) { 88 | e.printStackTrace(); 89 | } 90 | } 91 | 92 | private void loadData() { 93 | try { 94 | DefaultTableModel model = (DefaultTableModel) table.getModel(); 95 | if (table.isEditing()) { 96 | table.getCellEditor().stopCellEditing(); 97 | } 98 | model.setRowCount(0); 99 | List<ModelEmployee> list = service.getAll(); 100 | for (ModelEmployee d : list) { 101 | model.addRow(d.toTableRow(table.getRowCount() + 1)); 102 | } 103 | } catch (Exception e) { 104 | e.printStackTrace(); 105 | } 106 | } 107 | 108 | private void searchData(String search) { 109 | try { 110 | DefaultTableModel model = (DefaultTableModel) table.getModel(); 111 | if (table.isEditing()) { 112 | table.getCellEditor().stopCellEditing(); 113 | } 114 | model.setRowCount(0); 115 | List<ModelEmployee> list = service.search(search); 116 | for (ModelEmployee d : list) { 117 | model.addRow(d.toTableRow(table.getRowCount() + 1)); 118 | } 119 | } catch (Exception e) { 120 | e.printStackTrace(); 121 | } 122 | } 123 | 124 | @SuppressWarnings("unchecked") 125 | // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents 126 | private void initComponents() { 127 | 128 | panel = new javax.swing.JPanel(); 129 | scroll = new javax.swing.JScrollPane(); 130 | table = new javax.swing.JTable(); 131 | jSeparator1 = new javax.swing.JSeparator(); 132 | txtSearch = new javax.swing.JTextField(); 133 | lbTitle = new javax.swing.JLabel(); 134 | cmdDelete = new sample.swing.ButtonAction(); 135 | cmdEdit = new sample.swing.ButtonAction(); 136 | cmdNew = new sample.swing.ButtonAction(); 137 | 138 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 139 | 140 | scroll.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 141 | 142 | table.setModel(new javax.swing.table.DefaultTableModel( 143 | new Object [][] { 144 | 145 | }, 146 | new String [] { 147 | "SELECT", "#", "NAME", "DATE", "SALARY", "POSITIONS", "DESCRIPTION" 148 | } 149 | ) { 150 | Class[] types = new Class [] { 151 | java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class 152 | }; 153 | boolean[] canEdit = new boolean [] { 154 | true, false, false, false, false, false, false 155 | }; 156 | 157 | public Class getColumnClass(int columnIndex) { 158 | return types [columnIndex]; 159 | } 160 | 161 | public boolean isCellEditable(int rowIndex, int columnIndex) { 162 | return canEdit [columnIndex]; 163 | } 164 | }); 165 | table.getTableHeader().setReorderingAllowed(false); 166 | scroll.setViewportView(table); 167 | if (table.getColumnModel().getColumnCount() > 0) { 168 | table.getColumnModel().getColumn(0).setMaxWidth(50); 169 | table.getColumnModel().getColumn(1).setMaxWidth(40); 170 | table.getColumnModel().getColumn(2).setPreferredWidth(200); 171 | table.getColumnModel().getColumn(4).setPreferredWidth(50); 172 | table.getColumnModel().getColumn(5).setPreferredWidth(150); 173 | table.getColumnModel().getColumn(6).setPreferredWidth(150); 174 | } 175 | 176 | txtSearch.addKeyListener(new java.awt.event.KeyAdapter() { 177 | public void keyReleased(java.awt.event.KeyEvent evt) { 178 | txtSearchKeyReleased(evt); 179 | } 180 | }); 181 | 182 | lbTitle.setText("EMPLOYEE"); 183 | 184 | cmdDelete.setText("Delete"); 185 | cmdDelete.addActionListener(new java.awt.event.ActionListener() { 186 | public void actionPerformed(java.awt.event.ActionEvent evt) { 187 | cmdDeleteActionPerformed(evt); 188 | } 189 | }); 190 | 191 | cmdEdit.setText("Edit"); 192 | cmdEdit.addActionListener(new java.awt.event.ActionListener() { 193 | public void actionPerformed(java.awt.event.ActionEvent evt) { 194 | cmdEditActionPerformed(evt); 195 | } 196 | }); 197 | 198 | cmdNew.setText("New"); 199 | cmdNew.addActionListener(new java.awt.event.ActionListener() { 200 | public void actionPerformed(java.awt.event.ActionEvent evt) { 201 | cmdNewActionPerformed(evt); 202 | } 203 | }); 204 | 205 | javax.swing.GroupLayout panelLayout = new javax.swing.GroupLayout(panel); 206 | panel.setLayout(panelLayout); 207 | panelLayout.setHorizontalGroup( 208 | panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 209 | .addComponent(scroll, javax.swing.GroupLayout.DEFAULT_SIZE, 1190, Short.MAX_VALUE) 210 | .addComponent(jSeparator1) 211 | .addGroup(panelLayout.createSequentialGroup() 212 | .addGap(20, 20, 20) 213 | .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 214 | .addGroup(panelLayout.createSequentialGroup() 215 | .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE) 216 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 217 | .addComponent(cmdNew, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) 218 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 219 | .addComponent(cmdEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) 220 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 221 | .addComponent(cmdDelete, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)) 222 | .addComponent(lbTitle)) 223 | .addGap(20, 20, 20)) 224 | ); 225 | panelLayout.setVerticalGroup( 226 | panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 227 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLayout.createSequentialGroup() 228 | .addGap(10, 10, 10) 229 | .addComponent(lbTitle) 230 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 231 | .addGroup(panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 232 | .addComponent(txtSearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 233 | .addComponent(cmdDelete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 234 | .addComponent(cmdEdit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 235 | .addComponent(cmdNew, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 236 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 237 | .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 238 | .addGap(0, 0, 0) 239 | .addComponent(scroll, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE) 240 | .addGap(10, 10, 10)) 241 | ); 242 | 243 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 244 | getContentPane().setLayout(layout); 245 | layout.setHorizontalGroup( 246 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 247 | .addGroup(layout.createSequentialGroup() 248 | .addGap(52, 52, 52) 249 | .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 250 | .addGap(38, 38, 38)) 251 | ); 252 | layout.setVerticalGroup( 253 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 254 | .addGroup(layout.createSequentialGroup() 255 | .addGap(47, 47, 47) 256 | .addComponent(panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 257 | .addGap(40, 40, 40)) 258 | ); 259 | 260 | pack(); 261 | setLocationRelativeTo(null); 262 | }// </editor-fold>//GEN-END:initComponents 263 | 264 | private void cmdNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdNewActionPerformed 265 | Create create = new Create(); 266 | create.loadData(service, null); 267 | DefaultOption option = new DefaultOption() { 268 | @Override 269 | public boolean closeWhenClickOutside() { 270 | return true; 271 | } 272 | }; 273 | String actions[] = new String[]{"Cancel", "Save"}; 274 | GlassPanePopup.showPopup(new SimplePopupBorder(create, "Create Employee", actions, (pc, i) -> { 275 | if (i == 1) { 276 | // save 277 | try { 278 | service.create(create.getData()); 279 | pc.closePopup(); 280 | Notifications.getInstance().show(Notifications.Type.SUCCESS, "Employee has been created"); 281 | loadData(); 282 | } catch (Exception e) { 283 | e.printStackTrace(); 284 | } 285 | } else { 286 | pc.closePopup(); 287 | } 288 | }), option); 289 | }//GEN-LAST:event_cmdNewActionPerformed 290 | 291 | private void txtSearchKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtSearchKeyReleased 292 | searchData(txtSearch.getText().trim()); 293 | }//GEN-LAST:event_txtSearchKeyReleased 294 | 295 | private void cmdEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdEditActionPerformed 296 | List<ModelEmployee> list = getSelectedData(); 297 | if (!list.isEmpty()) { 298 | if (list.size() == 1) { 299 | ModelEmployee data = list.get(0); 300 | Create create = new Create(); 301 | create.loadData(service, data); 302 | DefaultOption option = new DefaultOption() { 303 | @Override 304 | public boolean closeWhenClickOutside() { 305 | return true; 306 | } 307 | }; 308 | String actions[] = new String[]{"Cancel", "Update"}; 309 | GlassPanePopup.showPopup(new SimplePopupBorder(create, "Edit Employee [" + data.getName() + "]", actions, (pc, i) -> { 310 | if (i == 1) { 311 | // edit 312 | try { 313 | ModelEmployee dataEdit = create.getData(); 314 | dataEdit.setEmployeeId(data.getEmployeeId()); 315 | service.edit(dataEdit); 316 | pc.closePopup(); 317 | Notifications.getInstance().show(Notifications.Type.SUCCESS, "Employee has been updated"); 318 | loadData(); 319 | } catch (Exception e) { 320 | e.printStackTrace(); 321 | } 322 | } else { 323 | pc.closePopup(); 324 | } 325 | }), option); 326 | } else { 327 | Notifications.getInstance().show(Notifications.Type.WARNING, "Please select only one employee"); 328 | } 329 | } else { 330 | Notifications.getInstance().show(Notifications.Type.WARNING, "Please select employee to edit"); 331 | } 332 | }//GEN-LAST:event_cmdEditActionPerformed 333 | 334 | private void cmdDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdDeleteActionPerformed 335 | List<ModelEmployee> list = getSelectedData(); 336 | if (!list.isEmpty()) { 337 | DefaultOption option = new DefaultOption() { 338 | @Override 339 | public boolean closeWhenClickOutside() { 340 | return true; 341 | } 342 | }; 343 | String actions[] = new String[]{"Cancel", "Delete"}; 344 | JLabel label = new JLabel("Are you sure to delete " + list.size() + " employee ?"); 345 | label.setBorder(new EmptyBorder(0, 25, 0, 25)); 346 | GlassPanePopup.showPopup(new SimplePopupBorder(label, "Confirm Delete", actions, (pc, i) -> { 347 | if (i == 1) { 348 | // delete 349 | try { 350 | for (ModelEmployee d : list) { 351 | service.delete(d.getEmployeeId()); 352 | } 353 | pc.closePopup(); 354 | Notifications.getInstance().show(Notifications.Type.SUCCESS, "Employee has been deleted"); 355 | } catch (Exception e) { 356 | e.printStackTrace(); 357 | } 358 | loadData(); 359 | } else { 360 | pc.closePopup(); 361 | } 362 | }), option); 363 | } else { 364 | Notifications.getInstance().show(Notifications.Type.WARNING, "Please select employee to delete"); 365 | } 366 | }//GEN-LAST:event_cmdDeleteActionPerformed 367 | 368 | private List<ModelEmployee> getSelectedData() { 369 | List<ModelEmployee> list = new ArrayList<>(); 370 | for (int i = 0; i < table.getRowCount(); i++) { 371 | if ((boolean) table.getValueAt(i, 0)) { 372 | ModelEmployee data = (ModelEmployee) table.getValueAt(i, 2); 373 | list.add(data); 374 | } 375 | } 376 | return list; 377 | } 378 | 379 | public static void main(String args[]) { 380 | FlatRobotoFont.install(); 381 | FlatLaf.registerCustomDefaultsSource("sample.themes"); 382 | UIManager.put("defaultFont", new Font(FlatRobotoFont.FAMILY, Font.PLAIN, 13)); 383 | FlatMacDarkLaf.setup(); 384 | 385 | java.awt.EventQueue.invokeLater(new Runnable() { 386 | public void run() { 387 | new Main().setVisible(true); 388 | } 389 | }); 390 | } 391 | 392 | // Variables declaration - do not modify//GEN-BEGIN:variables 393 | private sample.swing.ButtonAction cmdDelete; 394 | private sample.swing.ButtonAction cmdEdit; 395 | private sample.swing.ButtonAction cmdNew; 396 | private javax.swing.JSeparator jSeparator1; 397 | private javax.swing.JLabel lbTitle; 398 | private javax.swing.JPanel panel; 399 | private javax.swing.JScrollPane scroll; 400 | private javax.swing.JTable table; 401 | private javax.swing.JTextField txtSearch; 402 | // End of variables declaration//GEN-END:variables 403 | } 404 | --------------------------------------------------------------------------------