Creating detached windows

Are you able to run this demo on your Linux operating system:

//http://www.java2s.com/example/java/swing/managing-window-types.html

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

class Utility extends JFrame {
  int x, y, w, h;

  public Utility(int x, int y, int w, int h) {
    this.x = x;
    this.y = y;
    this.w = w;
    this.h = h;
    this.setTitle("Utility Window");
    this.setBounds(x, y, w, h);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setType(Type.UTILITY);
    this.setLayout(new FlowLayout());
    JButton exitButton = new JButton("Quit");
    this.add(exitButton);
    exitButton.addActionListener(event->System.exit(0));
  }
}

void setup() {
  size(400, 400);
  surface.setTitle("Default Processing Window");
  SwingUtilities.invokeLater(() -> {
    Utility wnd1 = new Utility(100, 100, 400, 300);
    wnd1.setVisible(true);
    Utility wnd2 = new Utility(400, 100, 300, 200);
    wnd2.setVisible(true);
  }
  );
}

1 Like