Java Code Examples for javax.swing.JFrame#setUndecorated()

The following examples show how to use javax.swing.JFrame#setUndecorated() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameShop.java    From JAVA-MVC-Swing-Monopoly with Apache License 2.0 6 votes vote down vote up
private void createWindow() {
	frame = new JFrame();
	panel = new JPanel();
	JLabel label = new JLabel("����");
	panel.add(label);

	frame.add(new Background(0, 0, 0, 0, null,null));
	frame.setSize(300, 300);
	// ���ô������롣
	frame.setLocation(
			this.mainFrame.getX()
					+ ((this.mainFrame.getWidth() + this.frame.getWidth()) / 2),
			this.mainFrame.getY()
					+ ((this.mainFrame.getHeight() + this.frame.getHeight()) / 2));
	frame.setUndecorated(true);
	frame.setAlwaysOnTop(true);
	frame.addMouseMotionListener(this);
	frame.addMouseListener(this);
	frame.setVisible(true);
}
 
Example 2
Source File: RobotUtils.java    From karate with MIT License 6 votes vote down vote up
public static void highlight(int x, int y, int width, int height, int time) {
    JFrame f = new JFrame();
    f.setUndecorated(true);
    f.setBackground(new Color(0, 0, 0, 0));
    f.setAlwaysOnTop(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setType(JFrame.Type.UTILITY);
    f.setFocusableWindowState(false);
    f.setAutoRequestFocus(false);
    f.setLocation(x, y);
    f.setSize(width, height);
    f.getRootPane().setBorder(BorderFactory.createLineBorder(Color.RED, 3));
    f.setVisible(true);
    delay(time);
    f.dispose();
}
 
Example 3
Source File: UI.java    From arcgis-runtime-demo-java with Apache License 2.0 6 votes vote down vote up
public static JFrame createWindow() {
  JFrame window = new JFrame();
  window.setUndecorated(true);
  window.setExtendedState(Frame.MAXIMIZED_BOTH);
  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  window.getContentPane().setLayout(new BorderLayout(0, 0));
  return window;
}
 
Example 4
Source File: MisplacedBorder.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);

    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();

    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
 
Example 5
Source File: SplashScreen.java    From chipster with MIT License 5 votes vote down vote up
public SplashScreen(Icon icon) {
	frame = new JFrame();
	frame.setLayout(null);
	frame.setUndecorated(true);		
	frame.setSize(icon.getIconWidth(), icon.getIconHeight()+TEXT_HEIGHT);
	frame.setLocationRelativeTo(null);  
	frame.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	frame.getRootPane().setBorder(new LineBorder(VisualConstants.SPLASH_BORDER_COLOR, 1));
	
	JLabel imageLabel = new JLabel(icon);
	imageLabel.setSize(icon.getIconWidth(), icon.getIconHeight());
	frame.add(imageLabel);
	imageLabel.setLocation(0, 0);
	textLabel = new JLabel();
	textLabel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
	
	textLabel.setFont(VisualConstants.SPLASH_SCREEN_FONT);
	
	textPanel = new JPanel(new BorderLayout());
	textPanel.setLocation(0, icon.getIconHeight());
	textPanel.setSize(icon.getIconWidth(), TEXT_HEIGHT);
	textPanel.setBackground(Color.WHITE);
	textPanel.setOpaque(true);
	textPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, VisualConstants.SPLASH_BORDER_COLOR));
	textPanel.add(textLabel);
	
	frame.add(textPanel);
	frame.setVisible(true);
}
 
