Java 8 Window - 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 Window class.

This code example shows how to use the following methods:setSize, setVisible, setDefaultCloseOperation, setLayout, add
    boolean cpu = true;
    if(args.length == 1 && args[0].equals("-gpu")){
      cpu = false;
    }     
 
    JFrame f = new JFrame();
    f.setSize(256, 256);
    f.setLayout(new GridLayout());
    f.add(new NewJPanel(cpu));
    f.setVisible(true);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  } 
} 
8
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:getToolkit
    verify(windows).markAsShowing(window);
  } 
 
  @Test
  public void shouldProcessEventWithIdEqualToWindowOpenedAndMarkWindowAsReadyIfWindowIsFileDialog() { 
    Window w = new FileDialog(window);
    when(context.storedQueueFor(w)).thenReturn(w.getToolkit().getSystemEventQueue());
    monitor.eventDispatched(new ComponentEvent(w, WINDOW_OPENED));
    verify(context).addContextFor(w);
    verify(windows).attachNewWindowVisibilityMonitor(w);
    verify(windows).markAsShowing(w);
    verify(windows).markAsReady(w);
  } 
 
  @Test
  public void shouldProcessEventWithIdEqualToWindowClosedAndWithRootWindow() { 
    when(context.storedQueueFor(window)).thenReturn(window.getToolkit().getSystemEventQueue());
    monitor.eventDispatched(new ComponentEvent(window, WINDOW_CLOSED));
    verify(context).removeContextFor(window);
    verify(windows).markAsClosed(window);
7
CodeRank
This code example shows how to use the following methods:pack, setVisible, setDefaultCloseOperation, add
	static { 
		Webcam.setDriver(new JavaCvDriver()); 
	} 
 
	public static void main(String[] args) {
		JFrame frame = new JFrame("LTI-CIVIL Webcam Capture Driver Example");
		frame.add(new WebcamPanel(Webcam.getDefault()));
		frame.pack();
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	} 
} 
7
CodeRank
This code example shows how to use the following methods:pack, setVisible, setDefaultCloseOperation, add
	static { 
		Webcam.setDriver(new LtiCivilDriver()); 
	} 
 
	public static void main(String[] args) {
		JFrame frame = new JFrame("LTI-CIVIL Webcam Capture Driver Example");
		frame.add(new WebcamPanel(Webcam.getDefault()));
		frame.pack();
		frame.setVisible(true);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	} 
} 
7
CodeRank
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:pack, setDefaultCloseOperation, add
	protected final VideoPanel videoPannel;
	protected final JFrame window;
 
	public SingleVideoDisplayWindow(String name,Dimension dimension) {
		super(); 
		this.window = new JFrame(name);
		this.videoPannel = new VideoPanel();
 
		this.videoPannel.setPreferredSize(dimension);
		this.window.add(videoPannel);
		this.window.pack();
		this.window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	} 
 
	public void setVisible(boolean visible) {
		this.window.setVisible(visible);
	} 
 
	public void updateImage(BufferedImage image) {
		videoPannel.updateImage(image);
7
CodeRank
This code example shows how to use the following methods:add, validate, setSize, setVisible, sleep
    @Test(groups = "display-required") // Will fail if run in a headless environment.
    public void testUserSelection() throws InterruptedException
    { 
        Robot robot = BasicRobot.robotWithNewAwtHierarchy();
        final SwingConsole swingConsole = new SwingConsole();
        JFrame frame = new JFrame();
        frame.add(swingConsole, BorderLayout.CENTER);
        FrameFixture frameFixture = new FrameFixture(robot, frame);
        frame.setSize(300, 100);
        frame.validate();
        frame.setVisible(true);
 
        final List<JLabel> labels = Arrays.asList(new JLabel("Zero"),
                                                  new JLabel("One"),
                                                  new JLabel("Two"));
 
        final int[] selection = new int[1];
        new Thread(new Runnable()
        { 
            public void run() 

7
CodeRank
This code example shows how to use the following methods:add, doLayout, getInsets, invalidate, validate
	} 
 
	private void initView(final Window screen) {
		view = new GameView(game);
		view.startPaint();
		left = screen.getInsets().left;
		top = screen.getInsets().top;
		screen.add((Canvas) view);
		screen.pack();
		screen.invalidate();
		screen.validate();
		view.createScreen();
		screen.doLayout();
		view.requestFocus();
	} 
 
	public synchronized boolean addComponent(Component component) {
		return addComponent(0, 0, component);
	} 
 
6
CodeRank
This code example shows how to use the following methods:pack, show, getContentPane
import com.ochafik.io.ReadText; 
 
public class Test { 
	@SuppressWarnings("deprecation") 
	public static void main(String args[]) {
		JFrame f=new JFrame("Test");
		String text=args.length==0 ? "" : ReadText.readText(new File(args[0]));
		JEditTextArea ta=new JEditTextArea();
		ta.setText(text);
		f.getContentPane().add("Center",new JScrollPane(ta));
		f.pack();
		f.show();
	} 
} 
7
CodeRank
See Code Examples for Java 8 Window Methods: