List of utility methods to do JFrame
void | centreJustifyFrame(final JFrame frame, final int y_position) Move the given JFrame to the centre of the screen. final Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); final int x_position = (screen.width - frame.getSize().width) / 2; frame.setLocation(new Point(x_position, y_position)); |
void | centreWindow(Window c, JFrame frame) centre Window Dimension app = frame.getSize(); int x = frame.getX() + (app.width - c.getWidth()) / 2; int y = frame.getY() + (app.height - c.getHeight()) / 3; if (y < frame.getY()) { y = frame.getY(); c.setLocation(x, y); |
void | changeLookAndFeel(final String lookName, final JFrame frame) change Look And Feel try { UIManager.setLookAndFeel(lookName); SwingUtilities.updateComponentTreeUI(frame); frame.pack(); } catch (Exception e) { |
File | chooseFile(String directoryPath, String dialogTitle, String selectedFileName, boolean saveDialog, String[] extensions, JFrame parentFrame) choose File File file = null; JFileChooser fc = null; if (directoryPath != null) { fc = new JFileChooser(directoryPath); } else { fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); ... |
void | ChooserDemo(JFrame jf, Component comp) Chooser Demo JMenuItem itemOpen, itemSave, itemDir, itemColor; JMenuBar mnuBar = new JMenuBar(); jf.setJMenuBar(mnuBar); JMenu mnu = new JMenu("File"); mnuBar.add(mnu); itemOpen = new JMenuItem("Buka File"); mnu.add(itemOpen); itemOpen.addActionListener(new ActionListener() { ... |
void | closeFrame(JFrame frame, JProgressBar progressBar) close Frame frame.setVisible(false); frame.setCursor(java.awt.Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
void | closeOnEsc(JFrame frame) close On Esc closeOnKeyStroke(frame.getRootPane(), ESC); |
void | closeOnEscape(final JFrame frame) close On Escape KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE"); Action actionListener = new AbstractAction() { public void actionPerformed(ActionEvent actionEvent) { frame.setVisible(false); frame.dispose(); }; JRootPane rootPane = frame.getRootPane(); ... |
void | closeOnEscape(final JFrame frame) Make the window close when the used presses escape. closeOnEscape(frame, frame.getRootPane()); |
void | closeOnKeyStroke(JFrame frame, KeyStroke keyStroke) close On Key Stroke closeOnKeyStroke(frame.getRootPane(), keyStroke); |