Java Code Examples for javax.swing.JWindow

The following are top voted examples for showing how to use javax.swing.JWindow. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: owa-notifier   File: WindowNotification.java   View source code 7 votes vote down vote up
public WindowNotification() {
	m_window = new JWindow();
	m_window.setAlwaysOnTop(true);

	m_listener = new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			fireListeners(CLICKED);
			if (m_closeOnClick)
				removeFromManager();
		}
	};

	setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
	setPanel(new JPanel());
}
 
Example 2
Project: incubator-netbeans   File: MorePropertySheetTest.java   View source code 6 votes vote down vote up
public void testSetNodesSurvivesMultipleAdd_RemoveNotifyCalls() throws Exception {
    final PropertySheet ps = new PropertySheet();
    Node n = new AbstractNode( Children.LEAF );
    JWindow window = new JWindow();
    ps.setNodes( new Node[] {n} );
    window.add( ps );
    window.remove( ps );
    window.add( ps );
    window.remove( ps );
    window.add( ps );
    window.remove( ps );
    window.setVisible(true);
    assertNotNull(ps.helperNodes);
    assertEquals("Helper nodes are still available even after several addNotify()/removeNotify() calls",
            ps.helperNodes[0], n);
}
 
Example 3
Project: incubator-netbeans   File: TooltipWindow.java   View source code 6 votes vote down vote up
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());

    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
Example 4
Project: incubator-netbeans   File: TooltipWindow.java   View source code 6 votes vote down vote up
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());
    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);
    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
Example 5
Project: incubator-netbeans   File: TooltipWindow.java   View source code 6 votes vote down vote up
public void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel(master.getTextComponent());

    Window w = SwingUtilities.windowForComponent(master.getTextComponent());
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y - 1);  // slight visual adjustment
    contentWindow.setVisible(true);

    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
}
 
Example 6
Project: openjdk-jdk10   File: JemmyExt.java   View source code 6 votes vote down vote up
public static int getJWindowCount() {
    return new QueueTool().invokeAndWait(new QueueTool.QueueAction<Integer>(null) {

        @Override
        public Integer launch() throws Exception {
            Window[] windows = Window.getWindows();
            int windowCount = 0;
            for (Window w : windows) {
                if (w.getClass().equals(JWindow.class)) {
                    windowCount++;
                }
            }
            return windowCount;
        }
    });
}
 
Example 7
Project: openjdk-jdk10   File: JemmyExt.java   View source code 6 votes vote down vote up
public static JWindow getJWindow(int index) {
    return new QueueTool().invokeAndWait(new QueueTool.QueueAction<JWindow>(null) {

        @Override
        public JWindow launch() throws Exception {
            Window[] windows = Window.getWindows();
            int windowIndex = 0;
            for (Window w : windows) {
                if (w.getClass().equals(JWindow.class)) {
                    if (windowIndex == index) {
                        return (JWindow) w;
                    }
                    windowIndex++;
                }
            }
            return null;
        }
    });
}
 
Example 8
Project: openjdk9   File: JemmyExt.java   View source code 6 votes vote down vote up
public static int getJWindowCount() {
    return new QueueTool().invokeAndWait(new QueueTool.QueueAction<Integer>(null) {

        @Override
        public Integer launch() throws Exception {
            Window[] windows = Window.getWindows();
            int windowCount = 0;
            for (Window w : windows) {
                if (w.getClass().equals(JWindow.class)) {
                    windowCount++;
                }
            }
            return windowCount;
        }
    });
}
 
Example 9
Project: openjdk9   File: JemmyExt.java   View source code 6 votes vote down vote up
public static JWindow getJWindow(int index) {
    return new QueueTool().invokeAndWait(new QueueTool.QueueAction<JWindow>(null) {

        @Override
        public JWindow launch() throws Exception {
            Window[] windows = Window.getWindows();
            int windowIndex = 0;
            for (Window w : windows) {
                if (w.getClass().equals(JWindow.class)) {
                    if (windowIndex == index) {
                        return (JWindow) w;
                    }
                    windowIndex++;
                }
            }
            return null;
        }
    });
}
 
