void test3(Window owner, Window child1, Window child2) { System.out.println("* * * STAGE 3 * * *\nWidow owner: " + owner); owner.setFocusableWindowState(true); owner.setVisible(true); child1.setFocusableWindowState(false); child1.setVisible(true); child2.setFocusableWindowState(true); child2.add(button); child2.setVisible(true); Util.waitTillShown(child2); Util.clickOnComp(button, robot); System.err.println( "focus owner: " + KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()); if (button != KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) { throw new RuntimeException("Test failed."); } child1.dispose(); child2.dispose(); owner.dispose(); }
private void showJPopupMenu(MouseEvent e) { try { if (e.isPopupTrigger() && menu != null) { if (window == null) { if (isWindows) { window = new JDialog((Frame) null); ((JDialog) window).setUndecorated(true); } else { window = new JWindow((Frame) null); } window.setAlwaysOnTop(true); Dimension size = menu.getPreferredSize(); Point centerPoint = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); if (e.getY() > centerPoint.getY()) window.setLocation(e.getX(), e.getY() - size.height); else window.setLocation(e.getX(), e.getY()); window.setVisible(true); menu.show(((RootPaneContainer) window).getContentPane(), 0, 0); // popup works only for focused windows window.toFront(); } } } catch (Exception ignored) { } }
public void putValue(String key, Object newValue) { super.putValue(key, newValue); if (key == Actions.SELECTED_KEY) { if (palette != null) { AbstractOSXApplication application = getApplication(); boolean b = (Boolean) newValue; if (b) { application.addPalette(palette); palette.setVisible(true); } else { application.removePalette(palette); palette.setVisible(false); } } } }
void test1(Window owner, Window child) { System.out.println("* * * STAGE 1 * * *\nWindow owner: " + owner); owner.setFocusableWindowState(false); owner.setVisible(true); child.add(button); child.setVisible(true); Util.waitTillShown(child); Util.clickOnComp(button, robot); if (button == KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()) { throw new RuntimeException("Test Failed."); } child.dispose(); owner.dispose(); }
public void setPalette(Window newValue) { AbstractOSXApplication application = getApplication(); if (palette != null) { palette.removeWindowListener(windowHandler); } palette = newValue; if (palette != null) { palette.addWindowListener(windowHandler); if (getValue(Actions.SELECTED_KEY) == Boolean.TRUE) { application.addPalette(palette); palette.setVisible(true); } else { application.removePalette(palette); palette.setVisible(false); } } }
/** * Show the window. * * @param container - Window of JFrame to show */ private void showPopup(Window container) { if (visibleComponent.isEnabled()) { Point pt = visibleComponent.getLocationOnScreen(); pt.translate(0, visibleComponent.getHeight()); container.setLocation(pt); container.toFront(); ApplicationManager.setCurrentlySelectedField(fieldName); if (container instanceof OntologySelector) { ((OntologySelector) container).makeVisible(); } else { container.setVisible(true); container.requestFocusInWindow(); } } }
public void setUiVisible(final boolean visible) { if (myPopup != null) { if (visible) { myPopup.show(); final Window window = getPopupWindow(); if (window != null && myRestoreWindowSize != null) { window.setSize(myRestoreWindowSize); myRestoreWindowSize = null; } } else { final Window window = getPopupWindow(); if (window != null) { myRestoreWindowSize = window.getSize(); window.setVisible(true); } } } }
/* This could live in the desktop script. However we'd like to get it on the screen as quickly as possible. */ public static void startSplashScreen() { int width = 275, height = 148; Window win = new Window(new Frame()); win.pack(); BshCanvas can = new BshCanvas(); can.setSize(width, height); // why is this necessary? Toolkit tk = Toolkit.getDefaultToolkit(); Dimension dim = tk.getScreenSize(); win.setBounds(dim.width / 2 - width / 2, dim.height / 2 - height / 2, width, height); win.add("Center", can); Image img = tk.getImage(Interpreter.class.getResource("/bsh/util/lib/splash.gif")); MediaTracker mt = new MediaTracker(can); mt.addImage(img, 0); try { mt.waitForAll(); } catch (Exception e) { } Graphics gr = can.getBufferedGraphics(); gr.drawImage(img, 0, 0, can); win.setVisible(true); win.toFront(); splashScreen = win; }
/** * Hide the Window from view * * @param container - Window to hide. */ public void hidePopup(Window container) { if ((container != null) && container.isVisible()) { container.setVisible(false); } }
public void actionPerformed(ActionEvent e) { Object source = e.getSource(); JButton btn = (JButton) source; Window w = SwingUtilities.getWindowAncestor(btn); if (btn.getText().equals(usesword)) { boolean msword = false; for (String item : inventory) { String magicsword = "light saber"; // "magic sword"; if (!used1) { if (item.equals(magicsword)) { txtTranscript.insert( "An intense battle ensues! " // "\nCONGRATULATIONS! You have slain the dragon " + "The only audible noise is the sound of light sabers waving in the air " // "and reclaimed the Treasure of the Noontide Sol! " + "and crashing together. As the battle grows more intense, suddenly out " // "The light's morale has been restored to the land!\n" + "of nowhere Emporer Palpatine intervenes, forcing you to the ground. " + "You are paralyzed as powerful electrical pulses eminate from the " + "Emporer's fingertips, entering into your entire being. " + "Your father, Darth Vader will not let the Emporer kill you! " + "He picks up the Emporer and throws him over the edge of a bottomless pit of certain doom! " + "He has saved your life!!! " + "With this one act of love your father has returned to the light, " + "showing that the light side of the force is still in him. " + "GAME OVER - YOU HAVE WON!!!", txtTranscript.getText().length()); msword = true; used1 = false; w.setVisible(false); } } } if (!used1 && !msword) { txtTranscript.insert( "\nDarth Vader lunges forward to strike you with his light saber!!! " // "The dragon // blows flames // in your // direction!!! // " + "You got lucky! He narrowly missed!!!" + "\nCONGRATULATIONS! You're an idiot! " + "You don't have a light saber! " + "Better retreat for now...", txtTranscript.getText().length()); used1 = true; } else if (used1 && !msword) { txtTranscript.insert( "\nThe Mask doesn't seem to be working. " // ("\nThe dragon blows flames in your // direction " + "You are not so lucky this time. After stupidly trying the Hulk mask " + "again, Vader lunges forward with his saber, decapitating you instantly. " // the dragon engulfs you in flames, almost instantly incinerating you " + "...\nGAME OVER\n", txtTranscript.getText().length()); msword = true; used1 = false; w.setVisible(false); } } if (btn.getText().equals(usedagger)) { boolean dagger = false; for (String item : inventory) { if (item.equals("glowing hulk mask")) { // dagger")) { if (!used) { txtTranscript.insert( "\nThe Mask doesn't seem to be working. " + "Darth Vader lunges forward to strike you with his light saber!!! " // "The // dragon blows flames in your direction!!! " + "You got lucky! He narrowly missed!!! " + "Better try something else...", txtTranscript.getText().length()); dagger = true; used = true; } else { txtTranscript.insert( "\nThe Mask doesn't seem to be working. " // ("\nThe dragon blows flames in your // direction " + "You are not so lucky this time. After stupidly trying the Hulk mask " + "again, Vader lunges forward with his saber, decapitating you instantly. " // the dragon engulfs you in flames, almost instantly incinerating you " + "...\nGAME OVER\n", txtTranscript.getText().length()); used = false; // reset static used boolean to false in case player comes back w.setVisible(false); } } } if (!used && !dagger) { txtTranscript.insert( "\nThe Mask doesn't seem to be working. " + "Darth Vader lunges forward to strike you with his light saber!!! " // "The // dragon // blows // flames in // your // direction!!! " + "You got lucky! He narrowly missed!!! " + "Better try something else...", txtTranscript.getText().length()); /*("\nThe dragon blows flames in your direction!!! " + "You got lucky! The flames narrowly missed!!!" + "\nCONGRATULATIONS! You're an idiot! " + "You don't have a dagger! And if you did would it really help " + "against this dragon? Better try something else...", txtTranscript.getText().length());*/ used = true; } else if (used && !dagger) { txtTranscript.insert( "\nThe Mask doesn't seem to be working. " // ("\nThe dragon blows flames in your // direction " + "You are not so lucky this time. After stupidly trying the Hulk mask " + "again, Vader lunges forward with his saber, decapitating you instantly. " // the dragon engulfs you in flames, almost instantly incinerating you " + "...\nGAME OVER\n", txtTranscript.getText().length()); /*("\nThe dragon blows flames in your direction " + "You are not so lucky this time. After stupidly trying the dagger " + "again, THAT YOU DON'T HAVE! the dragon engulfs you in flames, almost instantly incinerating you " + "into a pile of ashes ...\nGAME OVER\n", txtTranscript.getText().length());*/ used = false; // reset static used boolean to false in case player comes back w.setVisible(false); } } if (btn.getText().equals(runaway)) { txtTranscript.insert( "\nRUN FOR IT MARTY!!!\nYou barely escape.", txtTranscript.getText().length()); used = false; // reset static used boolean to false in case player comes back w.setVisible(false); } }