Skip to content

Commit

Permalink
Reduce minimum required JDK from 21 to 11
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkryst committed Jan 6, 2024
1 parent c156fdc commit 869ef1c
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 73 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 21
java-version: 11
java-package: jdk
architecture: x64

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 21
java-version: 11
java-package: jdk
architecture: x64

Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<name>VTerminal</name>

<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<maven.compiler.release>21</maven.compiler.release>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
Expand Down
52 changes: 24 additions & 28 deletions src/example/gui/view/EditorPaneView.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,36 @@ public EditorPaneView() {
var component = new VEditorPane();
component.setContentType("text/html");
component.setEditable(true);
component.setText("""
<html>
<head>
<style type="text/css">
i {
color: red;
}
</style>
</head>
<body>
<p>This <i>VEditorPane</i> is editable and <b>enabled</b>.</p>
</body>
</html>
""");
component.setText("<html>\n" +
" <head>\n" +
" <style type=\"text/css\">\n" +
" i {\n" +
" color: red;\n" +
" }\n" +
" </style>\n" +
" </head>\n" +
" <body>\n" +
" <p>This <i>VEditorPane</i> is editable and <b>enabled</b>.</p>\n" +
" </body>\n" +
"</html>\n");
this.add(component, BorderLayout.NORTH);

component = new VEditorPane();
component.setContentType("text/html");
component.setEditable(true);
component.setEnabled(false);
component.setText("""
<html>
<head>
<style type="text/css">
i {
color: red;
}
</style>
</head>
<body>
<p>This <i>VEditorPane</i> is editable and <b>disabled</b>.</p>
</body>
</html>
""");
component.setText("<html>\n" +
" <head>\n" +
" <style type=\"text/css\">\n" +
" i {\n" +
" color: red;\n" +
" }\n" +
" </style>\n" +
" </head>\n" +
" <body>\n" +
" <p>This <i>VEditorPane</i> is editable and <b>disabled</b>.</p>\n" +
" </body>\n" +
"</html>\n");
this.add(component, BorderLayout.SOUTH);
}