Example 6
Source File: AhkFastTyper.java    From training with MIT License 5 votes vote down vote up
private static void makeUI() {
		frame = new JFrame("Keyboard Shortcuts Pane");
		frame.setUndecorated(true);
		frame.setBackground(new Color(1, 1, 1, 0f));

//		frame.setFocusableWindowState(false);
		frame.setSize(100, 30);
		frame.setAlwaysOnTop(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setFocusableWindowState(false);
		frame.setFocusable(true);
		frame.setVisible(false);
	}
 
Example 7
Source File: VirtualCursor.java    From haxademic with MIT License 5 votes vote down vote up
public void setup() {
	super.setup();
	// set special window properties
	jframe = (JFrame)((PSurfaceAWT.SmoothCanvas) getSurface().getNative()).getFrame();
	jframe.removeNotify();
	jframe.setUndecorated(true);
	jframe.setLayout(null);
	jframe.addNotify();
	jframe.setAlwaysOnTop(true);

	pg = createGraphics(width, height);
	cursor = Base64Image.decodePImageFromBase64("iVBORw0KGgoAAAANSUhEUgAAAGoAAAC1CAMAAACAl5pfAAAAYFBMVEVHcEyRkZEQEBAAAAB1dXVISEgmJib///8cHBwGBgYoKCj9/f3////T09O8vLzl5eX19fVubm4yMjJCQkJXV1eJiYmhoaEvLy+YmJjY2Ng6Ojqurq7Hx8f19fXo6OheXl4dpwGJAAAAIHRSTlMAbe//ibfYBOP5//7/7u3x9vP9+fbv7s/kJcVRNwoVoJWYs8AAAAPzSURBVHgBvM2FiURRAASw+679t3uGDSwamJcG8jXUNC/LvI6YtuXfftSnaVlGXecy7LqWvPpVXv0qr36VV7vKq1/l1a7yald5tau82lVe7SqvdpVXuypcUd3P3b2iettXVO0rq/KVVfnKqnxlVb6yKl9Zla+syldW5Sur8pVV+cqqfGVVvrIqX58VX17xBRVfUNkFFVxQwQUVXFDBpRVcWsGlFVxawcWVX1755ZVfXvkFFV9Q8QUVX1DxBRVfUPEFFV9Q8QUVX1DRBRVcUMEFFVxQwQUVXFDBBRVfUPEFFV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CYII=");

	JPanel panel = new JPanel() {
		private static final long serialVersionUID = 1L;

		@Override
		protected void paintComponent(Graphics graphics) {
			if (graphics instanceof Graphics2D) {
				Graphics2D g2d = (Graphics2D) graphics;
				g2d.drawImage(pg.image, 0, 0, null);
			}
		}
	};

	jframe.setContentPane(panel);
	panel.setFocusable(true);
	panel.setFocusTraversalKeysEnabled(false);
	panel.requestFocus();
	panel.requestFocusInWindow();
}
 
Example 8
Source File: StartupHelper.java    From javamoney-examples with Apache License 2.0 5 votes vote down vote up
private
static
JFrame
createSplash()
{
  JFrame splash = new JFrame();

  // Build frame.
  splash.setBounds(createCenteredScreenBounds(350, 85));
  splash.setContentPane(new Panel());
  splash.setResizable(false);
  splash.setUndecorated(true);

  return splash;
}
 
Example 9
Source File: MisplacedBorder.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);

    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();

    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
 
Example 10
Source File: MisplacedBorder.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);

    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();

    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
 
Example 11
Source File: MisplacedBorder.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);

    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();

    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
 
Example 12
Source File: UI.java    From arcgis-runtime-demo-java with Apache License 2.0 5 votes vote down vote up
public static JFrame createWindow() {
  JFrame window = new JFrame();
  window.setUndecorated(true);
  window.setExtendedState(Frame.MAXIMIZED_BOTH);
  window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  window.getContentPane().setLayout(new BorderLayout(0, 0));
  return window;
}
 
Example 13
Source File: ImageWriter.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
private static BufferedImage renderImage(JPanel panel) {
  JFrame frame = new JFrame();
  frame.setUndecorated(true);
  frame.getContentPane().add(panel);
  frame.pack();
  BufferedImage bi = new BufferedImage(panel.getWidth(), panel.getHeight(), BufferedImage.TYPE_INT_ARGB);
  Graphics2D graphics = bi.createGraphics();
  panel.print(graphics);
  graphics.dispose();
  frame.dispose();
  return bi;
}
 
Example 14
Source File: VirtualCursor.java    From haxademic with MIT License 5 votes vote down vote up
public void setup() {
	super.setup();

	fxPanel = new JFXPanel();

	jframe = (JFrame)((PSurfaceAWT.SmoothCanvas) getSurface().getNative()).getFrame();
	jframe.removeNotify();
	jframe.setUndecorated(true);
	jframe.setLayout(null);
	jframe.addNotify();
	jframe.setAlwaysOnTop(true);
	jframe.add(fxPanel);
	jframe.setSize(750, 900);
	jframe.setVisible(true);
	jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	Platform.runLater(new Runnable() {
		@Override
		public void run() {
			initFX(fxPanel);
		}
	});
	// set special window properties
	jframe.setContentPane(fxPanel);
	fxPanel.setFocusable(false);
	fxPanel.setFocusTraversalKeysEnabled(false);
	fxPanel.requestFocus();
	fxPanel.requestFocusInWindow();
}
 
Example 15
Source File: MisplacedBorder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);

    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();

    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
 
Example 16
Source File: MisplacedBorder.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);

    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();

    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
 