Example 10
Project: PhET   File: KSUCreditsWindow.java   View source code 6 votes vote down vote up
public static JWindow show( Frame parent ) {
    final JWindow window = new KSUCreditsWindow( parent );
    SwingUtils.centerInParent( window );
    window.setVisible( true );

    /*
    *  Dispose of ksuCreditsWindow after N seconds.
    *  Take care to call dispose in the Swing thread.
    */
    Timer timer = new Timer( 4000, new ActionListener() {
        public void actionPerformed( ActionEvent e ) {
            if ( window.isDisplayable() ) {
                window.dispose();
            }
        }
    } );
    timer.setRepeats( false );
    timer.start();

    return window;
}
 
Example 11
Project: PhET   File: PhetJComponent.java   View source code 6 votes vote down vote up
public static void init( Window applicationWindow ) {


        if ( inited ) {
            throw new RuntimeException( "Multiple inits." );
        }

//        System.out.println( "Setting repaintManagerPhet." );
        RepaintManager.setCurrentManager( repaintManagerPhet );

        offscreen = new JWindow( applicationWindow ) {
            public void invalidate() {
            }

            public void paint( Graphics g ) {
            }
        };       //this seems to work.  I thought you might have needed a visible component, though (maybe for some JVM implementations?)
//        System.out.println( "offscreen.getOwner() = " + offscreen.getOwner() );

//        offscreen.getOwner().setVisible( true );
        offscreen.setSize( 0, 0 );
        offscreen.setVisible( true );
        offscreenContentPane.setOpaque( false );
        offscreen.setContentPane( offscreenContentPane );
        inited = true;
    }
 
Example 12
Project: JavaAyo   File: WindowNotification.java   View source code 6 votes vote down vote up
public WindowNotification() {
	m_window = new JWindow();
	m_window.setAlwaysOnTop(true);

	m_listener = new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			fireListeners(CLICKED);
			if (m_closeOnClick)
				removeFromManager();
		}
	};

	setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
	setPanel(new JPanel());
}
 
Example 13
Project: JavaAyo   File: SequentialNotificationManager.java   View source code 6 votes vote down vote up
/**
 * Shows the notification
 * @param window window to show
 */
protected static void showNotification(final JWindow window) {
	try {
		sLock.lock();
		sWindows.addLast(window);
		window.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosed(WindowEvent e) {
				window.removeWindowListener(this);
				sWindowOpen = false;
				nextWindow();
			}
		});
		nextWindow();
	} finally {
		sLock.unlock();
	}
}
 
Example 14
Project: JavaAyo   File: SequentialNotificationManager.java   View source code 6 votes vote down vote up
/**
 * shows the next window on the stack
 */
private static void nextWindow() {
	try {
		sLock.lock();
		if(!sWindowOpen && sWindows.size() > 0) {
			sWindowOpen = true;
			final JWindow window = sWindows.removeFirst();
			Timer delayVisibleTimer = new Timer(DELAY, new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					final Timer t = (Timer) e.getSource();
					t.stop();
					window.setVisible(true);
					window.getGlassPane().setVisible(true);

				}
			});
			delayVisibleTimer.start();
		}
	} finally {
		sLock.unlock();
	}
}
 
Example 15
Project: LuoYing   File: Jfx.java   View source code 6 votes vote down vote up
/**
 * 创建JWindow,该Window用于作为Jfx组件的容器,这个window始终覆盖在frame上。
 * @param ms
 * @param mainFrame
 * @param jfxRoot
 * @return 
 */
