├── 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 |
4 |
5 |
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 |
--------------------------------------------------------------------------------
/sample-form-use-modal-dialog/src/sample/icon/search.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
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 |
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 |
204 |
--------------------------------------------------------------------------------
/sample-form-use-modal-dialog/src/sample/form/Main.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
204 |
--------------------------------------------------------------------------------
/sample-form-use-modal-dialog/src/sample/form/Create.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
254 |
--------------------------------------------------------------------------------
/sample-form/src/sample/form/Create.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 | // //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 | }// //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