Example usage for javax.swing JTextField selectAll

List of usage examples for javax.swing JTextField selectAll

Introduction

In this page you can find the example usage for javax.swing JTextField selectAll.

Prototype

public void selectAll() 

Source Link

Document

Selects all the text in the TextComponent.

Usage

From source file:com.mgmtp.perfload.loadprofiles.ui.component.IntegerCellEditor.java

@Override
public boolean stopCellEditing() {
    String s = (String) super.getCellEditorValue();
    JTextField textField = (JTextField) getComponent();

    if (isBlank(s)) {
        textField.setBorder(new LineBorder(Color.red));
        return false;
    }/*from   w w w .  j  av a  2s  .c  o  m*/

    try {
        value = Integer.valueOf(s);
    } catch (NumberFormatException ex2) {
        textField.setBorder(new LineBorder(Color.red));
        textField.selectAll();
        return false;
    }

    return super.stopCellEditing();
}

From source file:com.mgmtp.perfload.loadprofiles.ui.component.DoubleCellEditor.java

@Override
public boolean stopCellEditing() {
    String s = (String) super.getCellEditorValue();
    JTextField textField = (JTextField) getComponent();

    if (isBlank(s)) {
        textField.setBorder(new LineBorder(Color.red));
        return false;
    }//from  ww w  .  ja v a  2s .c o m

    try {
        value = Double.valueOf(s);
    } catch (NumberFormatException ex2) {
        try {
            Number n = FORMAT.parse(s);
            value = n.doubleValue();
        } catch (ParseException ex1) {
            textField.setBorder(new LineBorder(Color.red));
            textField.selectAll();
            return false;
        }
    }

    return super.stopCellEditing();
}

From source file:com.github.cric.app.ui.SettingPanel.java

private JTextField textField(String defaultValue, boolean isInt) {

    JTextField field = new JTextField(defaultValue);
    addBorder(field, Color.GRAY);
    field.addFocusListener(new FocusListener() {

        @Override/*from  w w  w  . j  av a 2  s  . c  om*/
        public void focusLost(FocusEvent e) {

            handleFocusLost(field, isInt);
        }

        @Override
        public void focusGained(FocusEvent e) {

            addBorder(field, Color.GRAY);
            field.selectAll();
        }
    });
    return field;
}

From source file:com.tascape.qa.th.android.driver.App.java

/**
 * The method starts a GUI to let an user inspect element tree and take screenshot when the user is interacting
 * with the app-under-test manually. Please make sure to set timeout long enough for manual interaction.
 *
 * @param timeoutMinutes timeout in minutes to fail the manual steps
 *
 * @throws Exception if case of error//from  ww  w.  j  a v  a2s  .  c  o  m
 */