private static JWindow createJWindow(JFrame parent, final Pane jfxRoot) {
    JWindow jwin = new JWindow(parent);
    jwin.setLocationRelativeTo(null);
    jwin.setVisible(true);
    
    jfxPanel = new JFXPanel();
    jwin.getContentPane().add(jfxPanel);

    Platform.runLater(() -> {
        // 设置JFX主场景,并让JFX主界面变得透明,这样不会覆盖整个Canvas.
        jfxRoot.setBackground(Background.EMPTY);
        jfxPanel.setScene(new Scene(jfxRoot, Color.TRANSPARENT));
    });
    return jwin;
}
 
Example 16
Project: theSemProject   File: AutoSuggestor.java   View source code 6 votes vote down vote up
/**
 * Istanzia il suggeritore su un componente testo
 *
 * @param textComp finestra di testo su cui istanziare il suggeritore
 * @param mainWindow finestra principale
 * @param words lista di parole
 * @param popUpBackground colore dello sfondo
 * @param textColor colore del testo
 * @param suggestionFocusedColor colore del suggeritore
 * @param opacity indice di opacità
 */
public AutoSuggestor(JTextComponent textComp, Window mainWindow, List<String> words, Color popUpBackground, Color textColor, Color suggestionFocusedColor, float opacity) {
    this.textComp = textComp;
    this.suggestionsTextColor = textColor;
    this.container = mainWindow;
    this.suggestionFocusedColor = suggestionFocusedColor;
    this.textComp.getDocument().addDocumentListener(documentListener);

    setDictionary(words);

    typedWord = "";
    currentIndexOfSpace = 0;
    tW = 0;
    tH = 0;

    autoSuggestionPopUpWindow = new JWindow(mainWindow);
    autoSuggestionPopUpWindow.setOpacity(opacity);

    suggestionsPanel = new JPanel();
    suggestionsPanel.setLayout(new GridLayout(0, 1));
    suggestionsPanel.setBackground(popUpBackground);
    suggestionsPanel.setBorder(new LineBorder(Color.black));

    addKeyBindingToRequestFocusInPopUpWindow();
}
 
Example 17
Project: beautyeye   File: TranslucentPopupFactory.java   View source code 6 votes vote down vote up
/**
 * Frees any resources the <code>Popup</code> may be holding onto.
 */
protected void dispose()
{
	Component component = getComponent();
	Window window = SwingUtilities.getWindowAncestor(component);

	if (component instanceof JWindow)
	{
		((Window) component).dispose();
		component = null;
	}
	// If our parent is a DefaultFrame, we need to dispose it, too.
	if (window instanceof DefaultFrame)
	{
		window.dispose();
	}
}
 
Example 18
Project: JCommunique   File: WindowNotification.java   View source code 6 votes vote down vote up
public WindowNotification() {
	m_window = new JWindow();
	m_window.setAlwaysOnTop(true);

	m_listener = new MouseAdapter() {
		@Override
		public void mouseClicked(MouseEvent e) {
			fireListeners(CLICKED);
			if (m_closeOnClick)
				removeFromManager();
		}
	};

	setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
	setPanel(new JPanel());
}
 
Example 19
Project: chatty   File: AutoCompletion.java   View source code 6 votes vote down vote up
/**
 * Creates the window for the info popup. This should only be run once and
 * then reused, only changing the text and size.
 */
private void createInfoWindow() {
    infoWindow = new JWindow(SwingUtilities.getWindowAncestor(textField));
    infoLabel = new JLabel();
    infoWindow.add(infoLabel);
    JPanel contentPane = (JPanel) infoWindow.getContentPane();
    Border border = BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.GRAY),
            BorderFactory.createEmptyBorder(2, 4, 2, 4));
    contentPane.setBorder(border);
    contentPane.setBackground(HtmlColors.decode("#EEEEEE"));
    infoLabel.setFont(textField.getFont());

    /**
     * Hide the info popup if the textfield or containing window is changed
     * in any way.
     */
    containingWindow = SwingUtilities.getWindowAncestor(textField);
    if (containingWindow != null) {
        containingWindow.addComponentListener(componentListener);
    }
    textField.addComponentListener(componentListener);
}
 
