public static void main (String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("My Test App"); frame.setSize(480, 320); frame.setVisible(true); JOptionPane.showConfirmDialog(null, "Working dir: " + new File(".").getAbsolutePath()); } }
protected void updateGraph(FunctionGraph someGraph, String title) { if (someGraph.getParent() == null) { JFrame jf = someGraph.showInJFrame(title, 400, 250, false, false); setDependentWindowLocation(jf); } else { JFrame jf = (JFrame) SwingUtilities.getWindowAncestor(someGraph); jf.setTitle(title); jf.setVisible(true); // just to be sure someGraph.repaint(); } } }
frame.setTitle(appName); frame.pack(); frame.setSize(400, 300); frame.setResizable(true); frame.setVisible(true);
/** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub JFrame mimeFrame = new JFrame(); MimeTypeConfig mimeConf = new MimeTypeConfig(); mimeFrame.add(mimeConf); mimeFrame.setTitle("mime"); mimeFrame.setVisible(true); }
// Display a frame with HTML code public JFrame displayHTMLJFrame(String HTML, String title){ JFrame fen = new JFrame(); fen.setSize(1000, 800); fen.setTitle(title); JEditorPane pan = new JEditorPane(); pan.setEditorKit(new HTMLEditorKit()); pan.setEditable(false); pan.setText(HTML); fen.add(pan); return fen; }
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { JFrame win = new HelloWorldSwing(); win.setTitle("TextAreaDemo"); win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); win.setVisible(true); } }); }
/** Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setTitle("Planet Render"); frame.setBounds(100, 100, 1200, 700); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new AppContent()); } }
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setTitle("Title"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JButton button = new JButton(); button.setText("Hello, World!"); frame.getContentPane().add(button, BorderLayout.CENTER); frame.setSize(200, 100); frame.pack(); frame.setVisible(true); frame.show(); } }
private void launchEventPanel(final String title) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame myFrame = new JFrame(); myFrame.setTitle("Conference Call"); myFrame.setIconImage(CallConference.this.myCore.myPanel.myIconManager.getPromptIcon(CallEMart.class.toString())); myFrame.getContentPane().add(CallConference.this.myEventPanel, "Center"); myFrame.pack(); myFrame.setVisible(true); } }); }
JFrame t = new JFrame(); t.setSize(600,300); t.setFont(new Font("System", Font.PLAIN, 14)); Font f = t.getFont(); FontMetrics fm = t.getFontMetrics(f); int x = fm.stringWidth("Hello Center"); int y = fm.stringWidth(" "); int z = t.getWidth()/2 - (x/2); int w = z/y; String pad =""; //for (int i=0; i!=w; i++) pad +=" "; pad = String.format("%"+w+"s", pad); t.setTitle(pad+"Hello Center");
static void initApplication(JFrame frame, RupsController controller, final int onCloseOperation) { // title bar frame.setTitle("iText RUPS " + Version.getInstance().getVersion()); frame.setIconImage(Toolkit.getDefaultToolkit().getImage(Rups.class.getResource("logo.png"))); frame.setDefaultCloseOperation(onCloseOperation); // the content frame.setJMenuBar(controller.getMenuBar()); frame.getContentPane().add(controller.getMasterComponent(), java.awt.BorderLayout.CENTER); frame.setVisible(true); }
protected void updateGraph(FunctionGraph someGraph, String title) { if (someGraph.getParent() == null) { JFrame jf = someGraph.showInJFrame(title, 400, 250, false, false); setDependentWindowLocation(jf); } else { JFrame jf = (JFrame) SwingUtilities.getWindowAncestor(someGraph); jf.setTitle(title); jf.setVisible(true); // just to be sure someGraph.repaint(); } } }
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setTitle("Debug"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(false); FilenameDialog dialog = new FilenameDialog(frame, true, "Save as..."); System.out.println("Showing dialog..."); dialog.setVisible(true); String filename = dialog.getFilename(); System.out.println("Filename: " + filename + " (length = " + filename.length() + ')'); System.exit(0); } }
private void launchEventPanel(final String title) { EventQueue.invokeLater(new Runnable() { public void run() { JFrame myFrame = new JFrame(); myFrame.setTitle(title); myFrame.setIconImage(CrConference.this.mainCore.myPanel.myIconManager.getPromptIcon(Mart.class.toString())); myFrame.getContentPane().add(Conference.this.myEventPanel, "Center"); myFrame.pack(); myFrame.setVisible(true); } }); }
JFrame t = new JFrame(); t.setSize(600,300); t.setFont(new Font("System", Font.PLAIN, 14)); Font f = t.getFont(); FontMetrics fm = t.getFontMetrics(f); int x = fm.stringWidth("Hello Center"); int y = fm.stringWidth(" "); int z = t.getWidth()/2 - (x/2); int w = z/y; String pad =""; //for (int i=0; i!=w; i++) pad +=" "; pad = String.format("%"+w+"s", pad); t.setTitle(pad+"Hello Center");
public VisualizerWindow(WindowSettings ws) { this.setPreferredSize(new Dimension(ws.width, ws.height)); this.setLocation(ws.xLocation, ws.yLocation); // Create the OpenGL rendering canvas this.canvas = new VisualizerCanvas(); canvas.setPreferredSize(new Dimension(ws.width, ws.height)); canvas.setLocation(ws.xLocation, ws.yLocation); // Create a animator that drives canvas' display() at the specified FPS. this.animator = new FPSAnimator(canvas, FPS, true); // Create the top-level container final JFrame frame = this; // Swing's JFrame or AWT's Frame frame.getContentPane().add(canvas); // Manage pausing and resuming the animator when it doesn't need to run. frame.addWindowListener(this); frame.setTitle(TITLE); frame.pack(); frame.setVisible(true); animator.start(); // start the animation loop }
/** * Displays the picture in a window on the screen. */ public void show() { // create the GUI for viewing the image if needed if (frame == null) { frame = new JFrame(); JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("File"); menuBar.add(menu); JMenuItem menuItem1 = new JMenuItem(" Save... "); menuItem1.addActionListener(this); // use getMenuShortcutKeyMaskEx() in Java 10 (getMenuShortcutKeyMask() deprecated) menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu.add(menuItem1); frame.setJMenuBar(menuBar); frame.setContentPane(getJLabel()); // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); if (filename == null) frame.setTitle(width + "-by-" + height); else frame.setTitle(filename); frame.setResizable(false); frame.pack(); frame.setVisible(true); } // draw frame.repaint(); }
/** * Displays the picture in a window on the screen. */ public void show() { // create the GUI for viewing the image if needed if (frame == null) { frame = new JFrame(); JMenuBar menuBar = new JMenuBar(); JMenu menu = new JMenu("File"); menuBar.add(menu); JMenuItem menuItem1 = new JMenuItem(" Save... "); menuItem1.addActionListener(this); // use getMenuShortcutKeyMaskEx() in Java 10 (getMenuShortcutKeyMask() deprecated) menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); menu.add(menuItem1); frame.setJMenuBar(menuBar); frame.setContentPane(getJLabel()); // f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); if (filename == null) frame.setTitle(width + "-by-" + height); else frame.setTitle(filename); frame.setResizable(false); frame.pack(); frame.setVisible(true); } // draw frame.repaint(); }
private void init() { if (frame != null) frame.setVisible(false); frame = new JFrame(); offscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); onscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // closes only current window frame.setFocusTraversalKeysEnabled(false); // to recognize VK_TAB with isKeyPressed() frame.setTitle(name); frame.setJMenuBar(createMenuBar()); frame.pack(); frame.requestFocusInWindow(); frame.setVisible(true);
private static void init() { if (frame != null) frame.setVisible(false); frame = new JFrame(); offscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); onscreenImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // closes all windows frame.setTitle("Standard Draw"); frame.setJMenuBar(createMenuBar()); frame.pack(); frame.requestFocusInWindow(); frame.setVisible(true);