public void interactManually(int timeoutMinutes) throws Exception {
    LOG.info("Start manual UI interaction");
    long end = System.currentTimeMillis() + timeoutMinutes * 60000L;

    AtomicBoolean visible = new AtomicBoolean(true);
    AtomicBoolean pass = new AtomicBoolean(false);
    String tName = Thread.currentThread().getName() + "m";
    SwingUtilities.invokeLater(() -> {
        JDialog jd = new JDialog((JFrame) null, "Manual Device UI Interaction - " + device.getProductDetail());
        jd.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);

        JPanel jpContent = new JPanel(new BorderLayout());
        jd.setContentPane(jpContent);
        jpContent.setPreferredSize(new Dimension(1088, 828));
        jpContent.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

        JPanel jpInfo = new JPanel();
        jpContent.add(jpInfo, BorderLayout.PAGE_START);
        jpInfo.setLayout(new BorderLayout());
        {
            JButton jb = new JButton("PASS");
            jb.setForeground(Color.green.darker());
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_START);
            jb.addActionListener(event -> {
                pass.set(true);
                jd.dispose();
                visible.set(false);
            });
        }
        {
            JButton jb = new JButton("FAIL");
            jb.setForeground(Color.red);
            jb.setFont(jb.getFont().deriveFont(Font.BOLD));
            jpInfo.add(jb, BorderLayout.LINE_END);
            jb.addActionListener(event -> {
                pass.set(false);
                jd.dispose();
                visible.set(false);
            });
        }

        JLabel jlTimeout = new JLabel("xxx seconds left", SwingConstants.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        jpInfo.add(jlTimeout, BorderLayout.CENTER);
        new SwingWorker<Long, Long>() {
            @Override
            protected Long doInBackground() throws Exception {
                while (System.currentTimeMillis() < end) {
                    Thread.sleep(1000);
                    long left = (end - System.currentTimeMillis()) / 1000;
                    this.publish(left);
                }
                return 0L;
            }

            @Override
            protected void process(List<Long> chunks) {
                Long l = chunks.get(chunks.size() - 1);
                jlTimeout.setText(l + " seconds left");
                if (l < 850) {
                    jlTimeout.setForeground(Color.red);
                }
            }
        }.execute();

        JPanel jpResponse = new JPanel(new BorderLayout());
        JPanel jpProgress = new JPanel(new BorderLayout());
        jpResponse.add(jpProgress, BorderLayout.PAGE_START);

        JTextArea jtaJson = new JTextArea();
        jtaJson.setEditable(false);
        jtaJson.setTabSize(4);
        Font font = jtaJson.getFont();
        jtaJson.setFont(new Font("Courier New", font.getStyle(), font.getSize()));

        JTree jtView = new JTree();

        JTabbedPane jtp = new JTabbedPane();
        jtp.add("tree", new JScrollPane(jtView));
        jtp.add("json", new JScrollPane(jtaJson));

        jpResponse.add(jtp, BorderLayout.CENTER);

        JPanel jpScreen = new JPanel();
        jpScreen.setMinimumSize(new Dimension(200, 200));
        jpScreen.setLayout(new BoxLayout(jpScreen, BoxLayout.PAGE_AXIS));
        JScrollPane jsp1 = new JScrollPane(jpScreen);
        jpResponse.add(jsp1, BorderLayout.LINE_START);

        JPanel jpJs = new JPanel(new BorderLayout());
        JTextArea jtaJs = new JTextArea();
        jpJs.add(new JScrollPane(jtaJs), BorderLayout.CENTER);

        JSplitPane jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, jpResponse, jpJs);
        jSplitPane.setResizeWeight(0.88);
        jpContent.add(jSplitPane, BorderLayout.CENTER);

        JPanel jpLog = new JPanel();
        jpLog.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0));
        jpLog.setLayout(new BoxLayout(jpLog, BoxLayout.LINE_AXIS));

        JCheckBox jcbTap = new JCheckBox("Enable Click", null, false);
        jpLog.add(jcbTap);
        jpLog.add(Box.createHorizontalStrut(8));

        JButton jbLogUi = new JButton("Log Screen");
        jpResponse.add(jpLog, BorderLayout.PAGE_END);
        {
            jpLog.add(jbLogUi);
            jbLogUi.addActionListener((ActionEvent event) -> {
                jtaJson.setText("waiting for screenshot...");
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        LOG.debug("\n\n");
                        try {
                            WindowHierarchy wh = device.loadWindowHierarchy();
                            jtView.setModel(getModel(wh));

                            jtaJson.setText("");
                            jtaJson.append(wh.root.toJson().toString(2));
                            jtaJson.append("\n");

                            File png = device.takeDeviceScreenshot();
                            BufferedImage image = ImageIO.read(png);

                            int w = device.getDisplayWidth();
                            int h = device.getDisplayHeight();

                            BufferedImage resizedImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
                            Graphics2D g2 = resizedImg.createGraphics();
                            g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                                    RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                            g2.drawImage(image, 0, 0, w, h, null);
                            g2.dispose();

                            JLabel jLabel = new JLabel(new ImageIcon(resizedImg));
                            jpScreen.removeAll();
                            jsp1.setPreferredSize(new Dimension(w + 30, h));
                            jpScreen.add(jLabel);

                            jLabel.addMouseListener(new MouseAdapter() {
                                @Override
                                public void mouseClicked(MouseEvent e) {
                                    LOG.debug("clicked at {},{}", e.getPoint().getX(), e.getPoint().getY());
                                    if (jcbTap.isSelected()) {
                                        device.click(e.getPoint().x, e.getPoint().y);
                                        device.waitForIdle();
                                        jbLogUi.doClick();
                                    }
                                }
                            });
                        } catch (Exception ex) {
                            LOG.error("Cannot log screen", ex);
                            jtaJson.append("Cannot log screen");
                        }
                        jtaJson.append("\n\n\n");
                        LOG.debug("\n\n");

                        jd.setSize(jd.getBounds().width + 1, jd.getBounds().height + 1);
                        jd.setSize(jd.getBounds().width - 1, jd.getBounds().height - 1);
                    }
                };
                t.start();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbLogMsg = new JButton("Log Message");
            jpLog.add(jbLogMsg);
            JTextField jtMsg = new JTextField(10);
            jpLog.add(jtMsg);
            jtMsg.addFocusListener(new FocusListener() {
                @Override
                public void focusLost(final FocusEvent pE) {
                }

                @Override
                public void focusGained(final FocusEvent pE) {
                    jtMsg.selectAll();
                }
            });
            jtMsg.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(java.awt.event.KeyEvent e) {
                    if (e.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
                        jbLogMsg.doClick();
                    }
                }
            });
            jbLogMsg.addActionListener(event -> {
                Thread t = new Thread(tName) {
                    @Override
                    public void run() {
                        String msg = jtMsg.getText();
                        if (StringUtils.isNotBlank(msg)) {
                            LOG.info("{}", msg);
                            jtMsg.selectAll();
                        }
                    }
                };
                t.start();
                try {
                    t.join();
                } catch (InterruptedException ex) {
                    LOG.error("Cannot take screenshot", ex);
                }
                jtMsg.requestFocus();
            });
        }
        jpLog.add(Box.createHorizontalStrut(38));
        {
            JButton jbClear = new JButton("Clear");
            jpLog.add(jbClear);
            jbClear.addActionListener(event -> {
                jtaJson.setText("");
            });
        }

        JPanel jpAction = new JPanel();
        jpContent.add(jpAction, BorderLayout.PAGE_END);
        jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS));
        jpJs.add(jpAction, BorderLayout.PAGE_END);

        jd.pack();
        jd.setVisible(true);
        jd.setLocationRelativeTo(null);

        jbLogUi.doClick();
    });

    while (visible.get()) {
        if (System.currentTimeMillis() > end) {
            LOG.error("Manual UI interaction timeout");
            break;
        }
        Thread.sleep(500);
    }

    if (pass.get()) {
        LOG.info("Manual UI Interaction returns PASS");
    } else {
        Assert.fail("Manual UI Interaction returns FAIL");
    }
}