Expand Down
14 changes: 7 additions & 7 deletions src/example/repainting_a_screen/ExampleB.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ private static int getRandomCodePoint() {

private static Color getRandomColor() {
switch (ThreadLocalRandom.current().nextInt(0, 6)) {
case 0 -> { return Color.MAGENTA; }
case 1 -> { return Color.GREEN; }
case 2 -> { return Color.YELLOW; }
case 3 -> { return Color.BLUE; }
case 4 -> { return Color.RED; }
case 5 -> { return Color.ORANGE; }
default -> { return Color.WHITE; }
case 0: { return Color.MAGENTA; }
case 1: { return Color.GREEN; }
case 2: { return Color.YELLOW; }
case 3: { return Color.BLUE; }
case 4: { return Color.RED; }
case 5: { return Color.ORANGE; }
default: { return Color.WHITE; }
}
}
}
14 changes: 7 additions & 7 deletions src/example/resetting_a_screen/ExampleC.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public static void main(final String[] args) {

private static Color getRandomColor() {
switch (ThreadLocalRandom.current().nextInt(0, 6)) {
case 0 -> { return Color.MAGENTA; }
case 1 -> { return Color.GREEN; }
case 2 -> { return Color.YELLOW; }
case 3 -> { return Color.BLUE; }
case 4 -> { return Color.RED; }
case 5 -> { return Color.ORANGE; }
default -> { return Color.WHITE; }
case 0: { return Color.MAGENTA; }
case 1: { return Color.GREEN; }
case 2: { return Color.YELLOW; }
case 3: { return Color.BLUE; }
case 4: { return Color.RED; }
case 5: { return Color.ORANGE; }
default: { return Color.WHITE; }
}
}
}
14 changes: 7 additions & 7 deletions src/example/resetting_a_screen/ExampleD.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ private static int getRandomCodePoint() {

private static Color getRandomColor() {
switch (ThreadLocalRandom.current().nextInt(0, 6)) {
case 0 -> { return Color.MAGENTA; }
case 1 -> { return Color.GREEN; }
case 2 -> { return Color.YELLOW; }
case 3 -> { return Color.BLUE; }
case 4 -> { return Color.RED; }
case 5 -> { return Color.ORANGE; }
default -> { return Color.WHITE; }
case 0: { return Color.MAGENTA; }
case 1: { return Color.GREEN; }
case 2: { return Color.YELLOW; }
case 3: { return Color.BLUE; }
case 4: { return Color.RED; }
case 5: { return Color.ORANGE; }
default: { return Color.WHITE; }
}
}
}
14 changes: 7 additions & 7 deletions src/example/resetting_a_screen/ExampleF.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ private static int getRandomCodePoint() {

private static Color getRandomColor() {
switch (ThreadLocalRandom.current().nextInt(0, 6)) {
case 0 -> { return Color.MAGENTA; }
case 1 -> { return Color.GREEN; }
case 2 -> { return Color.YELLOW; }
case 3 -> { return Color.BLUE; }
case 4 -> { return Color.RED; }
case 5 -> { return Color.ORANGE; }
default -> { return Color.WHITE; }
case 0: { return Color.MAGENTA; }
case 1: { return Color.GREEN; }
case 2: { return Color.YELLOW; }
case 3: { return Color.BLUE; }
case 4: { return Color.RED; }
case 5: { return Color.ORANGE; }
default: { return Color.WHITE; }
}
}
}
17 changes: 11 additions & 6 deletions src/main/java/com/valkryst/VTerminal/plaf/VBasicArrowButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,35 @@ public void paint(final Graphics graphics) {

graphics.setColor(isPressed ? super.getForeground() : super.getBackground());
switch (super.getDirection()) {
case SwingConstants.NORTH -> {
case SwingConstants.NORTH: {
graphics.fillRect(0, 0, width, height - 2);
graphics.setColor(super.getForeground());
graphics.drawLine(0, 0, 0, height);
graphics.drawLine(1, height - 2, width - 1, height - 2);
break;
}
case SwingConstants.SOUTH -> {
case SwingConstants.SOUTH: {
graphics.fillRect(0, 2, width, height - 2);
graphics.setColor(super.getForeground());
graphics.drawLine(0, 0, 0, height);
graphics.drawLine(1, 1, width - 1, 1);
graphics.drawLine(1, height - 1, width - 1, height - 1);
break;
}
case SwingConstants.WEST -> {
case SwingConstants.WEST: {
graphics.fillRect(0, 0, width - 2, height);
graphics.setColor(super.getForeground());
graphics.drawLine(0, 0, width, 0);
graphics.drawLine(width - 2, 0, width - 2, height - 1);
break;
}
case SwingConstants.EAST -> {
case SwingConstants.EAST: {
graphics.fillRect(2, 0, width, height);
graphics.setColor(super.getForeground());
graphics.drawLine(0, 0, width, 0);
graphics.drawLine(1, 0, 1, height - 1);
graphics.drawLine(width - 1, 0, width - 1, height - 1);
break;
}
}

Expand Down Expand Up @@ -87,10 +91,11 @@ public Dimension getPreferredSize() {
final var laf = VTerminalLookAndFeel.getInstance();

switch (super.getDirection()) {
case SwingConstants.EAST, SwingConstants.WEST -> {
case SwingConstants.EAST:
case SwingConstants.WEST: {
return new Dimension(laf.getTileWidth() * 2, laf.getTileHeight());
}
default -> {
default: {
return new Dimension(laf.getTileWidth(), laf.getTileHeight());
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/valkryst/VTerminal/plaf/VButtonUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public void keyReleased(final KeyEvent e) {
}

switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER, KeyEvent.VK_SPACE -> {
case KeyEvent.VK_ENTER:
case KeyEvent.VK_SPACE: {
((JButton) component).doClick();
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/valkryst/VTerminal/plaf/VCheckBoxUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ public void keyReleased(final KeyEvent e) {
}

switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER, KeyEvent.VK_SPACE -> {
case KeyEvent.VK_ENTER:
case KeyEvent.VK_SPACE: {
final var checkBox = (JCheckBox) component;
checkBox.setSelected(!checkBox.isSelected());
break;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/valkryst/VTerminal/plaf/VPanelUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public Dimension getMinimumSize(final JComponent component) {

@Override
public Dimension getPreferredSize(final JComponent component) {
if (component instanceof final VPanel panel) {
if (component instanceof VPanel) {
final var panel = (VPanel) component;
final var laf = VTerminalLookAndFeel.getInstance();
final var height = laf.getTileHeight() * panel.getHeightInTiles();
final var width = laf.getTileWidth() * panel.getWidthInTiles();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ public void keyReleased(final KeyEvent e) {
}

switch (e.getKeyCode()) {
case KeyEvent.VK_ENTER, KeyEvent.VK_SPACE -> {
case KeyEvent.VK_ENTER:
case KeyEvent.VK_SPACE: {
final var checkBox = (JRadioButton) component;
checkBox.setSelected(!checkBox.isSelected());
break;
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/com/valkryst/VTerminal/plaf/VScrollPaneUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ public void keyPressed(final KeyEvent e) {
}

switch (e.getKeyCode()) {
case KeyEvent.VK_LEFT, KeyEvent.VK_HOME -> {
case KeyEvent.VK_LEFT:
case KeyEvent.VK_HOME: {
horizontalScrollBar.setValue(horizontalScrollBar.getValue() - horizontalScrollBar.getUnitIncrement());
break;
}
case KeyEvent.VK_RIGHT, KeyEvent.VK_END -> {
case KeyEvent.VK_RIGHT:
case KeyEvent.VK_END: {
horizontalScrollBar.setValue(horizontalScrollBar.getValue() + horizontalScrollBar.getUnitIncrement());
break;
}
}
}
Expand Down

0 comments on commit 869ef1c

Please sign in to comment.