Skip to content

Commit 6cb5806

Browse files
author
realPaulsen
committed
v1.1.3
1.1.3 final commit for release Changes: - JOptionPane-Methods of PUIElement refer to methods in PUIFrame Note: - Finished recompiling all releases with Java-11
1 parent 04370b0 commit 6cb5806

File tree

5 files changed

+90
-80
lines changed

5 files changed

+90
-80
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ by [`Paulsen`](https://github.com/realPaulsen)
9999
- **Comments**/JavaDoc still missing😬
100100
- **FixPoints** on PUISlider
101101
- **Free** movable PUIElements on PUIScrollPanel (without snapped locations)
102-
- **JOptionPane-Methods** of PUIElement should refer to methods in PUIFrame
103102
- **BugFixes:**
104103
- PUICore: when interactionLayer is -1 the element behind gets called as well
105104

src/ooo/paulsen/demo/Demo.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import ooo.paulsen.ui.*;
44
import ooo.paulsen.ui.PUIElement.ElementAlignment;
5+
import ooo.paulsen.utils.PSystem;
56

67
import java.awt.*;
78

@@ -15,17 +16,21 @@ public static void main(String[] args) {
1516
PUIFrame f;
1617
PUICanvas canvas;
1718
PUIMatrix matrix;
18-
PUIText darkmodeButton;
19+
PUIText darkModeButton;
1920
PUIScrollPanel sp;
2021
PUICheckBox cb;
2122
PUIRotaryControl rc;
2223
PUISlider slider;
2324
PUISlider slider2;
2425

26+
String frameTitle;
27+
2528
public Demo() {
2629

30+
frameTitle = "JPL-Demo - " + PSystem.getUserName() + "'s " + PSystem.getOSType() + "-System from " + PSystem.getUserDisplayLocation();
31+
2732
// initialize frame before creating Elements
28-
f = new PUIFrame("Project-Library Demo", 600, 600);
33+
f = new PUIFrame(frameTitle, 600, 600);
2934

3035

3136
// Drawing a rectangle in the background
@@ -43,22 +48,22 @@ public void paint(Graphics2D g, int x, int y, int w, int h) {
4348
setMatrixElements(false);
4449

4550

46-
darkmodeButton = new PUIText(f, "LIGHT", 2);
47-
darkmodeButton.addActionListener(new PUIAction() {
51+
darkModeButton = new PUIText(f, "LIGHT", 2);
52+
darkModeButton.addActionListener(new PUIAction() {
4853
@Override
4954
public void run(PUIElement that) {
5055
PUIElement.darkUIMode = !PUIElement.darkUIMode;
5156
if (PUIElement.darkUIMode) {
52-
darkmodeButton.setText("DARK");
57+
darkModeButton.setText("DARK");
5358
sp.setEnabled(false); // set any Element as disabled -> No more Interaction and no Visuals with this Element
5459
} else {
55-
darkmodeButton.setText("LIGHT");
60+
darkModeButton.setText("LIGHT");
5661
sp.setEnabled(true);
5762
}
5863
}
5964
});
6065
// if set to false: when pressed the eventchain doesnt stop => elements on layers behind this Button can be triggered as well
61-
darkmodeButton.doBlockRaycast(false);
66+
darkModeButton.doBlockRaycast(false);
6267

6368
sp = new PUIScrollPanel(f);
6469

@@ -118,10 +123,11 @@ public void run() {
118123
t.addActionListener(new PUIAction() {
119124
@Override
120125
public void run(PUIElement that) {
121-
f.setTitle(((PUIText) that).getText());
122126

123127
// automatically centers clicked Element in the UI
124128
sp.center(that);
129+
130+
that.sendUserInfo("You clicked List-Object: " + ((PUIText) that).getText());
125131
}
126132
});
127133
sp.addElement(t);
@@ -150,7 +156,7 @@ public void update(int w, int h) {
150156
});
151157

152158
// Set Position of other non-relative Elements
153-
darkmodeButton.setBounds(50, 50, 300, 100);
159+
darkModeButton.setBounds(50, 50, 300, 100);
154160
slider.setBounds(50, 200, 300, 50);
155161
slider2.setBounds(50, 250, 300, 50);
156162

src/ooo/paulsen/ui/PUICore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void mouseClicked(MouseEvent e) {
5454
firstHitLayer = elem.getInteractionLayer();
5555
}
5656
for (MouseListener listener : elem.getMouseListeners())
57-
listener.mousePressed(e);
57+
listener.mouseClicked(e);
5858
} else if ((firstHitLayer != -1 && firstHitLayer != elem.getInteractionLayer() && elem.isEnabled())) {
5959
return; // break from loop because 2DRaycast has been triggered and the layers behind are not reachable
6060
}

src/ooo/paulsen/ui/PUIElement.java

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public class PUIElement extends PUICanvas { // PaulsenUserInterfaceIntegratedEle
2020
darkOutline = new Color(81, 81, 81), darkText = new Color(235, 235, 235),
2121
darkSelected = new Color(196, 196, 196);
2222

23+
public enum ElementAlignment {
24+
HORIZONTAL, VERTICAL
25+
}
2326

2427
protected int x = 0, y = 0, w = 0, h = 0;
2528
protected Color backgroundColor = Color.LIGHT_GRAY;
@@ -304,6 +307,7 @@ public boolean isEnabled() {
304307

305308
/**
306309
* If enabled is set FALSE: The Event-/Listening-System ignores this Element and also doesn't draw it.
310+
*
307311
* @param enabled
308312
*/
309313
public void setEnabled(boolean enabled) {
@@ -374,25 +378,32 @@ public void setBackgroundColor(Color backgroundColor) {
374378
this.backgroundColor = backgroundColor;
375379
}
376380

381+
public Object getMetadata() {
382+
return metaData;
383+
}
384+
385+
public void setMetadata(Object o) {
386+
metaData = o;
387+
}
388+
377389
public String getUserInput(String message, String initialValue) {
378-
return JOptionPane.showInputDialog(frame, message, initialValue);
390+
return frame.getUserInput(message, initialValue);
379391
}
380392

381393
public void sendUserError(String message) {
382-
JOptionPane.showMessageDialog(frame, message, "ERROR", JOptionPane.ERROR_MESSAGE);
394+
frame.sendUserError(message);
383395
}
384396

385397
public void sendUserWarning(String message) {
386-
JOptionPane.showMessageDialog(frame, message, "WARNING", JOptionPane.WARNING_MESSAGE);
398+
frame.sendUserWarning(message);
387399
}
388400

389401
public void sendUserInfo(String message) {
390-
JOptionPane.showMessageDialog(frame, message, "INFO", JOptionPane.INFORMATION_MESSAGE);
402+
frame.sendUserInfo(message);
391403
}
392404

393405
public boolean getUserConfirm(String message, String title) {
394-
return JOptionPane.showConfirmDialog(frame, message, title, JOptionPane.OK_CANCEL_OPTION,
395-
JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION;
406+
return frame.getUserConfirm(message, title);
396407
}
397408

398409
/**
@@ -403,31 +414,18 @@ public boolean getUserConfirm(String message, String title) {
403414
* @return index from 0 to comboBoxInput.length
404415
*/
405416
public int getUserSelection(String title, String comboBoxInput[]) {
406-
if (frame == null)
407-
return -1;
408-
409-
JComboBox<String> box = new JComboBox<>(comboBoxInput);
410-
JOptionPane.showMessageDialog(frame, box, title, JOptionPane.QUESTION_MESSAGE);
411-
return box.getSelectedIndex();
417+
return frame.getUserSelection(title, comboBoxInput);
412418
}
413419

420+
/**
421+
* Creates a popup-window which lets u choose one of the Options
422+
*
423+
* @param title
424+
* @param comboBoxInput String-ArrayList of Options
425+
* @return index from 0 to comboBoxInput.length
426+
*/
414427
public int getUserSelection(String title, ArrayList<String> comboBoxInput) {
415-
String s[] = new String[comboBoxInput.size()];
416-
for (int i = 0; i < s.length; i++)
417-
s[i] = comboBoxInput.get(i);
418-
return getUserSelection(title, s);
419-
}
420-
421-
public Object getMetadata() {
422-
return metaData;
423-
}
424-
425-
public void setMetadata(Object o) {
426-
metaData = o;
427-
}
428-
429-
public enum ElementAlignment {
430-
HORIZONTAL, VERTICAL
428+
return frame.getUserSelection(title, comboBoxInput);
431429
}
432430

433431
}

src/ooo/paulsen/ui/PUIFrame.java

Lines changed: 48 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -203,47 +203,6 @@ public void repaint() {
203203
}
204204
}
205205

206-
public String getUserInput(String message, String initialValue) {
207-
return JOptionPane.showInputDialog(canvas, message, initialValue);
208-
}
209-
210-
public void sendUserError(String message) {
211-
JOptionPane.showMessageDialog(canvas, message, "ERROR", JOptionPane.ERROR_MESSAGE);
212-
}
213-
214-
public void sendUserWarning(String message) {
215-
JOptionPane.showMessageDialog(canvas, message, "WARNING", JOptionPane.WARNING_MESSAGE);
216-
}
217-
218-
public void sendUserInfo(String message) {
219-
JOptionPane.showMessageDialog(canvas, message, "INFO", JOptionPane.INFORMATION_MESSAGE);
220-
}
221-
222-
public boolean getUserConfirm(String message, String title) {
223-
return JOptionPane.showConfirmDialog(canvas, message, title, JOptionPane.OK_CANCEL_OPTION,
224-
JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION;
225-
}
226-
227-
/**
228-
* Creates a popup-window which lets u choose one of the Options
229-
*
230-
* @param title displayed Toptext
231-
* @param comboBoxInput String-Array of Options
232-
* @return index from 0 to comboBoxInput.length. <b>If -1:</b> no valid Option was selected
233-
*/
234-
public int getUserSelection(String title, String comboBoxInput[]) {
235-
JComboBox<String> box = new JComboBox<>(comboBoxInput);
236-
JOptionPane.showMessageDialog(canvas, box, title, JOptionPane.QUESTION_MESSAGE);
237-
return box.getSelectedIndex();
238-
}
239-
240-
public int getUserSelection(String title, ArrayList<String> comboBoxInput) {
241-
String s[] = new String[comboBoxInput.size()];
242-
for (int i = 0; i < s.length; i++)
243-
s[i] = comboBoxInput.get(i);
244-
return getUserSelection(title, s);
245-
}
246-
247206
public int getMaxFrameRate() {
248207
return maxFrameRate;
249208
}
@@ -292,4 +251,52 @@ public int compare(PUICanvas o1, PUICanvas o2) {
292251
// }
293252
}
294253

254+
public String getUserInput(String message, String initialValue) {
255+
return JOptionPane.showInputDialog(canvas, message, initialValue);
256+
}
257+
258+
public void sendUserError(String message) {
259+
JOptionPane.showMessageDialog(canvas, message, "ERROR", JOptionPane.ERROR_MESSAGE);
260+
}
261+
262+
public void sendUserWarning(String message) {
263+
JOptionPane.showMessageDialog(canvas, message, "WARNING", JOptionPane.WARNING_MESSAGE);
264+
}
265+
266+
public void sendUserInfo(String message) {
267+
JOptionPane.showMessageDialog(canvas, message, "INFO", JOptionPane.INFORMATION_MESSAGE);
268+
}
269+
270+
public boolean getUserConfirm(String message, String title) {
271+
return JOptionPane.showConfirmDialog(canvas, message, title, JOptionPane.OK_CANCEL_OPTION,
272+
JOptionPane.QUESTION_MESSAGE) == JOptionPane.OK_OPTION;
273+
}
274+
275+
/**
276+
* Creates a popup-window which lets u choose one of the Options
277+
*
278+
* @param title displayed Toptext
279+
* @param comboBoxInput String-Array of Options
280+
* @return index from 0 to comboBoxInput.length. <b>If -1:</b> no valid Option was selected
281+
*/
282+
public int getUserSelection(String title, String comboBoxInput[]) {
283+
JComboBox<String> box = new JComboBox<>(comboBoxInput);
284+
JOptionPane.showMessageDialog(canvas, box, title, JOptionPane.QUESTION_MESSAGE);
285+
return box.getSelectedIndex();
286+
}
287+
288+
/**
289+
* Creates a popup-window which lets u choose one of the Options
290+
*
291+
* @param title
292+
* @param comboBoxInput String-ArrayList of Options
293+
* @return index from 0 to comboBoxInput.length
294+
*/
295+
public int getUserSelection(String title, ArrayList<String> comboBoxInput) {
296+
String s[] = new String[comboBoxInput.size()];
297+
for (int i = 0; i < s.length; i++)
298+
s[i] = comboBoxInput.get(i);
299+
return getUserSelection(title, s);
300+
}
301+
295302
}

0 commit comments

Comments
 (0)