Java 8 JWindow - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JWindow class.

This code example shows how to use the following methods:addMouseListener, setSize, setVisible
import test.java.awt.regtesthelpers.Util; 
 
public class GrabOnUnfocusableToplevel { 
    public static void main(String[] args) {
        Robot r = Util.createRobot();
        JWindow w = new JWindow();
        w.setSize(100, 100);
        w.setVisible(true);
        Util.waitForIdle(r);
 
        final JPopupMenu menu = new JPopupMenu();
        JButton item = new JButton("A button in popup");
 
        menu.add(item);
 
        w.addMouseListener(new MouseAdapter() {
                public void mousePressed(MouseEvent me) {
                menu.show(me.getComponent(), me.getX(), me.getY());
 
                System.out.println("Showing menu at " + menu.getLocationOnScreen() +

6
CodeRank
This code example shows how to use the following methods:addMouseListener, validate, setLocation, setSize, setVisible
    if (m_previewWindow == null) {
       
      JLabel jl = new JLabel(m_subFlowPreview);
      //Dimension d = jl.getPreferredSize(); 
      jl.setLocation(0,0);
      m_previewWindow = new JWindow();
      //popup.getContentPane().setLayout(null); 
      m_previewWindow.getContentPane().add(jl);
      m_previewWindow.validate();
      m_previewWindow.setSize(m_subFlowPreview.getIconWidth(), m_subFlowPreview.getIconHeight());
       
      m_previewWindow.addMouseListener(new MouseAdapter() {
	  public void mouseClicked(MouseEvent e) {
	    m_previewWindow.dispose();
	    m_previewWindow = null;
	  } 
	}); 
       
      m_previewWindow.setLocation(
	  getParent().getLocationOnScreen().x + getX() + getWidth() / 2 - 

6
CodeRank
This code example shows how to use the following methods:add, setSize, setVisible
This code example shows how to use the following methods:add, setAlwaysOnTop, setLocation, setSize
     * @return 
     */ 
    private static JWindow createWindow(Icon icon, String head, String body, int posx, int posy, Color backgroundcolor,
            Color headerColor, Color messageColor) {
 
        final JWindow window = new JWindow();
        JPanel windowpanel = new JPanel(new GridBagLayout());
        windowpanel.setBackground(backgroundcolor);
 
        AWTUtilities.setWindowShape(window, new RoundRectangle2D.Float(0, 0, WIDTH, HEIGHT, 20, 20));
        AWTUtilities.setWindowOpaque(window, true);
 
        JLabel text = new JLabel("<HTML>" + body + "</HTML>");
        text.setForeground(messageColor);
 
        JLabel header = new JLabel(head);
        header.setForeground(headerColor);
        header.setFont(new Font(header.getFont().getName(), Font.BOLD, header.getFont().getSize() + 2));
 
        windowpanel.add(new JLabel(icon), new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER,

5
CodeRank
This code example shows how to use the following methods:getBounds, pack, setLocation, setVisible
        int        left       = loc.x;
        if (left < 0) {
            left = 0;
        } 
 
        int right = left + window.getBounds().width;
        if (right > screenSize.width) {
            left += screenSize.width - right;
        } 
 
 
        int top    = loc.y + contents.bounds().height;
        int bottom = top + window.getBounds().height;
 
        if (bottom > screenSize.height) {
            top += screenSize.height - bottom - 10;
        } 
 
 
        window.setLocation(left, top);

5
CodeRank
This code example shows how to use the following methods:setBounds, getContentPane
	public MySplash(){ 
		createSplash(); 
	} 
 
	private void createSplash() { 
		jw = new JWindow();
	    content = (JPanel) jw.getContentPane();
	    content.setBackground(Color.white);
 
	    // Set the window's bounds, centering the window 
	    int width = 328;
	    int height = 131;
	    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
	    int x = (screen.width - width) / 2;
	    int y = (screen.height - height) / 2;
	    jw.setBounds(x, y, width, height);
 
	    // Build the splash screen 
	    label = new JLabel(new ImageIcon("media_assets/splash.jpg"));
	    content.add(label, BorderLayout.CENTER);
 
5
CodeRank
This code example shows how to use the following methods:setBounds, setVisible, getContentPane
    } 
 
    private void showCellExtender(Rectangle windowRect) {
        final Rectangle screenBounds = convertToScreen(tree, windowRect);
        if (cellExtender == null) {
            cellExtender = new JWindow(SwingUtilities.getWindowAncestor(tree));
            cellExtender.getContentPane().add(new CellExtenderPanel(), BorderLayout.CENTER);
        } 
        cellExtender.setBounds(screenBounds);
        cellExtender.setVisible(true);
    } 
 
    private void hideCellExtender() { 
        if (cellExtender != null) {
            cellExtender.setVisible(false);
        } 
    } 
 
    private void disposeCellExtender() { 
        if (cellExtender != null) {
5
CodeRank
This code example shows how to use the following methods:getLocation, setLocation
		addMouseMotionListener(new MouseMotionAdapter() {
 
			@Override 
			public void mouseDragged(MouseEvent e) {
				// get location of Window 
				int thisX = parent.getLocation().x;
				int thisY = parent.getLocation().y;
 
				// Determine how much the mouse moved since the initial click 
				int xMoved = (thisX + e.getX()) - (thisX + initialClick.x);
				int yMoved = (thisY + e.getY()) - (thisY + initialClick.y);
 
				// Move window to this position 
				int X = thisX + xMoved;
				int Y = thisY + yMoved;
				parent.setLocation(X, Y);
			} 
		}); 
 
	} 
 
5
CodeRank
This code example shows how to use the following methods:getRootPane
            Method setWindowOpaque = awtutil.getMethod("setWindowOpacity", Window.class,
                    float.class); 
            setWindowOpaque.invoke(null, window, alpha);
        } catch (Exception ex) {
            if (OSUtils.isMacOSX()) { 
                window.getRootPane().putClientProperty("Window.alpha", new Float(alpha));// mac
            } 
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:isVisible
	 * 
	 * @return Whether this tool tip is visible. 
	 * @see #setVisible(boolean) 
	 */ 
	public boolean isVisible() { 
		return tooltip.isVisible();
	} 
 
 
	/** 
	 * Sets the location of this tool tip relative to the given rectangle. 
	 * 
	 * @param r The visual position of the caret (in screen coordinates). 
	 */ 
	public void setLocationRelativeTo(Rectangle r) {
 
		// Multi-monitor support - make sure the completion window (and 
		// description window, if applicable) both fit in the same window in 
		// a multi-monitor environment.  To do this, we decide which monitor 
		// the rectangle "r" is in, and use that one (just pick top-left corner 
3
CodeRank
See Code Examples for Java 8 JWindow Methods: