public void paint(Graphics g) { super.paint(g); if (screen.equalsIgnoreCase("title")) { MyPanel.score = 0; hs = new Highscore(); c.removeAll(); c.add(ts); panel = null; ts.revalidate(); } else if (screen.equalsIgnoreCase("instructions")) { c.removeAll(); c.add(instructions); instructions.revalidate(); } else if (screen.equalsIgnoreCase("mode")) { c.removeAll(); c.add(mode); mode.revalidate(); } else if (screen.equalsIgnoreCase("difficulty")) { c.removeAll(); c.add(dif); dif.revalidate(); } else if (screen.equalsIgnoreCase("highscore")) { if (hs.returnCount() == 0) { c.removeAll(); c.add(hs); c.validate(); } } else if (screen.equalsIgnoreCase("gameover")) { if (!once) { c.removeAll(); c.add(gg); once = true; c.validate(); } } else { if (once) { c.removeAll(); panel = new MyPanel(THA.WIDTH, THA.HEIGHT, ai, diff); c.setLayout(new BorderLayout()); c.add(panel.returnNs(), BorderLayout.WEST); c.add(panel, BorderLayout.CENTER); c.add(btns, BorderLayout.SOUTH); c.add(panel.returnAmmo(), BorderLayout.EAST); c.validate(); once = false; } } repaint(); }
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(); }
/** * @param filenames * @exception Exception if internal error */ public ChestImageViewer(String filenames[]) throws Exception { DisplayDeviceArea[] displayDeviceAreas = getPresentationAndImageDeviceAreas(); if (displayDeviceAreas == null) { System.err.println("Cannot determine device display areas"); } else { System.err.println("Found " + displayDeviceAreas.length + " device display areas"); for (int i = 0; i < displayDeviceAreas.length; ++i) { System.err.println("[" + i + "] = " + displayDeviceAreas[i]); displayDeviceAreas[i].getFrame().setBackground(Color.black); displayDeviceAreas[i].getFrame().setVisible(true); } { // Need to actually add something to the unused left display frame, else background will not // be set to black on Windows JPanel backgroundPanel = new JPanel(); backgroundPanel.setBackground(Color.black); displayDeviceAreas[0].getFrame().getContentPane().add(backgroundPanel); displayDeviceAreas[0].getFrame().validate(); } frame = displayDeviceAreas[1].getFrame(); Container content = frame.getContentPane(); content.setLayout(new GridLayout(1, 1)); multiPanel = new JPanel(); // multiPanel.setBackground(Color.black); frameWidth = (int) frame.getWidth(); frameHeight = (int) frame.getHeight(); Dimension d = new Dimension(frameWidth, frameHeight); // multiPanel.setSize(d); multiPanel.setPreferredSize(d); multiPanel.setBackground(Color.black); content.add(multiPanel); // frame.pack(); content.validate(); loadMultiPanelFromSpecifiedFiles(filenames); } }
RootWindow(Container container, Screen screen, Format[] format, Client c) { super(screen.rootId); rootwindow = container; client = c; screen.setRoot((Window) this); this.width = (short) (screen.width); this.height = (short) (screen.height); this.screen = screen; depth = screen.rootDepth; id = screen.rootId; type = DRAWABLE_WINDOW; x = y = 0; origin.x = 0; origin.y = 0; clss = (byte) InputOutput; for (int i = 0; i < format.length; i++) { if (format[i].depth == screen.rootDepth) { this.bitsPerPixel = format[i].bpp; } } setVisual(screen.rootVisual); setBackgroundIsPixel(); background.pixel = screen.white; setBorderIsPixel(); border.pixel = screen.black; borderWidth = 0; Resource.add(this); makeOptional(); attr &= ~(1 << 3); // cursorIsNone optional.cursor = Cursor.rootCursor; setColormap(screen.defaultColormap); // if(rootwindow instanceof JFrame){ // rootwindow.setSize(this.width+10, this.height+30); // ?? // } // else{ rootwindow.setSize(this.width, this.height); // } try { ddxwindow = (DDXWindow) (Window.dDXWindow.newInstance()); } catch (Exception e) { System.err.println(e); /*ddxwindow=new DDXWindowImp();*/ } ddxwindow.init(this); ddxwindow.setLocation(0, 0); if (rootwindow instanceof Frame) { // ((Frame)rootwindow).setLayout(null); ((Frame) rootwindow).setResizable(false); ((Frame) rootwindow).setMenuBar(null); ((Frame) rootwindow).add((java.awt.Component) ddxwindow); } else if (rootwindow instanceof Applet) { ((Applet) rootwindow).add((java.awt.Component) ddxwindow); } /* else if(rootwindow instanceof JFrame){ ((JFrame)rootwindow).getContentPane().setLayout(null); ((JFrame)rootwindow).setResizable(false); ((JFrame)rootwindow).setJMenuBar(null); ((JFrame)rootwindow).getContentPane().add((java.awt.Component)ddxwindow); } else if(rootwindow instanceof JWindow){ ((JWindow)rootwindow).getContentPane().setLayout(null); ((JWindow)rootwindow).getContentPane().add((java.awt.Component)ddxwindow); } else if (rootwindow instanceof JApplet){ ((JApplet)rootwindow).setJMenuBar(null); ((JApplet)rootwindow).getContentPane().add((java.awt.Component)ddxwindow); } */ else { rootwindow.add((java.awt.Component) ddxwindow); } if (screen.windowmode != WeirdX.InBrowser) { rootwindow.addNotify(); } else { rootwindow.setVisible(true); } ddxwindow.setVisible(true); { rootwindow.validate(); Insets insets = rootwindow.getInsets(); rootwindow.setSize( this.width + insets.left + insets.right, this.height + insets.top + insets.bottom); ddxwindow.setLocation(insets.left, insets.top); rootwindow.validate(); } ddxwindow.requestFocus(); Window.focus.win = id; Window.LOCK = rootwindow.getTreeLock(); Client.LOCK = rootwindow.getTreeLock(); Resource.LOCK = rootwindow.getTreeLock(); spriteTrace[0] = this; sprite.win = this; }