Java Code Examples for java.awt.Window#add()

The following examples show how to use java.awt.Window#add() . 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: Test4759934.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 2
Source File: Test4759934.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 3
Source File: Test4759934.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 4
Source File: Test4759934.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 5
Source File: Test4759934.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 6
Source File: Test4759934.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 7
Source File: Test4319113.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window) {
    JButton jButton = new JButton("Show ColorChooser");
    jButton.setActionCommand("Show ColorChooser");
    jButton.addActionListener(this);
    this.cbPlaf = new JComboBox<UIManager.LookAndFeelInfo>(UIManager.getInstalledLookAndFeels());
    this.cbPlaf.addItemListener(new ItemListener(){

        @Override
        public void itemStateChanged(ItemEvent itemEvent) {
            if (itemEvent.getStateChange() == 1) {
                SwingUtilities.invokeLater(new Runnable(){

                    @Override
                    public void run() {
                        UIManager.LookAndFeelInfo lookAndFeelInfo = (UIManager.LookAndFeelInfo)Test4319113.this.cbPlaf.getSelectedItem();
                        try {
                            UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
                            Frame[] arrframe = Frame.getFrames();
                            int n = arrframe.length;
                            while (--n >= 0) {
                                Test4319113.updateWindowTreeUI(arrframe[n]);
                            }
                        }
                        catch (Exception var2_3) {
                            System.err.println("Exception while changing L&F!");
                        }
                    }
                });
            }
        }

    });
    window.add(this.cbPlaf);
    window.add(jButton);
    window.pack();
    window.setVisible(true);
}
 
Example 8
Source File: Test4759934.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 9
Source File: ChildWindowProperties.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void testPanelBackground() {
    Window window = new Frame();
    window.setBackground(Color.GREEN);
    Panel panel = new Panel();
    window.add(panel);
    window.pack();
    window.setVisible(true);
    if (panel.getBackground() != Color.GREEN) {
        window.dispose();
        throw new RuntimeException("Panel Background Color Not Valid");
    }
    window.dispose();
}
 
Example 10
Source File: Sage.java    From sagetv with Apache License 2.0 5 votes vote down vote up
private static void splashAndLicense()
{
  splashWindow = new Window(masterWindow);
  splashWindow.setLayout(new BorderLayout());
  Image theImage = null;
  String splashImageName;
  if (Sage.get("ui/splash_image", null) != null)
  {
    theImage = Toolkit.getDefaultToolkit().createImage(Sage.get("ui/splash_image", null));
    ImageUtils.ensureImageIsLoaded(theImage);
  }
  else
  {
    theImage = ImageUtils.fullyLoadImage(isTrueClient() ? (is64BitJVM() ? "images/splashclient64.gif" : "images/splashclient.gif") : 
                                                          (is64BitJVM() ? "images/splash64.gif"       : "images/splash.gif"      ));
  }
  ActiveImage splashImage = new ActiveImage(theImage);
  splashWindow.add(splashImage, "Center");
  splashText = new Label(Sage.rez("Module_Init", new Object[] { "Application" }), Label.CENTER)
  {
    public void paint(Graphics g)
    {
      super.paint(g);
      g.setColor(Color.black);
      g.drawRect(0, 0, getWidth()-1, getHeight()-1);
    }
  };
  splashText.setBackground(new Color(42, 103, 190));
  splashText.setForeground(Color.white);
  splashWindow.add(splashText, "South");
  Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
  splashWindow.pack();
  Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
  splashWindow.setLocation(center.x - splashWindow.getWidth()/2, center.y - splashWindow.getHeight()/2);
  splashWindow.setVisible(true);
}
 
Example 11
Source File: ChildWindowProperties.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void testChildPropertiesWithDialogAsParent() {

        parentDialog = new Dialog((Dialog) null, "parent Dialog");
        parentDialog.setSize(WIDTH, HEIGHT);
        parentDialog.setLocation(100, 100);
        parentDialog.setBackground(Color.RED);
        parentLabel = new Label("ParentForegroundAndFont");
        parentFont = new Font("Courier New", Font.ITALIC, 15);
        parentDialog.setForeground(Color.BLUE);
        parentDialog.setFont(parentFont);

        parentDialog.add(parentLabel);
        parentDialog.setVisible(true);

        windowChild = new Window(parentDialog);
        windowChild.setSize(WIDTH, HEIGHT);
        windowChild.setLocation(WIDTH + 200, 100);
        childLabel = new Label("ChildForegroundAndFont");
        windowChild.add(childLabel);
        windowChild.setVisible(true);

        if (parentDialog.getBackground() == windowChild.getBackground()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Dialog's Background Color");
        }
        if (parentDialog.getForeground() == windowChild.getForeground()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Dialog's Foreground Color");
        }
        if (parentDialog.getFont() == windowChild.getFont()) {
            dispose();
            throw new RuntimeException("Child Window Should NOT Inherit "
                    + "Parent Dialog's Font Color");
        }
    }
 
Example 12
Source File: DnDSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Window createDragWindow( Image dragImage, Rectangle bounds ) {
    Window w = new Window( SwingUtilities.windowForComponent(sourceRow) );
    w.add(new JLabel(ImageUtilities.image2Icon(dragImage)));
    w.setBounds(bounds);
    w.setVisible(true);
    NativeWindowSystem nws = NativeWindowSystem.getDefault();
    if( nws.isUndecoratedWindowAlphaSupported() ) {
        nws.setWindowAlpha(w, 0.7f);
    }
    return w;
}
 