Example 20
Project: mindraider   File: SplashScreen.java   View source code 6 votes vote down vote up
/**
 * Constructor.
 * 
 * @param parent
 * @param isApplet
 */
public SplashScreen(JFrame parent, boolean isApplet) {
    this.isApplet = isApplet;

    splashLabel = new JLabel(IconsRegistry.getImageIcon("splash.gif"));

    if (!isApplet) {
        splashScreen = new JWindow(parent);
        splashScreen.getContentPane().add(splashLabel);
        splashScreen.pack();
        Rectangle screenRect = parent.getGraphicsConfiguration()
                .getBounds();
        splashScreen
                .setLocation(screenRect.x + screenRect.width / 2
                        - splashScreen.getSize().width / 2, screenRect.y
                        + screenRect.height / 2
                        - splashScreen.getSize().height / 2);
    }
}
 
Example 21
Project: mpcmaid   File: MPCMaid.java   View source code 6 votes vote down vote up
public static void showSplash() {
	screen = new JWindow();
	final URL resource = MainFrame.class.getResource("mpcmaidlogo400_400.png");
	final JLabel label = new JLabel(new ImageIcon(resource));
	screen.getContentPane().add(label);
	screen.setLocationRelativeTo(null);
	Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
	Dimension labelSize = screen.getPreferredSize();
	screen
			.setLocation(screenSize.width / 2 - (labelSize.width / 2), screenSize.height / 2
					- (labelSize.height / 2));
	screen.pack();
	screen.setVisible(true);
	label.repaint();
	screen.repaint();
}
 
Example 22
Project: AppWoksUtils   File: SyntheticaHelper.java   View source code 6 votes vote down vote up
protected static boolean checkIfMacInitWillFail() {

        // synthetica init fails on mac if there are already active windows
        Window awindow[];
        final int j = (awindow = Window.getWindows()).length;

        for (int i = 0; i < j; i++) {
            final Window window = awindow[i];

            final boolean flag = !(window instanceof JWindow) && !(window instanceof JFrame) && !(window instanceof JDialog);
            if (!window.getClass().getName().contains("Popup$HeavyWeightWindow") && !flag) {
                return true;
            }

        }
        return false;
    }
 
Example 23
Project: Swing9patch   File: CoolPopupFactory.java   View source code 6 votes vote down vote up
/**
 * Frees any resources the <code>Popup</code> may be holding onto.
 */
protected void dispose()
{
	Component component = getComponent();
	Window window = SwingUtilities.getWindowAncestor(component);

	if (component instanceof JWindow)
	{
		((Window) component).dispose();
		component = null;
	}
	// If our parent is a DefaultFrame, we need to dispose it, too.
	if (window instanceof DefaultFrame)
	{
		window.dispose();
	}
}
 
Example 24
Project: metasfresh   File: CompiereColor.java   View source code 6 votes vote down vote up
/**
 *  Set Background of Window Content Pane
 *  @param win window
 *  @param cc adempiere color
 */
public static void setBackground (Window win, CompiereColor cc)
{
	if (win instanceof JDialog)
	{
		((JPanel)((JDialog)win).getContentPane()).putClientProperty(AdempiereLookAndFeel.BACKGROUND, cc);
	//	((JPanel)((JDialog)win).getContentPane()).setName("contentPane");
	}
	else if (win instanceof JFrame)
	{
		((JPanel)((JFrame)win).getContentPane()).putClientProperty(AdempiereLookAndFeel.BACKGROUND, cc);
	//	((JPanel)((JFrame)win).getContentPane()).setName("contentPane");
	}
	else if (win instanceof JWindow)
	{
		((JPanel)((JWindow)win).getContentPane()).putClientProperty(AdempiereLookAndFeel.BACKGROUND, cc);
	//	((JPanel)((JWindow)win).getContentPane()).setName("contentPane");
	}
}
 
