List of usage examples for javax.swing JFrame getWidth
public int getWidth()
From source file:org.openscience.jchempaint.application.JChemPaint.java
public static JChemPaintPanel showInstance(IChemModel chemModel, String title, boolean debug) { JFrame f = new JFrame(title + " - JChemPaint"); chemModel.setID(title);/* w w w . j av a 2 s. c om*/ f.addWindowListener(new JChemPaintPanel.AppCloser()); f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); JChemPaintPanel p = new JChemPaintPanel(chemModel, GUI_APPLICATION, debug, null); p.updateStatusBar(); f.setPreferredSize(new Dimension(800, 494)); //1.618 f.add(p); f.pack(); Point point = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint(); int w2 = (f.getWidth() / 2); int h2 = (f.getHeight() / 2); f.setLocation(point.x - w2, point.y - h2); f.setVisible(true); frameList.add(f); return p; }
From source file:org.squidy.nodes.ReacTIVision.java
public static void showErrorPopUp(String errorMessage) { //get screen size Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); //create pop up final JFrame frame = new JFrame(); frame.setResizable(false);//from ww w . j a va2s .co m frame.setAlwaysOnTop(true); frame.setUndecorated(true); JLabel text = new JLabel(" " + errorMessage + " "); frame.getContentPane().setBackground(Color.RED); text.setForeground(Color.WHITE); frame.add(text); frame.pack(); frame.setLocation((dim.width - frame.getWidth()) / 2, (dim.height - frame.getHeight()) / 2); frame.setVisible(true); frame.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent arg0) { frame.dispose(); } }); }
From source file:org.swiftexplorer.SwiftExplorer.java
private static void openMainWindow(final MainPanel cp) throws IOException { JFrame frame = new JFrame(Configuration.INSTANCE.getAppName()); Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); float ratio = (float) 0.8; Dimension windowSize = new Dimension((int) (screenSize.getWidth() * ratio), (int) (screenSize.getHeight() * ratio)); frame.setSize(windowSize.getSize()); frame.setLocationByPlatform(true);//from w ww .j a va 2 s . c om frame.setIconImage(ImageIO.read(SwiftExplorer.class.getResource("/icons/logo.png"))); frame.getContentPane().add(cp); frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (cp.onClose()) { System.exit(0); } } }); cp.setOwner(frame); frame.setJMenuBar(cp.createMenuBar()); // center the frame int x = (int) ((screenSize.getWidth() - frame.getWidth()) / 2); int y = (int) ((screenSize.getHeight() - frame.getHeight()) / 2); frame.setLocation(x, y); frame.setVisible(true); }