List of utility methods to do JFrame
File[] | inputFiles(JFrame argParent) input Files return inputFiles("Select a file...", argParent); |
void | installEscapeCloseOperation(final JFrame dialog) install Escape Close Operation Action dispatchClosing = new AbstractAction() { public void actionPerformed(ActionEvent event) { dialog.dispatchEvent(new WindowEvent(dialog, WindowEvent.WINDOW_CLOSING)); }; JRootPane root = dialog.getRootPane(); root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(ESCAPE_KEY_STROKE, ESCAPE_KEY); root.getActionMap().put(ESCAPE_KEY, dispatchClosing); ... |
JInternalFrame | internalizeFrame(JFrame frame) creates an internalized frame with the same title, size, menu bars and content pane JInternalFrame ifr = new JInternalFrame(frame.getTitle(), true, true, true, true); ifr.setSize(frame.getSize()); ifr.setContentPane(frame.getContentPane()); ifr.setJMenuBar(frame.getJMenuBar()); return ifr; |
boolean | isAv(JFrame frame) is Av try { final URL url = new URL(ROOT); final URLConnection con = url.openConnection(); con.connect(); } catch (MalformedURLException e) { JOptionPane.showMessageDialog(frame, "Check Internet Connection"); } catch (IOException ex) { JOptionPane.showMessageDialog(frame, "Check Internet Connection"); ... |
boolean | isVisibleNotMinimized(JFrame frame) is Visible Not Minimized assertEventDispatcherThread();
return (frame.isVisible() && frame.isShowing() && (frame.getExtendedState() & JFrame.ICONIFIED) == 0);
|
void | jointButton(JFrame frame, final JButton button) Allows to relate a frame to a button frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { button.setEnabled(true); }); |
void | loadImageToFrame(JFrame frame, BufferedImage image) This method is used for drawing an image to JFrame. frame.setBounds(0, 0, image.getWidth(), image.getHeight()); frame.setVisible(true); Graphics2D g = (Graphics2D) frame.getRootPane().getGraphics(); g.drawImage(image, null, 0, 0); |
void | locateForm(JFrame f, int x, int y, int w, int h) Centra un frame e ne setta le dimensioni Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); x = (screenSize.width - w) / 2; y = (screenSize.height - h) / 2; f.setBounds(x, y, w, h); |
void | makeFullScreen(JFrame frame) make Full Screen frame.setExtendedState(JFrame.MAXIMIZED_BOTH); frame.setUndecorated(true); frame.setResizable(false); |
void | makeShaped(final JFrame frame) make Shaped if ("Mac OS X".equals(System.getProperty("os.name"))) { frame.setUndecorated(true); frame.setBackground(new java.awt.Color(0, 0, 0, 0)); frame.getRootPane().putClientProperty("Window.shadow", Boolean.TRUE); frame.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { SwingUtilities.invokeLater(new Runnable() { ... |