public void run() { JFrame frame = new JFrame(pTitle); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationByPlatform(true); JPanel pane = new JPanel(new BorderLayout()); GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); BufferedImageIcon icon = new BufferedImageIcon(ImageUtil.accelerate(pImage, gc)); JScrollPane scroll = new JScrollPane(new JLabel(icon)); scroll.setBorder(null); pane.add(scroll); frame.setContentPane(pane); frame.pack(); frame.setVisible(true); } });
public static void main(String[] args) throws Exception { try { TextEditorPane textArea = new TextEditorPane(); textArea.load(FileLocation.create("d:/temp/test.txt"), "UTF-8"); JPanel cp = new JPanel(); cp.setPreferredSize(new java.awt.Dimension(300, 300)); cp.setLayout(new java.awt.BorderLayout()); cp.add(new JScrollPane(textArea)); JFrame frame = new JFrame(); frame.setContentPane(cp); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationByPlatform(true); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }
public void run() { JFrame frame = new JFrame(pTitle); frame.getRootPane().getActionMap().put("window-close", new AbstractAction() { public void actionPerformed(ActionEvent e) { Window window = SwingUtilities.getWindowAncestor((Component) e.getSource()); window.setVisible(false); window.dispose(); } }); frame.getRootPane().getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), "window-close"); frame.addWindowListener(new ExitIfNoWindowPresentHandler()); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setLocationByPlatform(true); JPanel pane = new JPanel(new BorderLayout()); JScrollPane scroll = new JScrollPane(pImage != null ? new ImageLabel(pImage) : new JLabel("(no image data)", JLabel.CENTER)); scroll.setBorder(null); pane.add(scroll); frame.setContentPane(pane); frame.pack(); frame.setVisible(true); } });
JFrame frame = new JFrame (); frame.pack(); // or frame.setSize(int, int); frame.setLocationByPlatform(true); frame.setVisible(true);
private static JFrame makeFrame(final String title, final JPanel content) { final JFrame frame = new JFrame(title); frame.getContentPane().add(content); frame.setLocationByPlatform(true); frame.pack(); frame.setVisible(true); return frame; }
JScrollPane master = new JScrollPane( new ScrollSSCCE() ); master.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); JFrame frame = new JFrame("Scroll SSCCE"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //frame.add( new ScrollSSCCE() ); frame.add( master ); frame.setLocationByPlatform( true ); frame.setSize(200, 400); frame.setVisible( true );
final JFrame frame = new JFrame("Scroll Bar Test"); final JPanel content = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JScrollPane scrollPane = new JScrollPane(content, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); for(int i = 0; i < 10; i++){ content.add(new JLabel("Label " + i)); } frame.add(scrollPane); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true);
public void run() { JFrame goframe = new JFrame("Go"); goframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel mainPanel = new JPanel(); mainPanel.add(new GoPanel()); mainPanel.add(createButtonPanel()); goframe.add(mainPanel); goframe.pack(); goframe.setLocationByPlatform(true); goframe.setVisible(true); }
private static void createAndShowGui() { JFrame frame = new MainPanel(); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setLocationByPlatform(false); frame.setVisible(true); }
private void runDemo() { JFrame frame = new JFrame(); frame.setLayout(new GridBagLayout()); frame.setSize(300, 300); frame.add(this); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationByPlatform(true); frame.setVisible(true); }
SwingUtils.invokeLater(new Runnable() { @Override public void run() { JFrame application = new JFrame(); PanelFurniture panel = new PanelFurniture(); application.add(panel); application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); application.setSize(600,450); application.setLocationByPlatform(true); application.setVisible(true); } });
MonModel model = new MonModel(); JTable table = new JTable(model); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new JScrollPane(table), BorderLayout.CENTER); f.pack(); f.setLocationByPlatform(true); f.setVisible(true);
public void run() { JFrame frame = new JFrame("DJ Native Swing Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new SimpleWebBrowserExample(), BorderLayout.CENTER); frame.setSize(800, 600); frame.setLocationByPlatform(true); frame.setVisible(true); } });
public void run() { JFrame frame = new JFrame("DJ Native Swing Test"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new NavigationParameters(), BorderLayout.CENTER); frame.setSize(800, 600); frame.setLocationByPlatform(true); frame.setVisible(true); } });
/** * Creates a window showing the specified image. */ public static ImagePanel showWindow(BufferedImage img, String title, boolean closeOnExit ) { JFrame frame = new JFrame(title); ImagePanel panel = new ImagePanel(img); frame.add(panel, BorderLayout.CENTER); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); if( closeOnExit ) frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); return panel; }
public void run() { JFrame frame = new JFrame(pTitle); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocationByPlatform(true); JPanel pane = new JPanel(new BorderLayout()); JScrollPane scroll = new JScrollPane(new ImageLabel(pImage)); scroll.setBorder(null); pane.add(scroll); frame.setContentPane(pane); frame.pack(); frame.setVisible(true); } });
private static void createAndShowGui() { JFrame frame = new JFrame("This should be working now..."); MainPanel mainPanel = new MainPanel(); frame.setLayout(new BorderLayout()); // pointless considering the setContentPane call //frame.add(mainPanel, BorderLayout.CENTER); frame.setContentPane(mainPanel); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.pack(); frame.setLocationByPlatform(false); //frame.setSize(500, 500); frame.setVisible(true); }
private static void createAndShowGui() { Toolbar toolBar = new Toolbar(); TextPanel textPanel = new TextPanel(); toolBar.setTextPanel(textPanel); // ****** passing in my reference ******* JFrame frame = new JFrame("Add New Lines"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().add(textPanel); frame.getContentPane().add(toolBar, BorderLayout.PAGE_START); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true); }
public static JFrame goFullScreen() { GraphicsEnvironment env = GraphicsEnvironment. getLocalGraphicsEnvironment(); device = env.getDefaultScreenDevice(); original_mode = device.getDisplayMode(); JFrame frame = new JFrame(device.getDefaultConfiguration()); frame.setUndecorated(true); frame.setResizable(false); frame.setLocationByPlatform(true); device.setFullScreenWindow(frame); return frame; }
@ScriptFunction public void setLocationByPlatform(boolean aValue) { locationByPlatform = aValue; if (surface instanceof JDialog) { ((JDialog) surface).setLocationByPlatform(locationByPlatform); } if (surface instanceof JInternalFrame) { //((JInternalFrame) surface).setLocationByPlatform(locationByPlatform) } if (surface instanceof JFrame) { ((JFrame) surface).setLocationByPlatform(locationByPlatform); } }