Example 25
Project: webanno   File: WebAnno.java   View source code 6 votes vote down vote up
public static void main(String[] args) throws Exception
{
    Optional<JWindow> splash = LoadingSplashScreen
            .setupScreen(WebAnno.class.getResource("splash.png"));
    
    SpringApplicationBuilder builder = new SpringApplicationBuilder();
    // Signal that we may need the shutdown dialog
    builder.properties("running.from.commandline=true");
    init(builder);
    builder.sources(WebAnno.class);
    builder.listeners(event -> {
        if (event instanceof ApplicationReadyEvent
                || event instanceof ShutdownDialogAvailableEvent) {
            splash.ifPresent(it -> it.dispose());
        }
    });
    builder.run(args);
}
 
Example 26
Project: sp16-ceg3120   File: SplashScreen.java   View source code 6 votes vote down vote up
/** Construct a splash screen. */
public void showSplashScreen() {
	// create window, apply image
	JWindow window = new JWindow();
	ImageIcon icon = new ImageIcon("img/SQLizard.jpg");
	JLabel label = new JLabel(icon);

	window.add(label);

	Toolkit tk = Toolkit.getDefaultToolkit();
	int width = ((int) tk.getScreenSize().getWidth());
	int height = ((int) tk.getScreenSize().getHeight());

	window.setBounds((width / 2) - 440, (height / 2) - 245, 880, 495);
	window.setVisible(true);

	// provide splash screen loading effect
	try {
		Thread.sleep(2000);
	} catch (InterruptedException e) {
		e.printStackTrace();
	}

	window.setVisible(false);
}
 
Example 27
Project: SplashScreen   File: SwingSplashScreen.java   View source code 6 votes vote down vote up
SwingSplashScreen(BufferedImage image, int width, int height) {
        window = new JWindow((Window) null);
        window.setBackground(new Color(0, 0, 0, 0));
        window.setSize(width, height);
        window.setLocationRelativeTo(null);

        // alwaysOnTop keeps the LWJGL2 Display window from popping up and it can't be triggered manually
//        window.setAlwaysOnTop(true);

        window.add(new Component() {

            private static final long serialVersionUID = 1717818903226627606L;

            @Override
            public void paint(Graphics g) {
                if (image != null) {
                    g.drawImage(image, 0, 0, width, height, null);
                }
                for (Overlay overlay : getOverlays()) {
                    overlay.render((Graphics2D) g);
                }
            }
        });

        window.setVisible(true);
    }
 
Example 28
Project: ireport-fork   File: ApplePopupFactory.java   View source code 6 votes vote down vote up
private static JWindow checkOutWindow() {
    if (windowPool != null) {
        if (!windowPool.isEmpty()) {
            for (Iterator<Reference<JWindow>> i=windowPool.iterator(); i.hasNext();) {
                Reference<JWindow> ref = i.next();
                JWindow win = ref.get();
                i.remove();
                if (win != null) {
                    assert !win.isShowing();
                    win.setBounds (0, 0, 1, 1);
                    win.getContentPane().removeAll();
                    win.setBackground (new java.awt.Color (255, 255, 255, 0));
                    return win;
                }
            }
        }
    }
    JWindow nue = APPLE_COCOA_HACK ? (JWindow) new HackedJWindow() : new JWindow();
    
    nue.setBackground (new java.awt.Color (255, 255, 255, 0));
    return nue;
}
 
Example 29
Project: concurrent   File: TranslucentPopupFactory.java   View source code 6 votes vote down vote up
/**
 * Frees any resources the <code>Popup</code> may be holding onto.
 */
protected void dispose()
{
	Component component = getComponent();
	Window window = SwingUtilities.getWindowAncestor(component);

	if (component instanceof JWindow)
	{
		((Window) component).dispose();
		component = null;
	}
	// If our parent is a DefaultFrame, we need to dispose it, too.
	if (window instanceof DefaultFrame)
	{
		window.dispose();
	}
}
 
