Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

33
LINES

< > BotCompany Repo | #1034004 // TranslucentWindowTest

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4960L/28K).

sclass TranslucentWindowTest {
  new L<JWindow> windows;
  
  run {
    var screens = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
    System.out.println("Detected " + screens.length + " screen(s)");
    for (int iScreen = 0; iScreen < screens.length; iScreen++) {
      var screen = screens[iScreen].getDefaultConfiguration().getBounds();
      
      // place window in center of screen
      new JWindow window;
      window.setBounds(
        screen.x+screen.width/4,
        screen.y+screen.height/4,
        screen.width/2,
        screen.height/2);
        
      // faint (mostly translucent) blue background
      window.setBackground(new Color(0, 0, 255, 64));
      
      window.setAlwaysOnTop(true);
      var label = new JLabel("Screen " + (iScreen+1) + " of " + screens.length);
      label.setHorizontalAlignment(JLabel.CENTER);
      window.add(label);
      window.setVisible(true);
      windows.add(window);
    }
      
    doAfter(10.0, r {
      disposeWindows(windows);
    });
  }
}

Author comment

Began life as a copy of #1034002

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1034004
Snippet name: TranslucentWindowTest
Eternal ID of this version: #1034004/1
Text MD5: 1f6c0a9cd30da2a915f1d271a8ff543e
Transpilation MD5: 3a666ff446bbf85ef5951ae4035679a9
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-16 18:05:56
Source code size: 1064 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 148 / 284
Referenced in: #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674)