Search in sources :

Example 1 with RoundedButton

use of menus.RoundedButton in project DistributedFractalNetwork by Budder21.

the class FractalChooserMenu method chooseFractal.

/**
	 * Allows a user to choose a saved fractal and set zoom speed and resolution
	 * parameters
	 * @return a RenderManger for the network to use. Will return null if no fractal if the window is closed
	 */
public static RenderManager chooseFractal() {
    waiting = true;
    manager = null;
    JFrame f = new JFrame();
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    JLabel message = new JLabel(" Fractal:");
    message.setFont(Constants.mediumFont);
    p.add(message, BorderLayout.WEST);
    RoundedButton chooseFile = new RoundedButton();
    chooseFile.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1) {
                e1.printStackTrace();
            }
            JFileChooser fileChooser = new JFileChooser();
            FileNameExtensionFilter filter = new FileNameExtensionFilter("Fractal", "prop");
            fileChooser.setFileFilter(filter);
            manager = new RenderManager(fileChooser.getSelectedFile());
        }
    });
    p.add(chooseFile, BorderLayout.CENTER);
    f.setContentPane(p);
    f.pack();
    f.setLocationRelativeTo(null);
    f.setResizable(false);
    f.addWindowListener(new WindowListener() {

        public void windowOpened(WindowEvent e) {
        }

        public void windowClosed(WindowEvent e) {
        }

        public void windowIconified(WindowEvent e) {
        }

        public void windowDeiconified(WindowEvent e) {
        }

        public void windowActivated(WindowEvent e) {
        }

        public void windowDeactivated(WindowEvent e) {
        }

        @Override
        public void windowClosing(WindowEvent e) {
            waiting = false;
        }
    });
    f.setVisible(true);
    while (manager == null || waiting) {
    }
    return manager;
}
Also used : JPanel(javax.swing.JPanel) WindowListener(java.awt.event.WindowListener) RoundedButton(menus.RoundedButton) ActionEvent(java.awt.event.ActionEvent) JLabel(javax.swing.JLabel) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) JFileChooser(javax.swing.JFileChooser) JFrame(javax.swing.JFrame) WindowEvent(java.awt.event.WindowEvent)

Aggregations

BorderLayout (java.awt.BorderLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 WindowEvent (java.awt.event.WindowEvent)1 WindowListener (java.awt.event.WindowListener)1 JFileChooser (javax.swing.JFileChooser)1 JFrame (javax.swing.JFrame)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 FileNameExtensionFilter (javax.swing.filechooser.FileNameExtensionFilter)1 RoundedButton (menus.RoundedButton)1