Example 30
Project: polydes   File: LinkReferenceChooser.java   View source code 6 votes vote down vote up
public LinkReferenceChooser(JWindow owner, Link link)
{
	super(owner != null ? owner : SW.get());
	setFocusable(true);
	setSize(WIDTH, HEIGHT);
	
	this.link = link;
	listeners = new ArrayList<ActionListener>();
	
	add(createContentPanel(), BorderLayout.CENTER);
	
	addWindowFocusListener(new WindowAdapter()
	{
		@Override
		public void windowLostFocus(WindowEvent e)
		{
			dispose();
		}
	});
}
 
Example 31
Project: LVPDTool   File: SplashScreen.java   View source code 6 votes vote down vote up
public static void splashInit() {
    JWindow window = new JWindow();
    java.net.URL imgURL = SplashScreen.class.getResource("resources/images/SplashScreen.png");
    window.getContentPane().add(
            new JLabel("", new ImageIcon(imgURL), SwingConstants.CENTER));
    window.setBounds(500, 150, 300, 200);
    window.setSize(500, 400);
    
    java.awt.Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); 
    window.setLocation(dim.width/2-window.getSize().width/2, dim.height/2-window.getSize().height/2);
    
    setupAudio();
    window.setVisible(true);

    try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {
        System.out.println("Caught InterrupedException");
    }
    
    window.setVisible(false);
    window.dispose();
}
 
Example 32
Project: fx-experience   File: StandAloneApp.java   View source code 6 votes vote down vote up
@Override
public void init() {

  setLayout(new BorderLayout());

  // create javafx panel
  final JFXPanel javafxPanel = new JFXPanel();
  javafxPanel.setFocusable(false);
  javafxPanel.setOpaque(false);

  add(javafxPanel, BorderLayout.CENTER);

  JWindow fxKeyboard = new JWindow();
  fxKeyboard.setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
  fxKeyboard.getContentPane().add(javafxPanel);
  fxKeyboard.setFocusable(false);
  fxKeyboard.setBackground(null);

  fxKeyboard.pack();
  fxKeyboard.setLocationByPlatform(true);

  // create JavaFX scene
  Platform.runLater(() -> createScene(javafxPanel));

}
 
Example 33
Project: MesquiteCore   File: MesquiteFileDialog.java   View source code 6 votes vote down vote up
public MesquiteFileDialog (MesquiteWindow f, String message, int type) {
	super(getFrame(f), message, type);
	if (type == FileDialog.LOAD &&  (MesquiteTrunk.isMacOS() || MesquiteTrunk.isMacOSX()) && MesquiteTrunk.getOSXVersion()>10){
		titleWindow = new JWindow(); 
		titleWindow.setSize(twWidth,twHeight);
		titleWindowLabel = new Label();
		titleWindowLabel.setBackground(ColorDistribution.veryLightYellow); //ColorTheme.getExtInterfaceBackground()); //ColorDistribution.veryLightGray
		titleWindow.add(titleWindowLabel);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		int v, h;
		h = (screenSize.width-twWidth)/2;
		v = 26;
		titleWindow.setLocation(h, v);
		titleWindowLabel.setText("  " + message);
	//	Color darkBlue = new Color((float)0.0, (float)0.0, (float)0.7);
		titleWindowLabel.setForeground(ColorDistribution.darkBlue); //ColorTheme.getExtInterfaceElement(true));

	}
	this.message = message;
	this.type = type;
	currentFileDialog = this;
	//mfdThread = new MFDThread(this);
	//mfdThread.start();
	MainThread.incrementSuppressWaitWindow();
}
 
Example 34
Project: incubator-netbeans   File: CustomPopupFactory.java   View source code 5 votes vote down vote up
@Override
protected void prepareResources() {
    window = new JWindow(SwingUtilities.getWindowAncestor(owner));
    window.setType(JWindow.Type.POPUP);
    window.getContentPane().add (contents);
    window.setLocation (new Point (x, y));
    window.pack();
    disableShadow(window);
}
 
