Implement MaterialUI theme
This commit is contained in:
parent
56b41d49a4
commit
d11cdb2caf
9 changed files with 117 additions and 8 deletions
|
@ -15,6 +15,7 @@ dependencies {
|
||||||
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
|
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
|
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
|
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
|
||||||
|
implementation 'io.github.vincenzopalazzo:material-ui-swing:1.1.1'
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|
|
@ -31,19 +31,21 @@
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
<children>
|
<children>
|
||||||
<component id="ea5a" class="javax.swing.JButton" binding="previousButton">
|
<component id="ea5a" class="javax.swing.JButton" binding="previousButton" custom-create="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
|
<font name="JetBrains Mono" style="0"/>
|
||||||
<text value="←"/>
|
<text value="←"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="ddc41" class="javax.swing.JButton" binding="nextButton">
|
<component id="ddc41" class="javax.swing.JButton" binding="nextButton" custom-create="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
|
<font name="JetBrains Mono" style="0"/>
|
||||||
<text value="→"/>
|
<text value="→"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import DB.Competition;
|
||||||
import DB.Slot;
|
import DB.Slot;
|
||||||
import Exceptions.NotFoundInTable;
|
import Exceptions.NotFoundInTable;
|
||||||
import GUI.Agenda.Agenda;
|
import GUI.Agenda.Agenda;
|
||||||
|
import GUI.Theme.PrimaryContainedButtonUI;
|
||||||
import GUI.Types.ProjectionType;
|
import GUI.Types.ProjectionType;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -66,6 +67,7 @@ public class GUI extends JFrame implements ActionListener {
|
||||||
competitionButtonPanel = new JPanel();
|
competitionButtonPanel = new JPanel();
|
||||||
for (Competition competition : Competition.getAll()) {
|
for (Competition competition : Competition.getAll()) {
|
||||||
JButton button = new JButton(competition.getName());
|
JButton button = new JButton(competition.getName());
|
||||||
|
button.setUI(new PrimaryContainedButtonUI());
|
||||||
button.addActionListener(actionEvent -> switchAgenda(competition));
|
button.addActionListener(actionEvent -> switchAgenda(competition));
|
||||||
competitionButtonPanel.add(button);
|
competitionButtonPanel.add(button);
|
||||||
}
|
}
|
||||||
|
@ -103,5 +105,9 @@ public class GUI extends JFrame implements ActionListener {
|
||||||
|
|
||||||
private void createUIComponents() {
|
private void createUIComponents() {
|
||||||
competitionButton();
|
competitionButton();
|
||||||
|
nextButton = new JButton();
|
||||||
|
nextButton.setUI(new PrimaryContainedButtonUI());
|
||||||
|
previousButton = new JButton();
|
||||||
|
previousButton.setUI(new PrimaryContainedButtonUI());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@
|
||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<component id="6eea5" class="javax.swing.JButton" binding="cancelButton">
|
<component id="6eea5" class="javax.swing.JButton" binding="cancelButton" custom-create="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
|
@ -88,7 +88,7 @@
|
||||||
<text value="Cancel"/>
|
<text value="Cancel"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="9b61e" class="javax.swing.JButton" binding="confirmButton">
|
<component id="9b61e" class="javax.swing.JButton" binding="confirmButton" custom-create="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
|
|
|
@ -2,9 +2,11 @@ package GUI;
|
||||||
|
|
||||||
import Config.Config;
|
import Config.Config;
|
||||||
import DB.*;
|
import DB.*;
|
||||||
import Exceptions.NotFoundInTable;
|
|
||||||
import Exceptions.ProjectionNotSpecified;
|
import Exceptions.ProjectionNotSpecified;
|
||||||
import GUI.Agenda.Agenda;
|
import GUI.Agenda.Agenda;
|
||||||
|
import GUI.Theme.DangerContainedButtonUI;
|
||||||
|
import GUI.Theme.PrimaryContainedButtonUI;
|
||||||
|
import GUI.Theme.SecondaryContainedButtonUI;
|
||||||
import GUI.Types.ProjectionType;
|
import GUI.Types.ProjectionType;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
@ -55,14 +57,14 @@ public class ProjectionHandler extends JDialog {
|
||||||
slotComboBox.getModel().setSelectedItem(agenda.getSlot());
|
slotComboBox.getModel().setSelectedItem(agenda.getSlot());
|
||||||
updateRooms();
|
updateRooms();
|
||||||
}
|
}
|
||||||
createUIComponents();
|
createUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProjectionHandler(ProjectionType projectionType, Agenda agenda, Projection projection) {
|
public ProjectionHandler(ProjectionType projectionType, Agenda agenda, Projection projection) {
|
||||||
this.projectionType = projectionType;
|
this.projectionType = projectionType;
|
||||||
this.agenda = agenda;
|
this.agenda = agenda;
|
||||||
this.projection = projection;
|
this.projection = projection;
|
||||||
createUIComponents();
|
createUI();
|
||||||
competitionComboBox.getModel().setSelectedItem(projection.getCompetition());
|
competitionComboBox.getModel().setSelectedItem(projection.getCompetition());
|
||||||
filmComboBox.getModel().setSelectedItem(projection.getMovie());
|
filmComboBox.getModel().setSelectedItem(projection.getMovie());
|
||||||
dayComboBox.getModel().setSelectedItem(projection.getStartDate().toLocalDate());
|
dayComboBox.getModel().setSelectedItem(projection.getStartDate().toLocalDate());
|
||||||
|
@ -73,7 +75,7 @@ public class ProjectionHandler extends JDialog {
|
||||||
comboBox.setEnabled(false);
|
comboBox.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createUIComponents() {
|
private void createUI() {
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
setModal(true);
|
setModal(true);
|
||||||
setPreferredSize(new Dimension(500, 300));
|
setPreferredSize(new Dimension(500, 300));
|
||||||
|
@ -97,6 +99,16 @@ public class ProjectionHandler extends JDialog {
|
||||||
confirmButton.addActionListener(actionEvent -> confirm());
|
confirmButton.addActionListener(actionEvent -> confirm());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void createUIComponents() {
|
||||||
|
confirmButton = new JButton();
|
||||||
|
if (projectionType == ProjectionType.REMOVE)
|
||||||
|
confirmButton.setUI(new DangerContainedButtonUI());
|
||||||
|
else
|
||||||
|
confirmButton.setUI(new PrimaryContainedButtonUI());
|
||||||
|
cancelButton = new JButton();
|
||||||
|
cancelButton.setUI(new SecondaryContainedButtonUI());
|
||||||
|
}
|
||||||
|
|
||||||
private void updateCompetitions() {
|
private void updateCompetitions() {
|
||||||
ArrayList<Competition> competitions = Competition.getAll();
|
ArrayList<Competition> competitions = Competition.getAll();
|
||||||
if (competitions != null)
|
if (competitions != null)
|
||||||
|
|
28
src/main/java/GUI/Theme/DangerContainedButtonUI.java
Normal file
28
src/main/java/GUI/Theme/DangerContainedButtonUI.java
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package GUI.Theme;
|
||||||
|
|
||||||
|
import mdlaf.animation.MaterialUIMovement;
|
||||||
|
import mdlaf.components.button.MaterialButtonUI;
|
||||||
|
import mdlaf.utils.MaterialColors;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class DangerContainedButtonUI extends MaterialButtonUI {
|
||||||
|
@Override
|
||||||
|
public void installUI(JComponent c) {
|
||||||
|
super.mouseHoverEnabled = false;
|
||||||
|
super.installUI(c);
|
||||||
|
super.mouseHoverEnabled = true;
|
||||||
|
super.colorMouseHoverNormalButton = MaterialColors.RED_600;
|
||||||
|
super.background = MaterialColors.RED_700;
|
||||||
|
c.setBackground(super.background);
|
||||||
|
super.foreground = MaterialColors.WHITE;
|
||||||
|
c.setForeground(super.foreground);
|
||||||
|
|
||||||
|
if (super.mouseHoverEnabled) {
|
||||||
|
c.addMouseListener(
|
||||||
|
MaterialUIMovement.getMovement(c, this.colorMouseHoverNormalButton)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
super.borderEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
28
src/main/java/GUI/Theme/PrimaryContainedButtonUI.java
Normal file
28
src/main/java/GUI/Theme/PrimaryContainedButtonUI.java
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package GUI.Theme;
|
||||||
|
|
||||||
|
import mdlaf.animation.MaterialUIMovement;
|
||||||
|
import mdlaf.components.button.MaterialButtonUI;
|
||||||
|
import mdlaf.utils.MaterialColors;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class PrimaryContainedButtonUI extends MaterialButtonUI {
|
||||||
|
@Override
|
||||||
|
public void installUI(JComponent c) {
|
||||||
|
super.mouseHoverEnabled = false;
|
||||||
|
super.installUI(c);
|
||||||
|
super.mouseHoverEnabled = true;
|
||||||
|
super.colorMouseHoverNormalButton = MaterialColors.BLUE_600;
|
||||||
|
super.background = MaterialColors.BLUE_700;
|
||||||
|
c.setBackground(super.background);
|
||||||
|
super.foreground = MaterialColors.WHITE;
|
||||||
|
c.setForeground(super.foreground);
|
||||||
|
|
||||||
|
if (super.mouseHoverEnabled) {
|
||||||
|
c.addMouseListener(
|
||||||
|
MaterialUIMovement.getMovement(c, this.colorMouseHoverNormalButton)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
super.borderEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
28
src/main/java/GUI/Theme/SecondaryContainedButtonUI.java
Normal file
28
src/main/java/GUI/Theme/SecondaryContainedButtonUI.java
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
package GUI.Theme;
|
||||||
|
|
||||||
|
import mdlaf.animation.MaterialUIMovement;
|
||||||
|
import mdlaf.components.button.MaterialButtonUI;
|
||||||
|
import mdlaf.utils.MaterialColors;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
|
public class SecondaryContainedButtonUI extends MaterialButtonUI {
|
||||||
|
@Override
|
||||||
|
public void installUI(JComponent c) {
|
||||||
|
super.mouseHoverEnabled = false;
|
||||||
|
super.installUI(c);
|
||||||
|
super.mouseHoverEnabled = true;
|
||||||
|
super.colorMouseHoverNormalButton = MaterialColors.PURPLE_600;
|
||||||
|
super.background = MaterialColors.PURPLE_700;
|
||||||
|
c.setBackground(super.background);
|
||||||
|
super.foreground = MaterialColors.WHITE;
|
||||||
|
c.setForeground(super.foreground);
|
||||||
|
|
||||||
|
if (super.mouseHoverEnabled) {
|
||||||
|
c.addMouseListener(
|
||||||
|
MaterialUIMovement.getMovement(c, this.colorMouseHoverNormalButton)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
super.borderEnabled = false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,10 @@ package ProjectionPlanning;
|
||||||
import DB.DB;
|
import DB.DB;
|
||||||
import Exceptions.NotFoundInTable;
|
import Exceptions.NotFoundInTable;
|
||||||
import GUI.GUI;
|
import GUI.GUI;
|
||||||
|
import mdlaf.MaterialLookAndFeel;
|
||||||
|
import mdlaf.themes.MaterialLiteTheme;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) throws NotFoundInTable {
|
public static void main(String[] args) throws NotFoundInTable {
|
||||||
|
|
Reference in a new issue