Example 17
Source File: MisplacedBorder.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run() {
    final JMenuBar menubar = new JMenuBar();
    menubar.add(new JMenu(""));
    menubar.add(new JMenu(""));
    final JFrame frame = new JFrame();
    frame.setUndecorated(true);
    frame.setJMenuBar(menubar);
    frame.setSize(W / 3, H / 3);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);

    // draw menu bar using standard order.
    final BufferedImage bi1 = step1(menubar);

    // draw menu border on top of the menu bar, nothing should be changed.
    final BufferedImage bi2 = step2(menubar);
    frame.dispose();

    for (int x = 0; x < W; ++x) {
        for (int y = 0; y < H; ++y) {
            if (bi1.getRGB(x, y) != bi2.getRGB(x, y)) {
                try {
                    ImageIO.write(bi1, "png", new File("image1.png"));
                    ImageIO.write(bi2, "png", new File("image2.png"));
                } catch (IOException e) {
                    e.printStackTrace();
                }
                throw new RuntimeException("Failed: wrong color");
            }
        }
    }
}
 
Example 18
Source File: ImgWindow.java    From opencv-fun with GNU Affero General Public License v3.0 5 votes vote down vote up
public static ImgWindow newWindow (Mat mat, boolean undecorated) {
	JFrame frame = new JFrame();
	frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	frame.setSize(400, 400);
	frame.setUndecorated(undecorated);
	ImgWindow panel = new ImgWindow(frame);
	panel.setLayout(new FlowLayout(FlowLayout.LEFT));
	frame.add(panel);
	frame.setVisible(true);
	panel.setImage(mat);
	return panel;
}
 
Example 19
Source File: CredentialsDialog.java    From swift-k with Apache License 2.0 4 votes vote down vote up
public SwingCredentialsDialog(String title, Prompt[] prompts) {
    this.title = title;
    this.prompts = prompts;

    // the main panel
    JPanel main = new JPanel(new BorderLayout());
    titleLabel = new JLabel(title);
    titleLabel.setAlignmentX(0.5f);
    titleLabel.setFont(new Font("SansSerif", Font.BOLD, 16));
    main.add(titleLabel, BorderLayout.NORTH);
    // Labels
    GridBagLayout gbl = new GridBagLayout();
    JPanel lpane = new JPanel(gbl);
    GridBagConstraints gbc = new GridBagConstraints();

    lpane.setBorder(BorderFactory.createEmptyBorder(8, 0, 0, 0));

    labels = new JLabel[prompts.length];
    fields = new JTextComponent[prompts.length];
    browse = new JButton[prompts.length];

    for (int i = 0; i < prompts.length; i++) {
        labels[i] = new JLabel(prompts[i].label);
        labels[i].setFont(new Font("SansSerif", Font.BOLD, 14));
        lpane.add(labels[i]);
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridy = i;
        gbc.gridx = 0;
        gbc.weightx = 0.0;
        gbl.setConstraints(labels[i], gbc);

        switch (prompts[i].type) {
            case Prompt.TYPE_TEXT:
                fields[i] = new JTextField();
                break;
            case Prompt.TYPE_HIDDEN_TEXT:
                fields[i] = new JPasswordField();
                break;
            case Prompt.TYPE_FILE:
                fields[i] = new JTextField();
        }
        fields[i].addFocusListener(this);
        fields[i].setSize(fields[i].getPreferredSize().height + 8, 120);
        fields[i].addKeyListener(this);
        if (prompts[i].def != null) {
            fields[i].setText(prompts[i].def);
        }
        lpane.add(fields[i]);
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = 1;
        gbc.weightx = 1.0;
        gbl.setConstraints(fields[i], gbc);
        if (prompts[i].type == Prompt.TYPE_FILE) {
            browse[i] = new JButton("...");
            browse[i].addActionListener(this);
            lpane.add(browse[i]);
            gbc.gridx = 2;
            gbc.weightx = 0.0;
            gbl.setConstraints(browse[i], gbc);
        }
        if (prompts[i].def == null && focusIndex == -1) {
            focusIndex = i;
        }
    }

    main.add(lpane, BorderLayout.CENTER);
    main.setBorder(BorderFactory.createCompoundBorder(BorderFactory
        .createLineBorder(Color.BLACK, 1), BorderFactory
        .createEmptyBorder(8, 8, 8, 8)));

    dialog = new JFrame();
    dialog.setTitle("SSH " + title);
    dialog.getContentPane().add(main);
    dialog.setSize(Math.max(320, titleLabel.getPreferredSize().width),
        titleLabel.getPreferredSize().height + prompts.length
                * (labels[0].getPreferredSize().height + 8) + 24);
    dialog.setLocationRelativeTo(null);
    dialog.setUndecorated(true);
}
 
Example 20
Source File: FullScreenUtils.java    From WorldGrower with GNU General Public License v3.0 4 votes vote down vote up
public static void makeFullScreen(JFrame frame) {
	frame.setExtendedState(JFrame.MAXIMIZED_BOTH); 
	frame.setUndecorated(true);
	frame.setResizable(false);
}