private Component getLayeredPane() { Container parent = null; if (this.owner != null) { parent = this.owner instanceof Container ? (Container) this.owner : this.owner.getParent(); } for (Container p = parent; p != null; p = p.getParent()) { if (p instanceof JRootPane) { if (p.getParent() instanceof JInternalFrame) { continue; } parent = ((JRootPane) p).getLayeredPane(); } else if (p instanceof Window) { if (parent == null) { parent = p; } break; } else if (p instanceof JApplet) { break; } } return parent; }
NonOpaqueJAppletFrame() { super("NonOpaque Swing JAppletFrame"); JApplet ja = new JApplet() { public void paint(Graphics g) { super.paint(g); System.err.println("JAppletFrame paint called"); } }; p = new JPanel() { public void paintComponent(Graphics g) { super.paintComponent(g); render(g, getWidth(), getHeight(), true); g.setColor(Color.red); g.drawString("Non-Opaque Swing JFrame", 10, 15); } }; p.setDoubleBuffered(false); p.setOpaque(false); ja.add(p); add(ja); setUndecorated(true); }
@Override public Popup getPopup(Component owner, Component contents, int x, int y) throws IllegalArgumentException { Component[] hierarchy = getHierarchy(owner); for(int a = hierarchy.length-1; a>=0; a--) { if(hierarchy[a] instanceof JApplet && contents instanceof JComponent) { return new AppletPopup( (JApplet)hierarchy[a], owner, (JComponent)contents, x, y); /* Unfortunately we can't simply check against a java.awt.Frame, * because applets can be embedded in a * sun.plugin2.main.client.PluginEmbeddedFrame. */ //} else if(hierarchy[a] instanceof Frame) { } else if(hierarchy[a] instanceof JFrame) { return oldFactory.getPopup(owner, contents, x, y); } } return oldFactory.getPopup(owner, contents, x, y); }
public void run() { try { Class cls = Class.forName(loadAppletName); JApplet app = (JApplet)cls.newInstance(); app.setStub((AppletStub)this); app.init(); getContentPane().add("Center", app); loadApplet = app; validate(); if(isStarted) { loadApplet.start(); } validate(); } catch (Throwable e) { loadApplet = null; AppletLogger.showError("Exception:", e); e.printStackTrace(); validate(); } System.out.println("Thread end"); }
public void run() { try { Class cls = Class.forName(loadAppletName); JApplet app = (JApplet)cls.newInstance(); app.setStub((AppletStub)this); app.init(); getContentPane().add("Center", app); loadApplet = app; validate(); if(isStarted) { loadApplet.start(); } validate(); } catch (Throwable e) { loadApplet = null; AppletLogger.showError("Exception:", e); e.printStackTrace(); validate(); } }
/** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub JFrame f = new JFrame("Line"); f.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); JApplet applet = new Gynfont(); f.getContentPane().add("Center", applet); applet.init(); f.pack(); f.setSize(new Dimension(800, 100)); f.setVisible(true); }
/** * * Exibe uma caixa de dialogo com uma mensagem. * * @param applet * @param mensagem -> String com a mensagem a ser exibida * @param tipo -> Tipo da mensagem, sendo: 0 = Informacao, 1 = Alerta e 2 = Erro */ public static void showMensagem(JApplet applet, String mensagem, int tipo) { String[] botao = new String[]{""}; botao[0]= "Fechar"; String Titulo; int tipoMsg; switch (tipo) { case 0: Titulo= "Informa��o do Sistema."; tipoMsg=JOptionPane.INFORMATION_MESSAGE; break; case 1: Titulo= "Alerta do Sistema!"; tipoMsg=JOptionPane.WARNING_MESSAGE; break; case 2: Titulo= "Erro na Execu��o!"; tipoMsg=JOptionPane.ERROR_MESSAGE; break; default: Titulo= "Informa��o do Sistema!"; tipoMsg=JOptionPane.INFORMATION_MESSAGE; break; } JOptionPane.showOptionDialog(applet, mensagem, Titulo, JOptionPane.YES_OPTION, tipoMsg, null, botao, botao[0]); //JOptionPane.showMessageDialog(applet, message, "Mensagem do Sistema",JOptionPane.NO_OPTION); }
public Menu(int w, int h, JApplet aplet) { try { bgImage = ImageIO.read(this.getClass().getClassLoader().getResource("resources/chessg.jpg")); bgImage = bgImage.getScaledInstance(w, h, 1); startButton = ImageIO.read(this.getClass().getClassLoader().getResource("resources/startgame.png")); exitButton =ImageIO.read(this.getClass().getClassLoader().getResource("resources/exitgame.png")); playGame= new Rectangle(100,100,100,50); exit = new Rectangle(100,200,90,50); frame=aplet; } catch (IOException ex) { System.err.println(ex.toString()); } }
/** * Loads an image from the application server from which a JApplet originates. Stores * the the image in the image mapping with the parameter name as the key. * * @param applet The JApplet * @param parameter Name of the parameter which specifies the relative path of the image */ protected void loadImage(JApplet applet, String parameter) { String codeBase = applet.getCodeBase().toString(); String path = applet.getParameter(parameter); if (path != null) { try { URL url = new URL(codeBase + path); BufferedImage image = ImageIO.read(url); images.put(parameter, image); } catch (Exception e) { //Unable to load image do nothing } } }
public void init(JApplet a) { applet = a; size = applet.getSize(); canvas = new Canvas(); canvas.setSize(applet.getSize()); applet.add(canvas); canvas.createBufferStrategy(2); canvas.addKeyListener(this); canvas.addMouseListener(this); canvas.addMouseMotionListener(this); canvas.addMouseWheelListener(this); canvas.setBackground(Color.black); canvas.setForeground(Color.white); frames = 0; start = 0; layers = new CopyOnWriteArrayList<>(); initGame(); }
public static void main(String[] args) { SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame("Swing FX Keyboard"); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JApplet applet = new SwingDemo(); applet.init(); frame.setContentPane(applet.getContentPane()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); applet.start(); }); }
private void createMenus() { menuBar = new JMenuBar(); createFileMenu(); createDisplayMenu(); createAnimationMenu(); if (container instanceof JFrame) { ((JFrame) container).setJMenuBar(menuBar); } else if (container instanceof JApplet) { ((JApplet) container).setJMenuBar(menuBar); } }
/** Creates new form ActivityMonitorTest */ public ActivityMonitorTest(JApplet applet) { initComponents(); this.applet = applet; setSize(800,300); getContentPane().setLayout(new BorderLayout()); getContentPane().add(applet,BorderLayout.CENTER); }
/** * @param args the command line arguments */ public static void main(String args[]) { JApplet applet = new DVSActApplet(); JFrame frame = new ActivityMonitorTest(applet); applet.init(); applet.start(); frame.setVisible(true); }
/** * For testing in JFrame * @param args the command line arguments */ public static void main(String args[]) { JApplet applet = new ClockApplet(); JFrame frame = new ActivityMonitorTest(applet); applet.init(); applet.start(); frame.setVisible(true); }
/** * For testing in JFrame * @param args the command line arguments */ public static void main(String args[]) { JApplet applet = new DVSActApplet(); JFrame frame = new ActivityMonitorTest(applet); frame.setVisible(true); applet.init(); applet.start(); }
public static void main(String[] args) { // ensure that 4168475 does not regress test4168475(Component.class); // AWT classes (com.sun.beans.infos.ComponentBeanInfo) test(null, Button.class, Component.class, List.class, Menu.class, Panel.class); // Swing classes (dt.jar) test(null, JApplet.class, JButton.class, JCheckBox.class); // user defined classes test(Boolean.TRUE, Wombat.class, Foo.class, FooBar.class); }
public static void main(String args[]) { boolean exceptions = false; try { new JApplet(); } catch (HeadlessException e) { exceptions = true; } if (!exceptions) throw new RuntimeException("HeadlessException did not occur when expected"); }
/** * Call this method to initialize an applet from your launcher class * <code>MyAppletLauncher.init()</code> method. * * @param sClass class name in form "MyClass" for default package * or "com.abc.MyClass" for class in some package * * @param appletParent parent applet from a launcher. * * @throws Throwable wrapper for many exceptions thrown while applet * instantiation and calling init() method. */ public void initApplet(String sClass, final JApplet appletParent) throws Throwable { Class<?> clazz = loadClass(sClass); logInfo(LogArea.CONFIG, "initApplet() --> %s.init(); Loader: %s", sClass, clazz.getClassLoader()); applet = (JApplet)clazz.newInstance(); applet.setStub(new AppletStub() { @Override public boolean isActive() { return appletParent.isActive(); } @Override public URL getDocumentBase() { return appletParent.getDocumentBase(); } @Override public URL getCodeBase() { return appletParent.getCodeBase(); } @Override public String getParameter(String name) { return appletParent.getParameter(name); } @Override public AppletContext getAppletContext() { return appletParent.getAppletContext(); } @Override public void appletResize(int width, int height) { appletParent.resize(width, height); } }); applet.init(); appletParent.setContentPane(applet.getContentPane()); }
/** * @param args the command line arguments */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { try { // We use the system's look and feel to ensure that it does not // look alien to the user. UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } MarkupFrame frame = new MarkupFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JApplet applet = new main(); applet.init(); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); applet.start(); } }); }
public AppletPopup(JApplet applet, Component owner, JComponent component, int x,int y) { if(applet==null) throw new NullPointerException(); this.applet = applet; this.component = component; this.x = x; this.y = y; this.owner = owner; /* For some bizarre reason: the LineBorder doesn't show up like * it should. So we extract it and let the blocking pane paint it * instead. * */ if(component.getBorder() instanceof LineBorder) { borderColor = ((LineBorder)component.getBorder()).getLineColor(); component.setBorder(null); } /** Extract the background color to paint under the popup. * This is custom-designed to work with Mac's and the AquaComboBoxUI. */ Component[] t = component.getComponents(); Component j = null; for(int a = 0; a<t.length && j==null; a++) { if(!(t[a] instanceof Box.Filler)) { j = t[a]; } if(j instanceof JScrollPane) { j = ((JScrollPane)j).getViewport().getComponent(0); } } if(j!=null) backgroundColor = j.getBackground(); }