JButton button = (JButton)event.getSource(); Window window = SwingUtilities.windowForCompnent( button ); window.add(...);
w.add(pane, BorderLayout.CENTER); final Action closeAction = new CloseAction(w); closeButton.addActionListener(closeAction);
win.add(tooltip); win.pack(); Point p = new Point(-3, -win.getHeight() - 3);
w.add(pane, BorderLayout.CENTER); final Action closeAction = new CloseAction(w); closeButton.addActionListener(closeAction);
// Create a window for full-screen mode; add a button to leave full-screen mode Frame frame = new Frame(gs.getDefaultConfiguration()); Window win = new Window(frame); Canvas c = new Canvas(); c.setBackground(Color.RED); win.add(c); win.show(); //or setVisible(true); // Enter full-screen mode gs.setFullScreenWindow(win); win.validate();
w.add(pane, BorderLayout.CENTER); final Action closeAction = new CloseAction(w); closeButton.addActionListener(closeAction);
// Main class, which just creates a window and adds a label and shows it public class Main{ public static void main(String[] args) { Window window = new Window(1200, 800, "JFrame Example", false, JFrame.EXIT_ON_CLOSE); JLabel label = window.createLabel("Hi dude!!!!!", 0, 0); window.add(label); window.setVisible(true); } }
w.add(pane, BorderLayout.CENTER); final Action closeAction = new CloseAction(w); closeButton.addActionListener(closeAction);
w.add ( new JComponent ()
w.add(pane, BorderLayout.CENTER); final Action closeAction = new CloseAction(w); closeButton.addActionListener(closeAction);
private void ToolbarMove() { if (m_enToolbarPosition == ToolBarPosition.TP_EAST) { m_enToolbarPosition = ToolBarPosition.TP_WEST; SwingUtilities.getWindowAncestor(m_objASLMap.getLayeredPane()).getLayout().removeLayoutComponent(m_Toolbar); SwingUtilities.getWindowAncestor(m_objASLMap.getLayeredPane()).add(m_Toolbar, BorderLayout.WEST); } else { m_enToolbarPosition = ToolBarPosition.TP_EAST; SwingUtilities.getWindowAncestor(m_objASLMap.getLayeredPane()).getLayout().removeLayoutComponent(m_Toolbar); SwingUtilities.getWindowAncestor(m_objASLMap.getLayeredPane()).add(m_Toolbar, BorderLayout.EAST); } saveToolbarPos(); m_objASLMap.getView().revalidate(); m_Toolbar.revalidate(); NeedRepaint(); }
public class Start implements ActionListener { Window theWindow = new Window(); CustomPanel mainMenu = new CustomPanel(); CustomPanel optionsMenu = new CustomPanel(); Button myButton = new Button(); public static void main(String[] args) { theWindow.add(mainMenu); mainMenu.add(myButton); myButton.addActionListener(this); theWindow.setVisible(true); theWindow.repaint(); } public void actionPerformed(Event e) { theWindow.remove(mainMenu); theWindow.add(optionsMenu); theWindow.repaint(); }
mainPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); window.add(mainPanel);
mainPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); window.add(mainPanel);
public static ImagePanel createSplashImagePanel( String strImage ) { ImagePanel imagePanel = new ImagePanel( strImage ); imagePanel.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) ); Window splash = new Window( new Frame() ) { public void update( Graphics g ) { this.paint( g ); } }; splash.setBackground( new Color( 0, 0, 0, 0 ) ); splash.setLayout( new BorderLayout() ); splash.add( BorderLayout.CENTER, imagePanel ); splash.pack(); EditorUtilities.centerWindowInFrame( splash, splash ); splash.setVisible( true ); imagePanel.repaintNow(); return imagePanel; }
splashWindow.add(splashImage, "Center"); splashText = new Label(Sage.rez("Module_Init", new Object[] { "Application" }), Label.CENTER) splashText.setBackground(new Color(42, 103, 190)); splashText.setForeground(Color.white); splashWindow.add(splashText, "South"); Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize(); splashWindow.pack();
public static void startSplashScreen() { int width=275,height=148; Window win=new Window( new Frame() ); win.pack(); BshCanvas can=new BshCanvas(); can.setSize( width, height ); // why is this necessary? Toolkit tk=Toolkit.getDefaultToolkit(); Dimension dim=tk.getScreenSize(); win.setBounds( dim.width/2-width/2, dim.height/2-height/2, width, height ); win.add("Center", can); Image img=tk.getImage( Interpreter.class.getResource("/bsh/util/lib/splash.gif") ); MediaTracker mt=new MediaTracker(can); mt.addImage(img,0); try { mt.waitForAll(); } catch ( Exception e ) { } Graphics gr=can.getBufferedGraphics(); gr.drawImage(img, 0, 0, can); win.setVisible(true); win.toFront(); splashScreen = win; }
private OSXMaskingContentPane installMaskingPane(Window w) { OSXMaskingContentPane content; if (w instanceof RootPaneContainer) { // TODO: replace layered pane instead? final RootPaneContainer rpc = (RootPaneContainer)w; Container oldContent = rpc.getContentPane(); if (oldContent instanceof OSXMaskingContentPane) { content = (OSXMaskingContentPane)oldContent; } else { content = new OSXMaskingContentPane(oldContent); // TODO: listen for content pane changes rpc.setContentPane(content); } } else { Component oldContent = w.getComponentCount() > 0 ? w.getComponent(0) : null; if (oldContent instanceof OSXMaskingContentPane) { content = (OSXMaskingContentPane)oldContent; } else { content = new OSXMaskingContentPane(oldContent); w.add(content); } } return content; }
private OSXMaskingContentPane installMaskingPane(Window w) { OSXMaskingContentPane content; if (w instanceof RootPaneContainer) { // TODO: replace layered pane instead? final RootPaneContainer rpc = (RootPaneContainer)w; Container oldContent = rpc.getContentPane(); if (oldContent instanceof OSXMaskingContentPane) { content = (OSXMaskingContentPane)oldContent; } else { content = new OSXMaskingContentPane(oldContent); // TODO: listen for content pane changes rpc.setContentPane(content); } } else { Component oldContent = w.getComponentCount() > 0 ? w.getComponent(0) : null; if (oldContent instanceof OSXMaskingContentPane) { content = (OSXMaskingContentPane)oldContent; } else { content = new OSXMaskingContentPane(oldContent); w.add(content); } } return content; }