Example usage for javax.swing Box createVerticalGlue

List of usage examples for javax.swing Box createVerticalGlue

Introduction

In this page you can find the example usage for javax.swing Box createVerticalGlue.

Prototype

public static Component createVerticalGlue() 

Source Link

Document

Creates a vertical glue component.

Usage

From source file:Installer.java

public Installer(File targetDir) {
    ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    JPanel logoSplash = new JPanel();
    logoSplash.setLayout(new BoxLayout(logoSplash, BoxLayout.Y_AXIS));
    try {/*from ww  w.j  a  v a  2s.  co  m*/
        // Read png
        BufferedImage image;
        image = ImageIO.read(Installer.class.getResourceAsStream("logo.png"));
        ImageIcon icon = new ImageIcon(image);
        JLabel logoLabel = new JLabel(icon);
        logoLabel.setAlignmentX(CENTER_ALIGNMENT);
        logoLabel.setAlignmentY(CENTER_ALIGNMENT);
        logoLabel.setSize(image.getWidth(), image.getHeight());
        if (!QUIET_DEV) // VIVE - hide oculus logo
            logoSplash.add(logoLabel);
    } catch (IOException e) {
    } catch (IllegalArgumentException e) {
    }

    userHomeDir = System.getProperty("user.home", ".");
    osType = System.getProperty("os.name").toLowerCase();
    if (osType.contains("win")) {
        isWindows = true;
        appDataDir = System.getenv("APPDATA");
    }

    version = "UNKNOWN";
    try {
        InputStream ver = Installer.class.getResourceAsStream("version");
        if (ver != null) {
            String[] tok = new BufferedReader(new InputStreamReader(ver)).readLine().split(":");
            if (tok.length > 0) {
                jar_id = tok[0];
                version = tok[1];
            }
        }
    } catch (IOException e) {
    }

    // Read release notes, save to file
    String tmpFileName = System.getProperty("java.io.tmpdir") + releaseNotePathAddition + "Vivecraft"
            + version.toLowerCase() + "_release_notes.txt";
    releaseNotes = new File(tmpFileName);
    InputStream is = Installer.class.getResourceAsStream("release_notes.txt");
    if (!copyInputStreamToFile(is, releaseNotes)) {
        releaseNotes = null;
    }

    JLabel tag = new JLabel("Welcome! This will install Vivecraft " + version);
    tag.setAlignmentX(CENTER_ALIGNMENT);
    tag.setAlignmentY(CENTER_ALIGNMENT);
    logoSplash.add(tag);

    logoSplash.add(Box.createRigidArea(new Dimension(5, 20)));
    tag = new JLabel("Select path to minecraft. (The default here is almost always what you want.)");
    tag.setAlignmentX(CENTER_ALIGNMENT);
    tag.setAlignmentY(CENTER_ALIGNMENT);
    logoSplash.add(tag);

    logoSplash.setAlignmentX(CENTER_ALIGNMENT);
    logoSplash.setAlignmentY(TOP_ALIGNMENT);
    this.add(logoSplash);

    JPanel entryPanel = new JPanel();
    entryPanel.setLayout(new BoxLayout(entryPanel, BoxLayout.X_AXIS));

    Installer.targetDir = targetDir;
    selectedDirText = new JTextField();
    selectedDirText.setEditable(false);
    selectedDirText.setToolTipText("Path to minecraft");
    selectedDirText.setColumns(30);
    entryPanel.add(selectedDirText);
    JButton dirSelect = new JButton();
    dirSelect.setAction(new FileSelectAction());
    dirSelect.setText("...");
    dirSelect.setToolTipText("Select an alternative minecraft directory");
    entryPanel.add(dirSelect);

    entryPanel.setAlignmentX(LEFT_ALIGNMENT);
    entryPanel.setAlignmentY(TOP_ALIGNMENT);
    infoLabel = new JLabel();
    infoLabel.setHorizontalTextPosition(JLabel.LEFT);
    infoLabel.setVerticalTextPosition(JLabel.TOP);
    infoLabel.setAlignmentX(LEFT_ALIGNMENT);
    infoLabel.setAlignmentY(TOP_ALIGNMENT);
    infoLabel.setVisible(false);

    fileEntryPanel = new JPanel();
    fileEntryPanel.setLayout(new BoxLayout(fileEntryPanel, BoxLayout.Y_AXIS));
    fileEntryPanel.add(infoLabel);
    fileEntryPanel.add(entryPanel);

    fileEntryPanel.setAlignmentX(CENTER_ALIGNMENT);
    fileEntryPanel.setAlignmentY(TOP_ALIGNMENT);
    this.add(fileEntryPanel);
    this.add(Box.createVerticalStrut(5));

    JPanel optPanel = new JPanel();
    optPanel.setLayout(new BoxLayout(optPanel, BoxLayout.Y_AXIS));
    optPanel.setAlignmentX(LEFT_ALIGNMENT);
    optPanel.setAlignmentY(TOP_ALIGNMENT);

    //Add forge options
    JPanel forgePanel = new JPanel();
    forgePanel.setLayout(new BoxLayout(forgePanel, BoxLayout.X_AXIS));
    //Create forge: no/yes buttons
    useForge = new JCheckBox();
    AbstractAction actf = new updateActionF();
    actf.putValue(AbstractAction.NAME, "Install Vivecraft with Forge " + FORGE_VERSION);
    useForge.setAction(actf);
    forgeVersion = new JComboBox();
    if (!ALLOW_FORGE_INSTALL)
        useForge.setEnabled(false);
    useForge.setToolTipText(
            "<html>" + "If checked, installs Vivecraft with Forge support. The correct version of Forge<br>"
                    + "(as displayed) must already be installed.<br>" + "</html>");

    //Add "yes" and "which version" to the forgePanel
    useForge.setAlignmentX(LEFT_ALIGNMENT);
    forgeVersion.setAlignmentX(LEFT_ALIGNMENT);
    forgePanel.add(useForge);
    //forgePanel.add(forgeVersion);

    // Profile creation / update support
    createProfile = new JCheckBox("", true);
    AbstractAction actp = new updateActionP();
    actp.putValue(AbstractAction.NAME, "Create Vivecraft launcher profile");
    createProfile.setAction(actp);
    createProfile.setAlignmentX(LEFT_ALIGNMENT);
    createProfile.setSelected(true);
    createProfile.setToolTipText("<html>"
            + "If checked, if a Vivecraft profile doesn't already exist within the Minecraft launcher<br>"
            + "one is added. Then the profile is selected, and this Vivecraft version is set as the<br>"
            + "current version.<br>" + "</html>");

    useShadersMod = new JCheckBox();
    useShadersMod.setAlignmentX(LEFT_ALIGNMENT);
    if (!ALLOW_SHADERSMOD_INSTALL)
        useShadersMod.setEnabled(false);
    AbstractAction acts = new updateActionSM();
    acts.putValue(AbstractAction.NAME, "Install Vivecraft with ShadersMod 2.3.29");
    useShadersMod.setAction(acts);
    useShadersMod.setToolTipText("<html>" + "If checked, sets the vivecraft profile to use ShadersMod <br>"
            + "support." + "</html>");

    useHydra = new JCheckBox("Razer Hydra support", false);
    useHydra.setAlignmentX(LEFT_ALIGNMENT);
    if (!ALLOW_HYDRA_INSTALL)
        useHydra.setEnabled(false);
    useHydra.setToolTipText("<html>"
            + "If checked, installs the additional Razor Hydra native library required for Razor Hydra<br>"
            + "support." + "</html>");

    useHrtf = new JCheckBox("Enable binaural audio (Only needed once per PC)", false);
    useHrtf.setToolTipText("<html>"
            + "If checked, the installer will create the configuration file needed for OpenAL HRTF<br>"
            + "ear-aware sound in Minecraft (and other games).<br>"
            + " If the file has previously been created, you do not need to check this again.<br>"
            + " NOTE: Your sound card's output MUST be set to 44.1Khz.<br>" + " WARNING, will overwrite "
            + (isWindows ? (appDataDir + "\\alsoft.ini") : (userHomeDir + "/.alsoftrc")) + "!<br>"
            + " Delete the " + (isWindows ? "alsoft.ini" : "alsoftrc") + " file to disable HRTF again."
            + "</html>");
    useHrtf.setAlignmentX(LEFT_ALIGNMENT);

    //Add option panels option panel
    forgePanel.setAlignmentX(LEFT_ALIGNMENT);

    //optPanel.add(forgePanel);
    //optPanel.add(useShadersMod);
    optPanel.add(createProfile);
    optPanel.add(useHrtf);
    this.add(optPanel);

    this.add(Box.createRigidArea(new Dimension(5, 20)));

    instructions = new JLabel("", SwingConstants.CENTER);
    instructions.setAlignmentX(CENTER_ALIGNMENT);
    instructions.setAlignmentY(TOP_ALIGNMENT);
    instructions.setForeground(Color.RED);
    instructions.setPreferredSize(new Dimension(20, 40));
    this.add(instructions);

    this.add(Box.createVerticalGlue());
    JLabel github = linkify("Vivecraft is open source. find it on Github",
            "https://github.com/jrbudda/Vivecraft_111", "Vivecraft 1.11 Github");
    JLabel wiki = linkify("Vivecraft home page", "http://www.vivecraft.org", "Vivecraft Home");
    JLabel donate = linkify("If you think Vivecraft is awesome, please consider donating.",
            "https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=JVBJLN5HJJS52&lc=US&item_name=jrbudda&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted)",
            "jrbudda's Paypal");
    JLabel optifine = linkify("Vivecraft includes OptiFine for performance. Consider donating to them as well.",
            "http://optifine.net/donate.php", "http://optifine.net/donate.php");

    github.setAlignmentX(CENTER_ALIGNMENT);
    github.setHorizontalAlignment(SwingConstants.CENTER);
    wiki.setAlignmentX(CENTER_ALIGNMENT);
    wiki.setHorizontalAlignment(SwingConstants.CENTER);
    donate.setAlignmentX(CENTER_ALIGNMENT);
    donate.setHorizontalAlignment(SwingConstants.CENTER);
    optifine.setAlignmentX(CENTER_ALIGNMENT);
    optifine.setHorizontalAlignment(SwingConstants.CENTER);

    this.add(Box.createRigidArea(new Dimension(5, 20)));
    this.add(github);
    this.add(wiki);
    this.add(donate);
    this.add(optifine);

    this.setAlignmentX(LEFT_ALIGNMENT);
    updateFilePath();
    updateInstructions();
}