Example 35
Project: incubator-netbeans   File: CustomPopupFactory.java   View source code 5 votes vote down vote up
private static void safeSetBackground(JWindow window, Color background) {
    GraphicsConfiguration gc = window.getGraphicsConfiguration();
    
    if (!gc.isTranslucencyCapable()) return; // PERPIXEL_TRANSLUCENT not supported
    if (gc.getDevice().getFullScreenWindow() == window) return; // fullscreen windows not supported
    
    window.setBackground(background);
}
 
Example 36
Project: incubator-netbeans   File: MsgTooltipWindow.java   View source code 5 votes vote down vote up
void show(Point location) {
    Rectangle screenBounds = null;
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice[] gds = ge.getScreenDevices();
    for (GraphicsDevice device : gds) {
        GraphicsConfiguration gc = device.getDefaultConfiguration();
        screenBounds = gc.getBounds();
        if (screenBounds.contains(location)) {
            break;
        }
    }

    // showing the popup tooltip
    cp = new TooltipContentPanel();
    Window w = SwingUtilities.windowForComponent(parent);
    contentWindow = new JWindow(w);
    contentWindow.add(cp);
    contentWindow.pack();
    Dimension dim = contentWindow.getSize();

    if (screenBounds.width + screenBounds.x - location.x < cp.longestLine) {
        // the whole window does fully not fit to the right
        // the x position where the window has to start to fully fit to the right
        int left = screenBounds.width + screenBounds.x - cp.longestLine;
        // the window should have x pos minimally at the screen's start
        location.x = Math.max(screenBounds.x, left);
    }
    
    if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
        dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
    }
    if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
        dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
    }

    contentWindow.setSize(dim);

    contentWindow.setLocation(location.x, location.y + 1);  // slight visual adjustment
    
    contentWindow.setVisible(true);
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            cp.scrollRectToVisible(new Rectangle(1, 1));
        }
    });
    Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
    w.addWindowFocusListener(this);
    contentWindow.addWindowFocusListener(this);
    contentWindow.addKeyListener(this);
    w.addKeyListener(this);
}
 
Example 37
Project: incubator-netbeans   File: MultiSplitPaneTest.java   View source code 5 votes vote down vote up
protected void setUp() throws Exception {
    split = new MultiSplitPane();
    split.setDividerSize( DIVIDER_SIZE );
    
    testWindow = new JWindow();
    testWindow.setVisible( true );
    //testWindow.getContentPane().add( split );
}
 
Example 38
Project: incubator-netbeans   File: ProfilerTableHovers.java   View source code 5 votes vote down vote up
private static void safeSetBackground(JWindow window, Color background) {
    GraphicsConfiguration gc = window.getGraphicsConfiguration();
    
    if (!gc.isTranslucencyCapable()) return; // PERPIXEL_TRANSLUCENT not supported
    if (gc.getDevice().getFullScreenWindow() == window) return; // fullscreen windows not supported
    
    window.setBackground(background);
}
 
Example 39
Project: marathonv5   File: JSONOMapConfigTest.java   View source code 5 votes vote down vote up
public void findContainerNP() {
    List<List<String>> np = config.findContainerNP(Window.class);
    AssertJUnit.assertEquals(1, np.size());
    np = config.findContainerNP(JInternalFrame.class);
    AssertJUnit.assertEquals(1, np.size());
    np = config.findContainerNP(JWindow.class);
    AssertJUnit.assertEquals(2, np.size());
}
 
Example 40
Project: marathonv5   File: JSONOMapConfigTest.java   View source code 5 votes vote down vote up
public void findContainerNP() {
    List<List<String>> np = config.findContainerNP(Window.class);
    AssertJUnit.assertEquals(1, np.size());
    np = config.findContainerNP(JInternalFrame.class);
    AssertJUnit.assertEquals(1, np.size());
    np = config.findContainerNP(JWindow.class);
    AssertJUnit.assertEquals(2, np.size());
}