From source file:edu.ku.brc.af.ui.db.DatabaseLoginPanel.java

/**
 * Creates the UI for the login and hooks up any listeners.
 * @param isDlg  whether the parent is a dialog (false mean JFrame)
 * @param iconName the icon that will be shown in the panel
 * @param engageUPPrefs whether it should load and save the username password into the prefs
 * @param helpContext the help context to use.
 *///from ww w  .  j av a  2  s .c  o m
protected void createUI(final boolean isDlg, final String iconName, final String helpContext) {
    final boolean isNotEmbedded = !DBConnection.getInstance().isEmbedded() && !UIRegistry.isMobile();
    final AppPreferences localPrefs = AppPreferences.getLocalPrefs();

    //Font cachedFont = UIManager.getFont("JLabel.font");
    SkinItem skinItem = SkinsMgr.getSkinItem("LoginPanel");
    if (skinItem != null) {
        skinItem.pushFG("Label.foreground");
    }

    if (isNotEmbedded) {
        SpinnerModel portModel = new SpinnerNumberModel(3306, //initial value
                0, //min
                Integer.MAX_VALUE, //max
                1); //step
        portSpinner = new JSpinner(portModel);
        JSpinner.NumberEditor editor = new JSpinner.NumberEditor(portSpinner, "#");
        portSpinner.setEditor(editor);

        portSpinner.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex());
                if (drvInfo != null && isNotEmbedded && portSpinner != null) {
                    drvInfo.setPort((Integer) portSpinner.getValue());
                }
            }
        });
        setControlSize(portSpinner);
    }

    // First create the controls and hook up listeners
    dbPickList = new PropertiesPickListAdapter("login.databases"); //$NON-NLS-1$
    svPickList = new PropertiesPickListAdapter("login.servers"); //$NON-NLS-1$

    username = createTextField(15);
    password = createPasswordField(15);

    FocusAdapter focusAdp = new FocusAdapter() {
        @Override
        public void focusGained(FocusEvent e) {
            super.focusGained(e);

            JTextField tf = (JTextField) e.getSource();
            tf.selectAll();
        }
    };
    username.addFocusListener(focusAdp);
    password.addFocusListener(focusAdp);

    databases = new ValComboBox(dbPickList);
    if (databases.getComboBox() instanceof Java2sAutoComboBox) {
        ((Java2sAutoComboBox) databases.getComboBox()).setCaseSensitive(true);
    }
    servers = new ValComboBox(svPickList);

    dbPickList.setComboBox(databases);
    svPickList.setComboBox(servers);

    setControlSize(password);
    setControlSize(databases);
    setControlSize(servers);

    if (masterUsrPwdProvider != null) {
        editKeyInfoBtn = UIHelper.createI18NButton("CONFIG_MSTR_KEY");
        editKeyInfoBtn.setIcon(IconManager.getIcon("Key", IconManager.IconSize.Std20));
        editKeyInfoBtn.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (masterUsrPwdProvider != null && databases != null) {
                    String itemName = null;
                    if (databases.getComboBox().getSelectedItem() instanceof String) {
                        itemName = (String) databases.getComboBox().getSelectedItem();
                    } else {
                        PickListItemIFace pli = (PickListItemIFace) databases.getComboBox().getSelectedItem();
                        if (pli != null && pli.getValue() != null) {
                            itemName = pli.getValue();
                        }
                    }

                    if (itemName != null) {
                        masterUsrPwdProvider.editMasterInfo(username.getText(), itemName, false);
                    }
                }
            }
        });
    }

    rememberUsernameCBX = createCheckBox(getResourceString("rememberuser")); //$NON-NLS-1$
    rememberUsernameCBX.setEnabled(engageUPPrefs);

    statusBar = new JStatusBar();
    statusBar.setErrorIcon(IconManager.getIcon("Error", IconManager.IconSize.Std16)); //$NON-NLS-1$

    cancelBtn = createButton(getResourceString("CANCEL")); //$NON-NLS-1$
    loginBtn = createButton(getResourceString("Login")); //$NON-NLS-1$
    helpBtn = createButton(getResourceString("HELP")); //$NON-NLS-1$

    forwardImgIcon = IconManager.getIcon("Forward"); //$NON-NLS-1$
    downImgIcon = IconManager.getIcon("Down"); //$NON-NLS-1$
    moreBtn = new JCheckBox(getResourceString("LOGIN_DLG_MORE"), forwardImgIcon); // XXX I18N //$NON-NLS-1$
    setControlSize(moreBtn);

    // Extra
    dbDrivers = DatabaseDriverInfo.getDriversList();
    dbDriverCBX = createComboBox(dbDrivers);

    dbDriverCBX.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            updateUIControls();

            DatabaseDriverInfo drvInfo = dbDrivers.get(dbDriverCBX.getSelectedIndex());
            if (drvInfo != null && isNotEmbedded && portSpinner != null) {
                Integer defPort = drvInfo.getPortAsInt();
                int portFromPref = localPrefs.getInt(LOGIN_PORT, defPort);

                portSpinner.setValue(portFromPref);
                drvInfo.setPort(portFromPref);
            }
        }
    });

    if (dbDrivers.size() > 0) {
        if (dbDrivers.size() == 1) {
            dbDriverCBX.setSelectedIndex(0);
            dbDriverCBX.setEnabled(false);

        } else {
            String selectedStr = localPrefs.get("login.dbdriver_selected", "MySQL"); //$NON-NLS-1$ //$NON-NLS-2$
            int inx = Collections.binarySearch(dbDrivers,
                    new DatabaseDriverInfo(selectedStr, null, null, false, null));
            dbDriverCBX.setSelectedIndex(inx > -1 ? inx : -1);
        }

    } else {
        JOptionPane.showConfirmDialog(null, getResourceString("NO_DBDRIVERS"), //$NON-NLS-1$
                getResourceString("NO_DBDRIVERS_TITLE"), JOptionPane.CLOSED_OPTION); //$NON-NLS-1$
        System.exit(1);
    }

    addFocusListenerForTextComp(username);
    addFocusListenerForTextComp(password);

    addKeyListenerFor(username, !isDlg);
    addKeyListenerFor(password, !isDlg);

    addKeyListenerFor(databases.getTextField(), !isDlg);
    addKeyListenerFor(servers.getTextField(), !isDlg);

    if (!isDlg) {
        addKeyListenerFor(loginBtn, true);
    }

    rememberUsernameCBX.setSelected(engageUPPrefs ? localPrefs.getBoolean("login.rememberuser", false) : false); //$NON-NLS-1$

    cancelBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (dbListener != null) {
                dbListener.cancelled();
            }
        }
    });

    loginBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            doLogin();
        }
    });

    HelpMgr.registerComponent(helpBtn, helpContext); //$NON-NLS-1$

    moreBtn.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (extraPanel.isVisible()) {
                if (dbDriverCBX.getSelectedIndex() != -1) {
                    extraPanel.setVisible(false);
                    moreBtn.setIcon(forwardImgIcon);
                }

            } else {
                extraPanel.setVisible(true);
                moreBtn.setIcon(downImgIcon);
            }
            if (window != null) {
                window.pack();
            }
        }
    });

    // Ask the PropertiesPickListAdapter to set the index from the prefs
    dbPickList.setSelectedIndex();
    svPickList.setSelectedIndex();

    servers.getTextField().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            updateUIControls();
        }
    });

    databases.getTextField().addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            updateUIControls();
        }
    });

    databases.getTextField().addFocusListener(new FocusAdapter() {
        String server = null;

        private String getServerStr() {
            String serverStr = null;
            Object serverObj = servers.getValue();
            if (serverObj != null) {
                serverStr = serverObj.toString();
            }
            return serverStr;
        }

        @Override
        public void focusGained(FocusEvent e) {
            server = getServerStr();
        }

        @Override
        public void focusLost(FocusEvent e) {
            if (server != null) {
                String newVal = getServerStr();
                if (newVal != null && !newVal.equals(server)) {
                    setUsrPwdControlsFromPrefs();
                }
            }
        }
    });

    setUsrPwdControlsFromPrefs();

    // Layout the form

    PanelBuilder formBuilder = new PanelBuilder(new FormLayout("p,3dlu,p:g", "p,2dlu,p,2dlu,p,2dlu,p,2dlu,p")); //$NON-NLS-1$ //$NON-NLS-2$
    CellConstraints cc = new CellConstraints();
    formBuilder.addSeparator(getResourceString("LOGINLABEL"), cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$

    addLine("username", username, formBuilder, cc, 3); //$NON-NLS-1$
    addLine("password", password, formBuilder, cc, 5); //$NON-NLS-1$
    formBuilder.add(moreBtn, cc.xy(3, 7));

    PanelBuilder extraPanelBlder = new PanelBuilder(new FormLayout("p,3dlu,p:g", //$NON-NLS-1$ 
            UIHelper.createDuplicateJGoodiesDef("p", "2dlu", isNotEmbedded ? 9 : 11))); //$NON-NLS-1$ //$NON-NLS-2$

    extraPanel = extraPanelBlder.getPanel();
    extraPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 4, 2));

    //extraPanelBlder.addSeparator("", cc.xywh(1, 1, 3, 1)); //$NON-NLS-1$
    int y = 1;
    y = addLine(null, rememberUsernameCBX, extraPanelBlder, cc, y);
    y = addLine("databases", databases, extraPanelBlder, cc, y); //$NON-NLS-1$
    y = addLine("servers", servers, extraPanelBlder, cc, y); //$NON-NLS-1$

    y = addLine("driver", dbDriverCBX, extraPanelBlder, cc, y); //$NON-NLS-1$
    if (isNotEmbedded) {
        y = addLine("port", portSpinner, extraPanelBlder, cc, y); //$NON-NLS-1$
    }
    if (editKeyInfoBtn != null) {
        PanelBuilder pb = new PanelBuilder(new FormLayout("p,f:p:g", "p"));
        pb.add(editKeyInfoBtn, cc.xy(1, 1));
        y = addLine(null, pb.getPanel(), extraPanelBlder, cc, y);
        pb.getPanel().setOpaque(false);
    }
    extraPanel.setVisible(false);

    formBuilder.add(extraPanelBlder.getPanel(), cc.xywh(3, 9, 1, 1));

    PanelBuilder outerPanel = new PanelBuilder(new FormLayout("p,3dlu,p:g", "t:p,2dlu,p,2dlu,p"), this); //$NON-NLS-1$ //$NON-NLS-2$
    JLabel icon = StringUtils.isNotEmpty(iconName) ? new JLabel(IconManager.getIcon(iconName)) : null;

    if (icon != null) {
        icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 2, 2));
    }

    formBuilder.getPanel().setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 5));

    if (icon != null) {
        outerPanel.add(icon, cc.xy(1, 1));
    }
    JPanel btnPanel = ButtonBarFactory.buildOKCancelHelpBar(loginBtn, cancelBtn, helpBtn);
    outerPanel.add(formBuilder.getPanel(), cc.xy(3, 1));
    outerPanel.add(btnPanel, cc.xywh(1, 3, 3, 1));
    outerPanel.add(statusBar, cc.xywh(1, 5, 3, 1));

    formBuilder.getPanel().setOpaque(false);
    outerPanel.getPanel().setOpaque(false);
    btnPanel.setOpaque(false);

    updateUIControls();

    if (skinItem != null) {
        skinItem.popFG("Label.foreground");
    }

    if (AppPreferences.getLocalPrefs().getBoolean(expandExtraPanelName, false)) {
        extraPanel.setVisible(true);
        moreBtn.setIcon(downImgIcon);
    }
}

