Skip to content

Commit c8cf0fc

Browse files
authored
Merge pull request #101 from comtel2000/spotless-upd
Add Spotless code formatter plugin + format apply
2 parents 1392e61 + ca5f5b8 commit c8cf0fc

50 files changed

Lines changed: 1302 additions & 1788 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
fx-onscreen-keyboard
22

3-
Copyright (C) 2016, comtel2000
3+
Copyright (C) 2025, comtel2000
44

55
Redistribution and use in source and binary forms, with or without modification,
66
are permitted provided that the following conditions are met:
Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
module fx.onscreen.keyboard.samples {
2-
32
requires fx.onscreen.keyboard;
43
requires fx.onscreen.keyboard.swing;
5-
64
requires javafx.graphics;
75
requires javafx.swing;
86
requires javafx.controls;
97
requires javafx.media;
10-
11-
opens org.comtel2000.samples.fx to javafx.graphics;
128

9+
opens org.comtel2000.samples.fx to
10+
javafx.graphics;
1311
}

fx-onscreen-keyboard-samples/src/main/java/org/comtel2000/samples/fx/MainDemo.java

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
/* Copyright (c) 2025-2000 comtel2000 (BSD 3-Clause) */
12
package org.comtel2000.samples.fx;
23

4+
import static org.comtel2000.keyboard.control.VkProperties.*;
5+
6+
import java.util.Locale;
37
import javafx.application.Application;
48
import javafx.scene.Scene;
59
import javafx.scene.control.*;
@@ -9,10 +13,6 @@
913
import org.comtel2000.keyboard.control.KeyBoardPopup;
1014
import org.comtel2000.keyboard.control.KeyBoardPopupBuilder;
1115

12-
import java.util.Locale;
13-
14-
import static org.comtel2000.keyboard.control.VkProperties.*;
15-
1616
/*******************************************************************************
1717
* Copyright (c) 2025 comtel2000
1818
*
@@ -61,14 +61,13 @@ public void start(Stage stage) {
6161
cancelButton.setCancelButton(true);
6262

6363
Button popupButton = new Button("Popup");
64-
popupButton.setOnAction(act -> {
65-
TextInputDialog dialog = new TextInputDialog("Popup");
66-
dialog.setTitle("Text Input Dialog");
67-
dialog.setContentText("Please enter your name:");
68-
dialog.showAndWait();
69-
70-
});
71-
64+
popupButton.setOnAction(
65+
act -> {
66+
TextInputDialog dialog = new TextInputDialog("Popup");
67+
dialog.setTitle("Text Input Dialog");
68+
dialog.setContentText("Please enter your name:");
69+
dialog.showAndWait();
70+
});
7271

7372
CheckBox spaceKeyMove = new CheckBox("Movable");
7473
spaceKeyMove.setSelected(true);
@@ -80,9 +79,16 @@ public void start(Stage stage) {
8079

8180
CheckBox numblock = new CheckBox("NumBlock");
8281
numblock.setSelected(false);
83-
numblock.selectedProperty().addListener((l, a, b) -> popup.getKeyBoard().switchLayer(b == Boolean.TRUE ? DefaultLayer.NUMBLOCK : DefaultLayer.DEFAULT));
82+
numblock
83+
.selectedProperty()
84+
.addListener(
85+
(l, a, b) ->
86+
popup
87+
.getKeyBoard()
88+
.switchLayer(b == Boolean.TRUE ? DefaultLayer.NUMBLOCK : DefaultLayer.DEFAULT));
8489

85-
pane.getChildren().add(new ToolBar(okButton, cancelButton, popupButton, spaceKeyMove, capsLock, numblock));
90+
pane.getChildren()
91+
.add(new ToolBar(okButton, cancelButton, popupButton, spaceKeyMove, capsLock, numblock));
8692

8793
pane.getChildren().add(new Label("Text0"));
8894
TextField tf0 = new TextField();
@@ -141,7 +147,5 @@ public void start(Stage stage) {
141147
popup.addGlobalDoubleClickEventFilter();
142148

143149
stage.show();
144-
145150
}
146-
147151
}

fx-onscreen-keyboard-samples/src/main/java/org/comtel2000/samples/fx/StandAloneApp.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
/* Copyright (c) 2025-2000 comtel2000 (BSD 3-Clause) */
12
package org.comtel2000.samples.fx;
23

4+
import java.nio.file.Paths;
5+
import java.text.ParseException;
6+
import java.util.Locale;
7+
import java.util.Map;
38
import javafx.application.Application;
49
import javafx.scene.Group;
510
import javafx.scene.Scene;
@@ -11,11 +16,6 @@
1116
import org.comtel2000.keyboard.control.KeyboardType;
1217
import org.comtel2000.swing.robot.NativeAsciiRobotHandler;
1318

