MCPcopy Create free account
hub / github.com/HumbleUI/JWM / Example

Method Example

examples/dashboard/java/Example.java:44–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42 public Options progressBars = new Options("Default", "0%", "50%", "100%", "Indeterminate");
43
44 public Example() {
45 window = App.makeWindow();
46 window.setEventListener(this);
47
48 panelTextInput = new PanelTextInput(window);
49 panelScreens = new PanelScreens(window);
50 panelLegend = new PanelLegend(window);
51 panelMouse = new PanelMouse(window);
52 panelAnimation = new PanelAnimation(window);
53 panelMouseCursors = new PanelMouseCursors(window);
54 panelRendering = new PanelRendering(window);
55 panelEvents = new PanelEvents(window);
56 panelTheme = new PanelTheme(window);
57 panelTouch = new PanelTouch(window);
58
59 var scale = window.getScreen().getScale();
60 int count = App._windows.size() - 1;
61 Screen screen = App.getScreens()[(count / 5) % App.getScreens().length];
62 IRect bounds = screen.getWorkArea();
63
64 window.setTitle("JWM Window #" + count);
65 if (window instanceof WindowMac windowMac) {
66 windowMac.setSubtitle("Window Subtitle");
67 windowMac.setRepresentedFilename("macos/cc/WindowMac.mm");
68 }
69
70 panelScreens.setTitleStyle(panelScreens.titleStyles.get(count));
71
72 window.setWindowSize(bounds.getWidth() / 2, bounds.getHeight() / 2);
73 switch (count % 5) {
74 case 0 -> window.setWindowPosition(bounds.getLeft() + bounds.getWidth() / 4, bounds.getTop() + bounds.getHeight() / 4);
75 case 1 -> window.setWindowPosition(bounds.getLeft(), bounds.getTop());
76 case 2 -> window.setWindowPosition(bounds.getLeft() + bounds.getWidth() / 2, bounds.getTop());
77 case 3 -> window.setWindowPosition(bounds.getLeft(), bounds.getTop() + bounds.getHeight() / 2);
78 case 4 -> window.setWindowPosition(bounds.getLeft() + bounds.getWidth() / 2, bounds.getTop() + bounds.getHeight() / 2);
79 }
80
81 switch (Platform.CURRENT) {
82 case WINDOWS -> {
83 window.setIcon(new File("examples/dashboard/resources/windows.ico"));
84 }
85 case MACOS -> {
86 window.setIcon(new File("examples/dashboard/resources/macos.icns"));
87 }
88 case X11 -> {
89 ((WindowX11) window).setClassHint("jwm-dashboard-example"); // allows OS-wide identification of the window (e.g. icon themes, .desktop files)
90 try {
91 Bitmap i = Bitmap.makeFromImage(Image.makeDeferredFromEncodedBytes(Files.readAllBytes(Path.of("examples/dashboard/resources/linux/icon_48x48.png"))));
92 ImageInfo info = i.getImageInfo();
93
94 ((WindowX11) window).setIconData(info.getWidth(), info.getHeight(), i.readPixels());
95 } catch (IOException e) {
96 e.printStackTrace();
97 }
98 }
99 }
100
101 window.setVisible(true);

Callers

nothing calls this directly

Calls 15

makeWindowMethod · 0.95
getScreensMethod · 0.95
getWidthMethod · 0.95
getHeightMethod · 0.95
setEventListenerMethod · 0.80
sizeMethod · 0.80
setSubtitleMethod · 0.80
setTitleStyleMethod · 0.80
getLeftMethod · 0.80
getTopMethod · 0.80
setClassHintMethod · 0.80

Tested by

no test coverage detected