From source file:se.llbit.chunky.renderer.ui.RenderControls.java

private JPanel buildGeneralPane() {
    JLabel canvasSizeLbl = new JLabel("Canvas size:");
    JLabel canvasSizeAdvisory = new JLabel("Note: Actual image size may not be the same as the window size!");

    canvasSizeCB.setEditable(true);//from w  ww .  j  a  v a2s.co m
    canvasSizeCB.addItem("400x400");
    canvasSizeCB.addItem("1024x768");
    canvasSizeCB.addItem("960x540");
    canvasSizeCB.addItem("1920x1080");
    canvasSizeCB.addActionListener(canvasSizeListener);
    final JTextField canvasSizeEditor = (JTextField) canvasSizeCB.getEditor().getEditorComponent();
    canvasSizeEditor.addFocusListener(new FocusListener() {
        @Override
        public void focusLost(FocusEvent e) {
        }

        @Override
        public void focusGained(FocusEvent e) {
            canvasSizeEditor.selectAll();
        }
    });

    updateCanvasSizeField();

    loadSceneBtn.setText("Load Scene");
    loadSceneBtn.setIcon(Icon.load.imageIcon());
    loadSceneBtn.addActionListener(loadSceneListener);

    JButton loadSelectedChunksBtn = new JButton("Load Selected Chunks");
    loadSelectedChunksBtn.setToolTipText("Load the chunks that are currently selected in the map view");
    loadSelectedChunksBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            sceneMan.loadChunks(chunky.getWorld(), chunky.getSelectedChunks());
        }
    });

    JButton reloadChunksBtn = new JButton("Reload Chunks");
    reloadChunksBtn.setIcon(Icon.reload.imageIcon());
    reloadChunksBtn.setToolTipText("Reload all chunks in the scene");
    reloadChunksBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            sceneMan.reloadChunks();
        }
    });

    openSceneDirBtn.setText("Open Scene Directory");
    openSceneDirBtn.setToolTipText("Open the directory where Chunky stores scene descriptions and renders");
    openSceneDirBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            try {
                if (Desktop.isDesktopSupported()) {
                    Desktop.getDesktop().open(context.getSceneDirectory());
                }
            } catch (IOException e) {
                Log.warn("Failed to open scene directory", e);
            }
        }
    });
    openSceneDirBtn.setVisible(Desktop.isDesktopSupported());

    loadSceneBtn.setToolTipText("This replaces the current scene!");
    JButton setCanvasSizeBtn = new JButton("Apply");
    setCanvasSizeBtn.setToolTipText("Set the canvas size to the value in the field");
    setCanvasSizeBtn.addActionListener(canvasSizeListener);

    JButton halveCanvasSizeBtn = new JButton("Halve");
    halveCanvasSizeBtn.setToolTipText("Halve the canvas width and height");
    halveCanvasSizeBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int width = renderMan.scene().canvasWidth() / 2;
            int height = renderMan.scene().canvasHeight() / 2;
            setCanvasSize(width, height);
        }
    });
    JButton doubleCanvasSizeBtn = new JButton("Double");
    doubleCanvasSizeBtn.setToolTipText("Double the canvas width and height");
    doubleCanvasSizeBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int width = renderMan.scene().canvasWidth() * 2;
            int height = renderMan.scene().canvasHeight() * 2;
            setCanvasSize(width, height);
        }
    });

    JButton makeDefaultBtn = new JButton("Make Default");
    makeDefaultBtn.setToolTipText("Make the current canvas size the default");
    makeDefaultBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            PersistentSettings.set3DCanvasSize(renderMan.scene().canvasWidth(),
                    renderMan.scene().canvasHeight());
        }
    });

    JSeparator sep1 = new JSeparator();
    JSeparator sep2 = new JSeparator();

    biomeColorsCB.setText("enable biome colors");
    updateBiomeColorsCB();

    saveDumpsCB.setText("save dump once every ");
    saveDumpsCB.addActionListener(saveDumpsListener);
    updateSaveDumpsCheckBox();

    String[] frequencyStrings = new String[dumpFrequencies.length];
    for (int i = 0; i < dumpFrequencies.length; ++i) {
        frequencyStrings[i] = Integer.toString(dumpFrequencies[i]);
    }
    dumpFrequencyCB.setModel(new DefaultComboBoxModel(frequencyStrings));
    dumpFrequencyCB.setEditable(true);
    dumpFrequencyCB.addActionListener(dumpFrequencyListener);
    updateDumpFrequencyField();

    saveSnapshotsCB.addActionListener(saveSnapshotListener);
    updateSaveSnapshotCheckBox();

    yCutoff.update();

    JPanel panel = new JPanel();
    GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setHorizontalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup()
                    .addGroup(layout.createSequentialGroup().addComponent(loadSceneBtn)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(openSceneDirBtn))
                    .addGroup(layout.createSequentialGroup().addComponent(loadSelectedChunksBtn)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(reloadChunksBtn))
                    .addComponent(sep1)
                    .addGroup(layout.createSequentialGroup().addComponent(canvasSizeLbl)
                            .addPreferredGap(ComponentPlacement.RELATED)
                            .addComponent(canvasSizeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(setCanvasSizeBtn)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(makeDefaultBtn))
                    .addGroup(layout.createSequentialGroup().addComponent(halveCanvasSizeBtn)
                            .addPreferredGap(ComponentPlacement.RELATED).addComponent(doubleCanvasSizeBtn))
                    .addComponent(canvasSizeAdvisory).addComponent(sep2).addComponent(biomeColorsCB)
                    .addGroup(layout.createSequentialGroup().addComponent(saveDumpsCB)
                            .addComponent(dumpFrequencyCB, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(dumpFrequencyLbl).addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(saveSnapshotsCB).addGroup(yCutoff.horizontalGroup(layout)))
            .addContainerGap());
    layout.setVerticalGroup(layout.createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup().addComponent(loadSceneBtn).addComponent(openSceneDirBtn))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout
                    .createParallelGroup().addComponent(loadSelectedChunksBtn).addComponent(reloadChunksBtn))
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(
                    sep1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(canvasSizeLbl)
                    .addComponent(canvasSizeCB, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(setCanvasSizeBtn).addComponent(makeDefaultBtn))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup().addComponent(halveCanvasSizeBtn)
                    .addComponent(doubleCanvasSizeBtn))
            .addPreferredGap(ComponentPlacement.RELATED).addComponent(canvasSizeAdvisory)
            .addPreferredGap(ComponentPlacement.UNRELATED)
            .addComponent(sep2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                    GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(ComponentPlacement.UNRELATED).addComponent(biomeColorsCB)
            .addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(saveDumpsCB)
                    .addComponent(dumpFrequencyCB).addComponent(dumpFrequencyLbl))
            .addComponent(saveSnapshotsCB).addPreferredGap(ComponentPlacement.UNRELATED)
            .addGroup(yCutoff.verticalGroup(layout)).addContainerGap());
    return panel;
}