14-
import java.nio.file.Paths;
15-
import java.text.ParseException;
16-
import java.util.Locale;
17-
import java.util.Map;
18-
1919
/*******************************************************************************
2020
* Copyright (c) 2025 comtel2000
2121
*
@@ -102,7 +102,6 @@ public void start(Stage stage) {
102102

103103
popup.registerScene(scene);
104104
popup.setVisible(true);
105-
106105
}
107106

108107
private void showHelp() {
@@ -138,5 +137,4 @@ private void parsePosition(String p) throws Exception {
138137
posY = Integer.valueOf(pos[1]);
139138
}
140139
}
141-
142140
}

fx-onscreen-keyboard-samples/src/main/java/org/comtel2000/samples/swing/StandAloneApp.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1+
/* Copyright (c) 2025-2000 comtel2000 (BSD 3-Clause) */
12
package org.comtel2000.samples.swing;
23

4+
import java.awt.*;
5+
import java.nio.file.Paths;
6+
import java.text.ParseException;
7+
import java.util.Collections;
8+
import java.util.HashMap;
9+
import java.util.Locale;
10+
import java.util.Map;
311
import javafx.application.Platform;
412
import javafx.embed.swing.JFXPanel;
513
import javafx.scene.Group;
614
import javafx.scene.Scene;
15+
import javax.swing.*;
716
import org.comtel2000.keyboard.control.DefaultLayer;
817
import org.comtel2000.keyboard.control.KeyBoardPopup;
918
import org.comtel2000.keyboard.control.KeyboardPane;
1019
import org.comtel2000.keyboard.control.KeyboardType;
1120
import org.comtel2000.swing.robot.NativeAsciiRobotHandler;
1221

13-
import javax.swing.*;
14-
import java.awt.*;
15-
import java.nio.file.Paths;
16-
import java.text.ParseException;
17-
import java.util.Collections;
18-
import java.util.HashMap;
19-
import java.util.Locale;
20-
import java.util.Map;
21-
2222
/*******************************************************************************
2323
* Copyright (c) 2025 comtel2000
2424
*
@@ -55,10 +55,11 @@ public StandAloneApp() {}
5555

5656
public static void main(String[] args) {
5757
arguments = args;
58-
SwingUtilities.invokeLater(() -> {
59-
StandAloneApp app = new StandAloneApp();
60-
app.init();
61-
});
58+
SwingUtilities.invokeLater(
59+
() -> {
60+
StandAloneApp app = new StandAloneApp();
61+
app.init();
62+
});
6263
}
6364

6465
public static Map<String, String> getParameters() {
@@ -97,7 +98,6 @@ public void init() {
9798

9899
// create JavaFX scene
99100
Platform.runLater(() -> createScene(javafxPanel));
100-
101101
}
102102

103103
public void createScene(JFXPanel javafxPanel) {

fx-onscreen-keyboard-samples/src/main/java/org/comtel2000/samples/swing/SwingDemo.java

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1+
/* Copyright (c) 2025-2000 comtel2000 (BSD 3-Clause) */
12
package org.comtel2000.samples.swing;
23

4+
import static org.comtel2000.keyboard.control.VkProperties.*;
5+
6+
import java.awt.*;
7+
import java.util.Locale;
8+
import javax.swing.*;
39
import org.comtel2000.keyboard.control.DefaultLayer;
410
import org.comtel2000.swing.control.KeyBoardWindow;
511
import org.comtel2000.swing.control.KeyBoardWindowBuilder;
612
import org.comtel2000.swing.robot.AWTRobotHandler;
713
import org.comtel2000.swing.ui.KeyboardUIManagerTool;
814