Example 13
Source File: Test4759934.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 14
Source File: Test4759934.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 15
Source File: Test4759934.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 16
Source File: Test4759934.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private void show(Window window, String command) {
    JButton button = new JButton(command);
    button.setActionCommand(command);
    button.addActionListener(this);
    button.setFont(button.getFont().deriveFont(64.0f));

    window.add(button);
    window.pack();
    window.setVisible(true);
}
 
Example 17
Source File: RPSplash.java    From RipplePower with Apache License 2.0 4 votes vote down vote up
public RPSplash(Color progressBarColour, String imageResourcePath, String buildString, Color buildTextColour,
		int buildLabelX, int buildLabelY, String versionNumber, Color versionTextColour, int versionLabelX,
		int versionLabelY, boolean autonClose, final Updateable update) {

	this.buildTextColour = buildTextColour;
	this.buildLabelX = buildLabelX;
	this.buildLabelY = buildLabelY;
	this.versionTextColour = versionTextColour;
	this.versionLabelX = versionLabelX;
	this.versionLabelY = versionLabelY;

	progressColour = progressBarColour;
	setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
	setBackground(Color.white);

	gradientColour = UIRes.getBrighter(progressBarColour, 0.75);

	Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 11);
	setFont(font);
	fontMetrics = getFontMetrics(font);

	image = LImage.createImage(imageResourcePath).getBufferedImage();

	if (buildString != null) {
		build = buildString;
	}
	if (versionNumber != null) {
		version = versionNumber;
	}

	Dimension size = new Dimension(image.getWidth(this), image.getHeight(this));
	window = new Window(new Frame());
	window.setSize(size);
	window.setLayout(new BorderLayout());
	window.add(BorderLayout.CENTER, this);
	window.setLocation(UIRes.getPointToCenter(window, size));
	window.validate();
	window.setVisible(true);

	if (autonClose) {
		Updateable call = new Updateable() {
			@Override
			public void action(Object o) {
				for (; progress < 10;) {
					process();
					try {
						Thread.sleep(100);
					} catch (InterruptedException e) {
					}
				}
				RPSplash.this.dispose();
				if (update != null) {
					update.action(progress);
				}
			}
		};
		LSystem.postThread(call);
	}
}
 
Example 18
Source File: TN5250jSplashScreen.java    From tn5250j with GNU General Public License v2.0 4 votes vote down vote up
/**
    * Creates the Splash screen window and configures it.
    */
   protected void initialize(ImageIcon iimage) {

      image = iimage.getImage();
      // if no image, return
      if (image == null) {
         throw new IllegalArgumentException("Image specified is invalid.");
      }
//      System.out.println(" here in splash ");

      MediaTracker tracker = new MediaTracker(this);
      tracker.addImage(image,0);

      try {
         tracker.waitForAll();
      }
      catch(Exception e) {
         System.out.println(e.getMessage());
      }

      // create dialog window
      f = new Frame();
      dialog = new Window(f);
      dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
      Dimension s = new Dimension(image.getWidth(this) + 2,
         image.getHeight(this) + 2);
      setSize(s);
      dialog.setLayout(new BorderLayout());
      dialog.setSize(s);

      dialog.add(this,BorderLayout.CENTER);
      dialog.pack();

      // position splash screen
      Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
      int x = (screen.width - s.width)/2;
      if (x < 0) {
         x = 0;
      }

      int y = (screen.height - s.height)/2;
      if (y < 0) {
         y = 0;
      }

      dialog.setLocation(x, y);
      dialog.validate();

   }
 
Example 19
Source File: WindowOwnedByEmbeddedFrameTest.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    try {
        Robot robot = Util.createRobot();
        robot.setAutoDelay(50);

        embeddedFrame = createEmbeddedFrame();

        textField = new TextField("");

        window = new Window(embeddedFrame);
        window.setSize(200, 200);
        window.setLocationRelativeTo(null);
        window.add(textField);
        window.setVisible(true);

        Util.waitForIdle(robot);

        Util.clickOnComp(textField, robot);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_T);
        robot.keyRelease(KeyEvent.VK_T);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_E);
        robot.keyRelease(KeyEvent.VK_E);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_S);
        robot.keyRelease(KeyEvent.VK_S);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_T);
        robot.keyRelease(KeyEvent.VK_T);
        Util.waitForIdle(robot);

        if ("".equals(textField.getText())) {
            throw new RuntimeException("Keyboard input in text field isn't possible");
        }
    } finally {
        if (embeddedFrame != null) {
            embeddedFrame.dispose();
        }
        if (window != null) {
            window.dispose();
        }
    }
}
 
Example 20
Source File: WindowOwnedByEmbeddedFrameTest.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    try {
        Robot robot = Util.createRobot();
        robot.setAutoDelay(50);

        embeddedFrame = createEmbeddedFrame();

        textField = new TextField("");

        window = new Window(embeddedFrame);
        window.setSize(200, 200);
        window.setLocationRelativeTo(null);
        window.add(textField);
        window.setVisible(true);

        Util.waitForIdle(robot);

        Util.clickOnComp(textField, robot);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_T);
        robot.keyRelease(KeyEvent.VK_T);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_E);
        robot.keyRelease(KeyEvent.VK_E);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_S);
        robot.keyRelease(KeyEvent.VK_S);
        Util.waitForIdle(robot);

        robot.keyPress(KeyEvent.VK_T);
        robot.keyRelease(KeyEvent.VK_T);
        Util.waitForIdle(robot);

        if ("".equals(textField.getText())) {
            throw new RuntimeException("Keyboard input in text field isn't possible");
        }
    } finally {
        if (embeddedFrame != null) {
            embeddedFrame.dispose();
        }
        if (window != null) {
            window.dispose();
        }
    }
}