From source file:plugins.tprovoost.Microscopy.MicroManagerForIcy.MMMainFrame.java

/**
 * Initialize all the GUI.//from w  ww .  ja  v  a 2 s .  c o m
 */
@Override
public void initializeGUI() {
    ThreadUtil.invokeNow(new Runnable() {

        @Override
        public void run() {
            _camera_label = mCore.getCameraDevice();
            if (_camera_label.length() > 0) {
                if (_combo_binning.getItemCount() > 0) {
                    _combo_binning.removeAllItems();
                }
                StrVector binSizes;
                try {
                    binSizes = mCore.getAllowedPropertyValues(_camera_label, MMCoreJ.getG_Keyword_Binning());
                } catch (Exception e1) {
                    binSizes = new StrVector();
                }
                ActionListener[] listeners = _combo_binning.getActionListeners();
                for (int i = 0; i < listeners.length; i++) {
                    _combo_binning.removeActionListener(listeners[i]);
                }
                for (int i = 0; i < binSizes.size(); i++) {
                    _combo_binning.addItem(binSizes.get(i));
                }
                _combo_binning.setMaximumRowCount((int) binSizes.size());
                if (binSizes.size() == 0L)
                    _combo_binning.setEditable(true);
                else {
                    _combo_binning.setEditable(false);
                }

                for (int i = 0; i < listeners.length; i++) {
                    _combo_binning.addActionListener(listeners[i]);
                }
                _combo_binning.setSelectedIndex(0);
            }
            try {
                _shutters = mCore.getLoadedDevicesOfType(DeviceType.ShutterDevice);
            } catch (Exception e) {
                e.printStackTrace();
            }

            if (_shutters != null) {
                String[] items = new String[(int) _shutters.size()];
                for (int i = 0; i < _shutters.size(); i++) {
                    items[i] = _shutters.get(i);
                }

                ActionListener[] listeners = _combo_shutters.getActionListeners();
                for (int i = 0; i < listeners.length; i++) {
                    _combo_shutters.removeActionListener(listeners[i]);
                }
                if (_combo_shutters.getItemCount() > 0) {
                    _combo_shutters.removeAllItems();
                }

                for (int i = 0; i < items.length; i++) {
                    _combo_shutters.addItem(items[i]);
                }

                for (int i = 0; i < listeners.length; i++)
                    _combo_shutters.addActionListener(listeners[i]);

                String activeShutter = mCore.getShutterDevice();
                if (activeShutter != null)
                    _combo_shutters.setSelectedItem(activeShutter);
                else {
                    _combo_shutters.setSelectedItem("");
                }
            }

            // ------------
            // GUI DRAW
            // -----------
            _mainPanel.removeAll();
            _panelConfig = new JPanel();
            _panelConfig.setLayout(new BoxLayout(_panelConfig, BoxLayout.Y_AXIS));
            _panelConfig.add(_groupPad, BorderLayout.CENTER);
            _panelConfig.add(_groupButtonsPanel, BorderLayout.SOUTH);
            _panelConfig.setPreferredSize(new Dimension(300, 300));

            _panelCameraSettingsContainer = new JPanel();
            _panelCameraSettingsContainer
                    .setLayout(new BoxLayout(_panelCameraSettingsContainer, BoxLayout.Y_AXIS));
            _panelCameraSettingsContainer.add(_panel_cameraSettings);
            _panelCameraSettingsContainer.add(Box.createVerticalGlue());

            _panelAcquisitions = new JPanel();
            _panelAcquisitions.setLayout(new BoxLayout(_panelAcquisitions, BoxLayout.Y_AXIS));
            _panelAcquisitions.add(new JLabel("No acquisition running."));

            JPanel panelPainterSettingsContainer = new JPanel();
            panelPainterSettingsContainer.setLayout(new GridLayout());
            panelPainterSettingsContainer.add(_panelColorChooser);

            _tabbedPanel = new JTabbedPane();
            _tabbedPanel.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
            _tabbedPanel.add("Configuration", _panelConfig);
            _tabbedPanel.add("Camera Settings", _panelCameraSettingsContainer);
            _tabbedPanel.add("Running Acquisitions", _panelAcquisitions);
            _tabbedPanel.add("Painter Settings", panelPainterSettingsContainer);

            final IcyLogo logo_title = new IcyLogo("Micro-Manager for Icy");
            logo_title.setPreferredSize(new Dimension(200, 80));
            _mainPanel.add(_tabbedPanel, BorderLayout.CENTER);
            _mainPanel.add(logo_title, BorderLayout.NORTH);
            _mainPanel.validate();
        }
    });
}