9-
import javax.swing.*;
10-
import java.awt.*;
11-
import java.util.Locale;
12-
13-
import static org.comtel2000.keyboard.control.VkProperties.*;
14-
1515
/*******************************************************************************
1616
* Copyright (c) 2025 comtel2000
1717
*
@@ -43,25 +43,29 @@ public class SwingDemo extends JFrame {
4343
private static final long serialVersionUID = 1L;
4444

4545
public static void main(String[] args) {
46-
SwingUtilities.invokeLater(() -> {
47-
JFrame frame = new JFrame("Swing FX Keyboard");
48-
frame.setResizable(false);
49-
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
50-
51-
SwingDemo kb = new SwingDemo();
52-
kb.init();
53-
frame.setContentPane(kb.getContentPane());
54-
frame.pack();
55-
frame.setLocationRelativeTo(null);
56-
frame.setVisible(true);
57-
58-
});
46+
SwingUtilities.invokeLater(
47+
() -> {
48+
JFrame frame = new JFrame("Swing FX Keyboard");
49+
frame.setResizable(false);
50+
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
51+
52+
SwingDemo kb = new SwingDemo();
53+
kb.init();
54+
frame.setContentPane(kb.getContentPane());
55+
frame.pack();
56+
frame.setLocationRelativeTo(null);
57+
frame.setVisible(true);
58+
});
5959
}
6060

6161
public void init() {
6262

6363
KeyBoardWindow window =
64-
KeyBoardWindowBuilder.create().initLocale(Locale.forLanguageTag("en")).addIRobot(new AWTRobotHandler()).layer(DefaultLayer.NUMBLOCK).build();
64+
KeyBoardWindowBuilder.create()
65+
.initLocale(Locale.forLanguageTag("en"))
66+
.addIRobot(new AWTRobotHandler())
67+
.layer(DefaultLayer.NUMBLOCK)
68+
.build();
6569
KeyboardUIManagerTool.installKeyboardDefaults(window);
6670

6771
JPanel panel = new JPanel();
@@ -90,7 +94,5 @@ public void init() {
9094

9195
setLayout(new BorderLayout());
9296
add(panel, BorderLayout.CENTER);
93-
9497
}
95-
9698
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
module fx.onscreen.keyboard.swing {
2-
32
requires transitive fx.onscreen.keyboard;
43
requires transitive javafx.base;
54
requires transitive java.desktop;
@@ -10,6 +9,6 @@
109
exports org.comtel2000.swing.control;
1110
exports org.comtel2000.swing.robot;
1211

13-
provides org.comtel2000.keyboard.robot.IRobot with org.comtel2000.swing.robot.NativeAsciiRobotHandler;
14-
12+
provides org.comtel2000.keyboard.robot.IRobot with
13+
org.comtel2000.swing.robot.NativeAsciiRobotHandler;
1514
}

fx-onscreen-keyboard-swing/src/main/java/org/comtel2000/swing/control/KeyBoardWindow.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
/* Copyright (c) 2025-2000 comtel2000 (BSD 3-Clause) */
12
package org.comtel2000.swing.control;
23

4+
import java.util.Optional;
35
import javafx.embed.swing.JFXPanel;
46
import javafx.event.Event;
57
import javafx.event.EventHandler;
68
import javafx.scene.Group;
79
import javafx.scene.Node;
810
import javafx.scene.Scene;
9-
import org.comtel2000.keyboard.control.KeyBoardPopup;
10-
1111
import javax.swing.*;
12-
import java.util.Optional;
12+
import org.comtel2000.keyboard.control.KeyBoardPopup;
1313

1414
/*******************************************************************************
1515
* Copyright (c) 2025 comtel2000
@@ -44,11 +44,12 @@
4444
*/
4545
public class KeyBoardWindow extends JWindow {
4646

47-
public static final EventHandler<? super Event> DEFAULT_CLOSE_HANDLER = event -> {
48-
if (event.getSource() instanceof Node node) {
49-
node.getScene().getWindow().hide();
50-
}
51-
};
47+
public static final EventHandler<? super Event> DEFAULT_CLOSE_HANDLER =
48+
event -> {
49+
if (event.getSource() instanceof Node node) {
50+
node.getScene().getWindow().hide();
51+
}
52+
};
5253
private static final long serialVersionUID = 1564988010984549166L;
5354
private final JFXPanel jfxPanel;
5455
private transient KeyBoardPopup popup;
@@ -79,5 +80,4 @@ protected void createScene(final KeyBoardPopup popup) {
7980
public Optional<KeyBoardPopup> getKeyBoardPopup() {
8081
return Optional.ofNullable(popup);
8182
}
82-
8383
}

fx-onscreen-keyboard-swing/src/main/java/org/comtel2000/swing/control/KeyBoardWindowBuilder.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
/* Copyright (c) 2025-2000 comtel2000 (BSD 3-Clause) */
12
package org.comtel2000.swing.control;
23

4+
import java.nio.file.Path;
5+
import java.util.Locale;
6+
import java.util.concurrent.CountDownLatch;
37
import javafx.application.Platform;
48
import javafx.util.Builder;
59
import org.comtel2000.keyboard.control.DefaultLayer;
@@ -8,10 +12,6 @@
812
import org.comtel2000.keyboard.robot.IRobot;
913
import org.comtel2000.swing.robot.AWTRobotHandler;
1014

11-
import java.nio.file.Path;
12-
import java.util.Locale;
13-
import java.util.concurrent.CountDownLatch;
14-
1515
/*******************************************************************************
1616
* Copyright (c) 2025 comtel2000
1717
*
@@ -136,17 +136,17 @@ public KeyBoardWindowBuilder style(String css) {
136136
@Override
137137
public KeyBoardWindow build() {
138138
final KeyBoardWindow window = new KeyBoardWindow();
139-
Platform.runLater(() -> {
140-
KeyBoardPopup popup = new KeyBoardPopup(kb.build());
141-
window.createScene(popup);
142-
latch.countDown();
143-
});
139+
Platform.runLater(
140+
() -> {
141+
KeyBoardPopup popup = new KeyBoardPopup(kb.build());
142+
window.createScene(popup);
143+
latch.countDown();
144+
});
144145
try {
145146
latch.await();
146147
} catch (InterruptedException e) {
147148
Thread.currentThread().interrupt();
148149
}
149150
return window;
150151
}
151-
152152
}

0 commit comments

Comments
 (0)