public void init() { this.setLayout(new BorderLayout()); frame.addMouseListener( new MouseAdapter() { public void mousePressed(MouseEvent e) { System.out.println("MousePressed"); pressed = true; } public void mouseReleased(MouseEvent e) { System.out.println("MouseReleased"); released = true; } public void mouseClicked(MouseEvent e) { System.out.println("MouseClicked!!!!"); clicked = true; } }); frame.addMouseMotionListener( new MouseMotionAdapter() { public void mouseDragged(MouseEvent e) { System.out.println("MouseDragged--" + e); dragged = true; } public void mouseMoved(MouseEvent e) {} }); } // End init()
/* */ public static void main(String[] args) /* */ { /* 59 */ System.out.println(""); /* 60 */ for (int i = 0; i < credits.length; i++) /* 61 */ System.out.println(credits[i]); /* 62 */ System.out.println(""); /* */ try /* */ { /* 65 */ Frame f = new Frame(credits[0]); /* 66 */ f.setLayout(new GridLayout(credits.length, 1)); /* 67 */ for (int i = 0; i < credits.length; i++) /* 68 */ f.add(new Label(credits[i], 1)); /* 69 */ f.pack(); /* 70 */ Toolkit t = f.getToolkit(); /* 71 */ f.setLocation( (t.getScreenSize().width - f.getSize().width) / 2, (t.getScreenSize().height - f.getSize().height) / 2); /* 72 */ f.addWindowListener( new WindowAdapter() { /* */ public void windowClosing(WindowEvent e) { /* 74 */ System.exit(0); /* */ } /* 76 */ }); /* 77 */ f.show(); /* */ } /* */ catch (Exception localException) { } /* */ }
public void mouseMoved(MouseEvent ev) { JRootPane root = getRootPane(); if (root.getWindowDecorationStyle() == JRootPane.NONE) { return; } Window w = (Window) ev.getSource(); Frame f = null; Dialog d = null; if (w instanceof Frame) { f = (Frame) w; } else if (w instanceof Dialog) { d = (Dialog) w; } // Update the cursor int cursor = getCursor(calculateCorner(w, ev.getX(), ev.getY())); if (cursor != 0 && ((f != null && (f.isResizable() && (f.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0)) || (d != null && d.isResizable()))) { w.setCursor(Cursor.getPredefinedCursor(cursor)); } else { w.setCursor(lastCursor); } }
/** * @param owner the owner of this component * @param maxVersion the maximum version number which is valid */ public CheckOutVersionDialog(Frame owner, int maxVersion) { super(owner, true); this.maxVersion = maxVersion; parentFrame = owner; versionTF = new JTextField(5); okButton = new JButton("Ok"); okButton.addActionListener(this); JPanel versionPanel = new JPanel(); JPanel buttonPanel = new JPanel(); versionPanel.add(new JLabel("Version number to check out: ")); versionPanel.add(versionTF); buttonPanel.add(okButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(versionPanel, BorderLayout.CENTER); getContentPane().add(buttonPanel, BorderLayout.SOUTH); setLocation((int) owner.getLocation().getX() + 100, (int) owner.getLocation().getY() + 100); pack(); }
@Override public void configChanged(final Config cfg, final String key) { if (key.equals(CFG_RESOLUTION)) { final GraphicResolution[] resolutions = display.getPossibleResolutions(); final String selected = cfg.getString(CFG_RESOLUTION); for (final GraphicResolution res : resolutions) { if (res.toString().equals(selected)) { display.setDisplayMode(res); screenWidth = display.getWidth(); screenHeight = display.getHeight(); if (displayFrame != null) { displayFrame.pack(); displayFrame.setLocationRelativeTo(null); } return; } } // overwrite with default value in case invalid value was insert cfg.set(CFG_RESOLUTION, new GraphicResolution(800, 600, 32, 60).toString()); return; } if (key.equals(CFG_FULLSCREEN)) { if (display.isFullscreen() != cfg.getBoolean(CFG_FULLSCREEN)) { display.toogleFullscreen(); } return; } }
public static void main(final String[] argv) { final Frame frame = new Frame("Cg demo (runtime_ogl_vertex_fragment)"); final GLCanvas canvas = new GLCanvas(); canvas.addGLEventListener(new runtime_ogl_vertex_fragment()); frame.add(canvas); frame.setSize(512, 512); final Animator animator = new Animator(canvas); frame.addWindowListener( new WindowAdapter() { @Override public void windowClosing(@SuppressWarnings("unused") final WindowEvent e) { // Run this on another thread than the AWT event queue to // make sure the call to Animator.stop() completes before // exiting new Thread( new Runnable() { public void run() { animator.stop(); System.exit(0); } }) .start(); } }); frame.setVisible(true); animator.start(); // and all the rest happens in the display function... }
/** * Creates a new connection to the specified host of specified type. <br> * <br> * type: Type of connection to create <br> * destination: Host to connect to (in "host:port" or "host" syntax) */ public Connection(java.net.InetAddress host, int port, PluginContext ctx) throws MessagingNetworkException, java.io.IOException { if (TRAKTOR_USED) { if (traktorConnectionDown) throw new IOException("network is down"); traktor = new Frame("" + host + ":" + port + " - Traktor"); final Checkbox c = new Checkbox("break this & ALL future connections"); c.setState(traktorConnectionDown); c.addItemListener( new ItemListener() { public void itemStateChanged(ItemEvent e) { traktorConnectionDown = c.getState(); try { if (traktorConnectionDown) closeSocket(); } catch (Exception ex) { } } }); traktor.add(c); traktor.setSize(100, 50); traktor.setLocation(230, 450); traktor.setVisible(true); } else { traktor = null; } }
public static void main(String[] args) { Frame f = new Frame(); f.setSize(200, 100); Label lb = new Label("Hello World!!"); f.add(lb); f.setVisible(true); }
public static void main(String[] args) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setText("SWT and Swing DND Example"); GridLayout layout = new GridLayout(1, false); shell.setLayout(layout); Text swtText = new Text(shell, SWT.BORDER); swtText.setText("SWT Text"); GridData data = new GridData(GridData.FILL_HORIZONTAL); swtText.setLayoutData(data); setDragDrop(swtText); Composite comp = new Composite(shell, SWT.EMBEDDED); java.awt.Frame frame = SWT_AWT.new_Frame(comp); JTextField swingText = new JTextField(40); swingText.setText("Swing Text"); swingText.setDragEnabled(true); frame.add(swingText); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = swingText.getPreferredSize().height; comp.setLayoutData(data); shell.setSize(400, 200); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }
/** * Make changes to UI to notify content change * * @param contentchanged */ public final void notifyContentChange(boolean contentchanged) { if (contentchanged) { this.cmdSave.setEnabled(true); if (ContainerComponent instanceof Frame) { ((Frame) ContainerComponent).setTitle(getTitle() + "*"); } else if (ContainerComponent instanceof Dialog) { ((Dialog) ContainerComponent).setTitle(getTitle() + "*"); } else if (ContainerComponent instanceof JTabbedPane) { if (TabId > 0) { // ((JTabbedPane)ContainerComponent).setTitleAt(getTabId(), getTitle() + "*"); JTabbedPane jtb = (JTabbedPane) ContainerComponent; jtb.setTitleAt(jtb.indexOfComponent(this), getTitle() + "*"); } } } else { this.cmdSave.setEnabled(false); if (ContainerComponent instanceof Frame) { ((Frame) ContainerComponent).setTitle(getTitle()); } else if (ContainerComponent instanceof Dialog) { ((Dialog) ContainerComponent).setTitle(getTitle()); } else if (ContainerComponent instanceof JTabbedPane) { if (TabId > 0) { // ((JTabbedPane)ContainerComponent).setTitleAt(getTabId(), getTitle()); JTabbedPane jtb = (JTabbedPane) ContainerComponent; jtb.setTitleAt(jtb.indexOfComponent(this), getTitle()); } } } }
// case name change helper private static void doCaseNameChange(String newCaseName) { // update case name if (!newCaseName.equals("")) { Frame f = WindowManager.getDefault().getMainWindow(); f.setTitle(newCaseName + " - " + Case.getAppName()); // set the window name to the new value } }
public void addClient() { client = new Canvas() { public void paint(Graphics g) { super.paint(g); } }; client.setBackground(new Color(30, 220, 40)); clientCont.add(client); clientCont.validate(); final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); WindowIDProvider pid = (WindowIDProvider) acc.getPeer(client); log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow()); Rectangle toFocusBounds = toFocus.getBounds(); toFocusBounds.setLocation(toFocus.getLocationOnScreen()); f.validate(); // KDE doesn't accept clicks on title as activation - click below title Rectangle fbounds = f.getBounds(); fbounds.y += f.getInsets().top; fbounds.height -= f.getInsets().top; Process proc = startClient( new Rectangle[] { fbounds, dummy.getBounds(), toFocusBounds, new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()), new Rectangle(10, 130, 20, 20) }, pid.getWindow()); new ClientWatcher(client, proc, clientCont).start(); }
public static void main(String[] args) { for (int i = 0; i < 100; i++) { Frame f = new Frame(); f.pack(); f.dispose(); } Vector garbage = new Vector(); while (true) { try { garbage.add(new byte[1000]); } catch (OutOfMemoryError e) { break; } } garbage = null; Vector<WeakReference<Window>> windowList = (Vector<WeakReference<Window>>) AppContext.getAppContext().get(Window.class); if (windowList != null && !windowList.isEmpty()) { throw new RuntimeException("Test FAILED: Window list is not empty: " + windowList.size()); } System.out.println("Test PASSED"); }
@Test public void testShowingPopupMenu() { MouseEvent event = new MouseEvent( manif1, MouseEvent.MOUSE_CLICKED, WHEN, MODS, X_LOC, Y_LOC, ONE_CLICK, false, MouseEvent.BUTTON3); // Assertion that the number of Frames has not changed Frame[] framesBefore = Frame.getFrames(); secondPopupOpener.mousePressed(event); Frame[] framesAfter = Frame.getFrames(); Assert.assertTrue(framesBefore.length == framesAfter.length); // Assertion that the count of open Frames has increased by one framesBefore = Frame.getFrames(); firstPopupOpener.mousePressed(event); framesAfter = Frame.getFrames(); Assert.assertTrue(framesBefore.length + 1 == framesAfter.length); }
public final void enter(Frame var1, int var2, int var3, int var4, int var5) { this.a = this.b.getDisplayMode(); if (this.a == null) { throw new NullPointerException(); } else { var1.setUndecorated(true); var1.enableInputMethods(false); this.a((byte) 13, var1); if (0 == var5) { int var6 = this.a.getRefreshRate(); DisplayMode[] var7 = this.b.getDisplayModes(); boolean var8 = false; for (int var9 = 0; ~var9 > ~var7.length; ++var9) { if (~var2 == ~var7[var9].getWidth() && var7[var9].getHeight() == var3 && var7[var9].getBitDepth() == var4) { int var10 = var7[var9].getRefreshRate(); if (!var8 || Math.abs(var10 + -var6) < Math.abs(var5 + -var6)) { var8 = true; var5 = var10; } } } if (!var8) { var5 = var6; } } this.b.setDisplayMode(new DisplayMode(var2, var3, var4, var5)); } }
static void repaintFrames() { for (int i = 0; i < frames.size(); i++) { Frame frame = (Frame) frames.elementAt(i); configColors(frame); frame.repaint(); } }
public void launchCalc() { f.add(tf, BorderLayout.NORTH); p2 = new Panel(); p2.setLayout(new GridLayout(4, 5)); p2.add(b1); p2.add(b2); p2.add(b3); p2.add(b18); p2.add(b10); p2.add(b6); p2.add(b7); p2.add(b8); p2.add(b19); p2.add(b4); p2.add(b11); p2.add(b12); p2.add(b13); p2.add(b14); p2.add(b9); p2.add(b16); p2.add(b17); p2.add(b20); p2.add(b15); p2.add(b5); f.add(p2, BorderLayout.CENTER); f.pack(); f.setSize(250, 200); f.setVisible(true); }
public static void view(DrawModel d) { final Display display = new Display(); final Shell shell = new Shell(display); shell.setLayout(new FillLayout()); Composite composite = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND); Frame baseFrame = SWT_AWT.new_Frame(composite); baseFrame.setBounds(0, 0, 800, 600); Java3DViewer viewer = new Java3DViewer(baseFrame, d); baseFrame.add(viewer); shell.open(); d.setFaceColor(Color.GREEN); d.circle(0.9); // viewer.draw(d); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } baseFrame.dispose(); shell.dispose(); composite.dispose(); display.dispose(); System.exit(0); }
public static void main(String[] args) { Triangle triangle = new Triangle(); Frame frame = new Frame("Comgr Triangle"); frame.add(triangle); frame.setSize(triangle.getWidth(), triangle.getHeight()); frame.setVisible(true); }
public static void Field1(){ fieldT.Label(); fieldT.panel(); f1.setSize(400, 400); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); // 화면 픽셀 계산 Dimension frm = f1.getSize();//창 크기 계산 int xpos = (int)(screen.getWidth() / 2 - frm.getWidth() / 2); // 창 중앙 위치 계산 int ypos = (int)(screen.getHeight() / 2 - frm.getHeight() / 2); f1.setLayout(new GridLayout(4, 4));// 프레임 레이아웃 f1.setBackground(Color.cyan); //프레임 배경 f1.addWindowListener(new WEventHandler()); f1.addKeyListener(new KEventHandler()); f1.setResizable(false); for(int i =0;i<4;i++){ for(int j=0;j<4;j++){ f1.add(p[i][j]); } } f1.setLocation(xpos, ypos); f1.setVisible(true); }
@Test public void testWindowParenting02CreateVisibleDestroy3Odd() throws InterruptedException { int x = 0; int y = 0; NEWTEventFiFo eventFifo = new NEWTEventFiFo(); GLWindow glWindow1 = GLWindow.create(glCaps); GLEventListener demo1 = new RedSquare(); setDemoFields(demo1, glWindow1, false); glWindow1.addGLEventListener(demo1); NewtCanvasAWT newtCanvasAWT = new NewtCanvasAWT(glWindow1); Frame frame = new Frame("AWT Parent Frame"); Assert.assertNotNull(frame); frame.setSize(width, height); // visible test frame.setVisible(true); frame.add(newtCanvasAWT); Animator animator1 = new Animator(glWindow1); animator1.start(); while (animator1.isAnimating() && animator1.getDuration() < durationPerTest) { Thread.sleep(100); } Assert.assertEquals(true, animator1.isAnimating()); // !!! frame.dispose(); glWindow1.destroy(true); }
public static void main(String[] args) { Frame frame = new Frame("Simple JOGL Application"); GLCanvas canvas = new GLCanvas(); canvas.addGLEventListener(new Project1()); frame.add(canvas); frame.setSize(600, 600); final Animator animator = new Animator(canvas); frame.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { new Thread( new Runnable() { public void run() { animator.stop(); System.exit(0); } }) .start(); } }); frame.setVisible(true); animator.start(); }
public void beginExecution() { if (cam == null) { int numBuffers = 2; env = GraphicsEnvironment.getLocalGraphicsEnvironment(); device = env.getDefaultScreenDevice(); // MultiBufferTest test = new MultiBufferTest(numBuffers, device); try { GraphicsConfiguration gc = device.getDefaultConfiguration(); mainFrame = new Frame(gc); mainFrame.setUndecorated(true); mainFrame.setIgnoreRepaint(true); device.setFullScreenWindow(mainFrame); if (device.isDisplayChangeSupported()) { chooseBestDisplayMode(device); } mainFrame.createBufferStrategy(numBuffers); bufferStrategy = mainFrame.getBufferStrategy(); } catch (Exception e) { e.printStackTrace(); } } }
public static void main(String[] args) { try { if (args.length != 1) throw new IllegalArgumentException("Wrong number of arguments"); FileReader in = new FileReader(args[0]); HardcopyWriter out = null; Frame f = new Frame("PrintFile: " + args[0]); f.setSize(200, 50); f.show(); try { out = new HardcopyWriter(f, args[0], 10, .75, .75, .75, .75); } catch (HardcopyWriter.PrintCanceledException e) { System.exit(0); } f.setVisible(false); char[] buffer = new char[4096]; int numchars; while ((numchars = in.read(buffer)) != -1) out.write(buffer, 0, numchars); out.close(); } catch (Exception e) { System.err.println(e); System.err.println("Usage: java HardcopyWriter$PrintFile <filename>"); System.exit(1); } System.exit(0); }
protected void fileOpened(final DocumentView documentView, File file, Object value) { final DocumentOrientedApplication application = getApplication(); if (value == null) { documentView.setFile(file); documentView.setEnabled(true); Frame w = (Frame) SwingUtilities.getWindowAncestor(documentView.getComponent()); if (w != null) { w.setExtendedState(w.getExtendedState() & ~Frame.ICONIFIED); w.toFront(); } documentView.getComponent().requestFocus(); application.addRecentFile(file); application.setEnabled(true); } else { if (value instanceof Throwable) { ((Throwable) value).printStackTrace(); } JSheet.showMessageSheet( documentView.getComponent(), "<html>" + UIManager.getString("OptionPane.css") + "<b>Couldn't open the file \"" + file + "\".</b><br>" + value, JOptionPane.ERROR_MESSAGE, new SheetListener() { public void optionSelected(SheetEvent evt) { // application.dispose(documentView); } }); } }
private void destroyPlayerFrame() { if (playerFrame != null) { playerFrame.removeAll(); playerFrame.dispose(); playerFrame = null; } }
@Override public void createPartControl(Composite parent) { // TODO read (positioning): // http://www.eclipse.org/articles/using-perspectives/PerspectiveArticle.html composite = new Composite(parent, SWT.EMBEDDED); java.awt.Frame frame = SWT_AWT.new_Frame(composite); this.mainPanel = new javax.swing.JPanel(); this.mainPanel.setLayout(new BorderLayout()); this.viewPanel = new JPanel(new BorderLayout()); // Control Panel this.controlPanel = new JPanel(new FlowLayout()); // this.controlPanel.add(this.cbCFOnly); // this.controlPanel.add(this.exportEPMLBtn); this.controlPanel.add(this.refreshBtn); // this.cbCFOnly.addActionListener(this); // this.exportEPMLBtn.addActionListener(this); this.refreshBtn.addActionListener(this); // main Panel // mainPanel.add(this.controlPanel, BorderLayout.NORTH); mainPanel.add(this.viewPanel, BorderLayout.CENTER); mainPanel.add(this.errorLabel, BorderLayout.SOUTH); frame.add(mainPanel); }
@Override public void actionPerformed(ActionEvent e) { Frame frame = getFrame(); JFileChooser chooser = new JFileChooser(); int ret = chooser.showOpenDialog(frame); if (ret != JFileChooser.APPROVE_OPTION) { return; } File f = chooser.getSelectedFile(); if (f.isFile() && f.canRead()) { Document oldDoc = getEditor().getDocument(); if (oldDoc != null) { oldDoc.removeUndoableEditListener(undoHandler); } if (elementTreePanel != null) { elementTreePanel.setEditor(null); } getEditor().setDocument(new PlainDocument()); frame.setTitle(f.getName()); Thread loader = new FileLoader(f, editor.getDocument()); loader.start(); } else { JOptionPane.showMessageDialog( getFrame(), "Could not open file: " + f, "Error opening file", JOptionPane.ERROR_MESSAGE); } }
public void mouseClicked(MouseEvent ev) { Window w = (Window) ev.getSource(); Frame f = null; if (w instanceof Frame) { f = (Frame) w; } else { return; } Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane()); int state = f.getExtendedState(); if (getTitlePane() != null && getTitlePane().contains(convertedPoint)) { if ((ev.getClickCount() % 2) == 0 && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) { if (f.isResizable()) { if ((state & Frame.MAXIMIZED_BOTH) != 0) { f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH); } else { f.setExtendedState(state | Frame.MAXIMIZED_BOTH); } return; } } } }
/* */ public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent) /* */ { /* 974 */ String str = paramPropertyChangeEvent.getPropertyName(); /* */ /* 977 */ if (("resizable".equals(str)) || ("state".equals(str))) { /* 978 */ Frame localFrame = MetalTitlePane.this.getFrame(); /* */ /* 980 */ if (localFrame != null) { /* 981 */ MetalTitlePane.this.setState(localFrame.getExtendedState(), true); /* */ } /* 983 */ if ("resizable".equals(str)) { /* 984 */ MetalTitlePane.this.getRootPane().repaint(); /* */ } /* */ } /* 987 */ else if ("title".equals(str)) { /* 988 */ MetalTitlePane.this.repaint(); /* */ } /* 990 */ else if ("componentOrientation" == str) { /* 991 */ MetalTitlePane.this.revalidate(); /* 992 */ MetalTitlePane.this.repaint(); /* */ } /* 994 */ else if ("iconImage" == str) { /* 995 */ MetalTitlePane.this.updateSystemIcon(); /* 996 */ MetalTitlePane.this.revalidate(); /* 997 */ MetalTitlePane.this.repaint(); /* */ } /* */ }