Example usage for javax.swing SwingConstants TOP

List of usage examples for javax.swing SwingConstants TOP

Introduction

In this page you can find the example usage for javax.swing SwingConstants TOP.

Prototype

int TOP

To view the source code for javax.swing SwingConstants TOP.

Click Source Link

Document

Box-orientation constant used to specify the top of a box.

Usage

From source file:org.interreg.docexplore.DocExploreTool.java

@SuppressWarnings("serial")
protected static File askForHome(String text) {
    final File[] file = { null };
    final JDialog dialog = new JDialog((Frame) null, XMLResourceBundle.getBundledString("homeLabel"), true);
    JPanel content = new JPanel(new LooseGridLayout(0, 1, 10, 10, true, false, SwingConstants.CENTER,
            SwingConstants.TOP, true, false));
    content.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
    JLabel message = new JLabel(text, ImageUtils.getIcon("free-64x64.png"), SwingConstants.LEFT);
    message.setIconTextGap(20);//from ww w. j  a va  2s . co  m
    //message.setFont(Font.decode(Font.SANS_SERIF));
    content.add(message);

    final JPanel pathPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
    pathPanel.add(new JLabel("<html><b>" + XMLResourceBundle.getBundledString("homeLabel") + ":</b></html>"));
    final JTextField pathField = new JTextField(System.getProperty("user.home") + File.separator + "DocExplore",
            40);
    pathPanel.add(pathField);
    pathPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("browseLabel")) {
        JNativeFileDialog nfd = null;

        public void actionPerformed(ActionEvent arg0) {
            if (nfd == null) {
                nfd = new JNativeFileDialog();
                nfd.acceptFiles = false;
                nfd.acceptFolders = true;
                nfd.multipleSelection = false;
                nfd.title = XMLResourceBundle.getBundledString("homeLabel");
            }
            nfd.setCurrentFile(new File(pathField.getText()));
            if (nfd.showOpenDialog())
                pathField.setText(nfd.getSelectedFile().getAbsolutePath());
        }
    }));
    content.add(pathPanel);

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 10));
    buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgOkLabel")) {
        public void actionPerformed(ActionEvent e) {
            File res = new File(pathField.getText());
            if (res.exists() && !res.isDirectory() || !res.exists() && !res.mkdirs())
                JOptionPane.showMessageDialog(dialog, XMLResourceBundle.getBundledString("homeErrorMessage"),
                        XMLResourceBundle.getBundledString("errorLabel"), JOptionPane.ERROR_MESSAGE);
            else {
                file[0] = res;
                dialog.setVisible(false);
            }
        }
    }));
    buttonPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgCancelLabel")) {
        public void actionPerformed(ActionEvent e) {
            dialog.setVisible(false);
        }
    }));
    content.add(buttonPanel);

    dialog.getContentPane().add(content);
    dialog.pack();
    dialog.setResizable(false);
    GuiUtils.centerOnScreen(dialog);
    dialog.setVisible(true);
    return file[0];
}

From source file:org.interreg.docexplore.GeneralConfigPanel.java

public GeneralConfigPanel(final File config) throws Exception {
    this.configFile = config;

    final String xml = config.exists() ? StringUtils.readFile(config) : "<config></config>";
    setLayout(new LooseGridLayout(0, 1, 5, 5, true, true, SwingConstants.LEFT, SwingConstants.TOP));

    //      JPanel ac = new JPanel(new LooseGridLayout(0, 1, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    //      ac.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgACLabel")));
    //      ac.add(useAutoConnect = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseACLabel")));
    //      JPanel typePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    //      typePanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTypeLabel")));
    //      typePanel.add(autoConnectType = new JComboBox(new Object [] {XMLResourceBundle.getBundledString("cfgFileLabel"), XMLResourceBundle.getBundledString("cfgMysqlLabel")}));
    //      ac.add(typePanel);
    //      ac.add(autoConnectSubPanel = new JPanel(new BorderLayout()));
    //      //from   www.j  av a  2  s .  c o  m
    //      fsSubPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    //      fsSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPathLabel"))); fsSubPanel.add(acFSPath = new JTextField(40));
    //      
    //      dbSubPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPathLabel"))); dbSubPanel.add(acDBPath = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgHostLabel"))); dbSubPanel.add(acDBHost = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgDBLabel"))); dbSubPanel.add(acDBDatabase = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgUserLabel"))); dbSubPanel.add(acDBUser = new JTextField(40));
    //      dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPasswordLabel"))); dbSubPanel.add(acDBPassword = new JTextField(40));
    //      
    //      Set<ConnectionHandler.PastConnection> cons = new ConnectionHandler().connections;
    //      if (cons != null)
    //      {
    //         Vector<Object> recentCons = new Vector<Object>();
    //         for (ConnectionHandler.PastConnection con : cons)
    //            if (con.source instanceof DataLinkMySQLSource || con.source instanceof DataLinkFS2Source)
    //               recentCons.add(con);
    //         
    //         if (!recentCons.isEmpty())
    //         {
    //            recentCons.insertElementAt(XMLResourceBundle.getBundledString("cfgCurrentLabel"), 0);
    //            JPanel recentPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    //            recentPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgRecentLabel")));
    //            JComboBox recentBox = new JComboBox(recentCons);
    //            recentPanel.add(recentBox);
    //            ac.add(recentPanel);
    //            
    //            recentBox.addItemListener(new ItemListener() {public void itemStateChanged(ItemEvent e)
    //            {
    //               if (e.getStateChange() != ItemEvent.SELECTED)
    //                  return;
    //               if (e.getItem().equals(XMLResourceBundle.getBundledString("cfgCurrentLabel")))
    //                  fillAutoConnect(xml);
    //               else fillAutoConnect((ConnectionHandler.PastConnection)e.getItem());
    //            }});
    //         }
    //      }

    JPanel display = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    display.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgDisplayLabel")));
    JPanel displayDims = new JPanel(
            new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP));
    displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgWidthLabel")));
    displayDims.add(displayWidth = new JTextField(5));
    displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgHeightLabel")));
    displayDims.add(displayHeight = new JTextField(5));
    displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgLanguageLabel")));
    displayDims.add(
            displayLang = new JComboBox(new Object[] { XMLResourceBundle.getBundledString("cfgEnglishLabel"),
                    XMLResourceBundle.getBundledString("cfgFrenchLabel") }));
    display.add(displayHelp = new JCheckBox(XMLResourceBundle.getBundledString("cfgHelpLabel")));
    display.add(displayFullscreen = new JCheckBox(XMLResourceBundle.getBundledString("cfgFullscreenLabel")));
    display.add(displayNativeCursor = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseCursorLabel")));
    display.add(displayDims);

    JPanel topPluginsPanel = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, true, true, SwingConstants.LEFT, SwingConstants.TOP));
    topPluginsPanel
            .setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgPluginsLabel")));
    pluginsPanel = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false));
    JScrollPane scrollPane = new JScrollPane(pluginsPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(500, 300));
    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    topPluginsPanel.add(scrollPane);

    JPanel addPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    addPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgAddPluginLabel")) {
        public void actionPerformed(ActionEvent e) {
            try {
                JOptionPane.showMessageDialog(GeneralConfigPanel.this,
                        XMLResourceBundle.getBundledString("cfgAddPluginMessage").replace("%pdir",
                                DocExploreTool.getPluginDir().getAbsolutePath()));
                if (System.getProperty("os.name").toLowerCase().contains("win"))
                    Runtime.getRuntime()
                            .exec(new String[] { "explorer", DocExploreTool.getPluginDir().getAbsolutePath() });
                else if (System.getProperty("os.name").toLowerCase().contains("mac"))
                    Runtime.getRuntime()
                            .exec(new String[] { "open", DocExploreTool.getPluginDir().getAbsolutePath() });
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
            //         File jarFile = browsePlugins();
            //         if (jarFile == null)
            //            return;
            //         PluginPanel pluginPanel = new PluginPanel(GeneralConfigPanel.this, "yes", jarFile.getName(), "");
            //         pluginPanels.add(pluginPanel);
            //         pluginsPanel.add(pluginPanel);
            //         ((Window)getTopLevelAncestor()).pack();
        }
    }));
    addPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgRefreshPluginsLabel")) {
        public void actionPerformed(ActionEvent e) {
            refreshPlugins(xml);
            ((Window) getTopLevelAncestor()).pack();
        }
    }));
    topPluginsPanel.add(addPanel);

    //      setAutoConnectSubPanel(fsSubPanel);

    //      add(ac);
    add(display);
    add(topPluginsPanel);

    add(safeMode = new JCheckBox(XMLResourceBundle.getBundledString("cfgSafeModeLabel")));

    //      autoConnectType.addItemListener(new ItemListener() {public void itemStateChanged(ItemEvent e)
    //      {
    //         if (e.getStateChange() != ItemEvent.SELECTED)
    //            return;
    //         if (e.getItem().equals(XMLResourceBundle.getBundledString("cfgFileLabel")))
    //            setAutoConnectSubPanel(fsSubPanel);
    //         else setAutoConnectSubPanel(dbSubPanel);
    //         Window top = (Window)getTopLevelAncestor();
    //         if (top != null)
    //            top.pack();
    //      }});

    if (xml != null)
        fill(xml);
}

From source file:org.interreg.docexplore.ServerConfigPanel.java

public ServerConfigPanel(final File config, final File serverDir) throws Exception {
    super(new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false));

    this.serverDir = serverDir;
    this.books = new Vector<Book>();
    this.bookList = new JList(new DefaultListModel());

    JPanel listPanel = new JPanel(new BorderLayout());
    listPanel.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgBooksLabel")));
    bookList.setOpaque(false);/*  w w  w  . j a v  a2 s  . c o m*/
    bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    bookList.setCellRenderer(new ListCellRenderer() {
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            Book book = (Book) value;
            JLabel label = new JLabel("<html><b>" + book.name + "</b> - " + book.nPages + " pages</html>");
            label.setOpaque(true);
            if (isSelected) {
                label.setBackground(TextToolbar.styleHighLightedBackground);
                label.setForeground(Color.white);
            }
            if (book.deleted)
                label.setForeground(Color.red);
            else if (!book.used)
                label.setForeground(Color.gray);
            return label;
        }
    });
    bookList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting())
                return;
            setFields((Book) bookList.getSelectedValue());
        }
    });
    JScrollPane scrollPane = new JScrollPane(bookList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(500, 300));
    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    listPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel importPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    importPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgImportLabel")) {
        public void actionPerformed(ActionEvent e) {
            final File inFile = DocExploreTool.getFileDialogs().openFile(DocExploreTool.getIBookCategory());
            if (inFile == null)
                return;

            try {
                final File tmpDir = new File(serverDir, "tmp");
                tmpDir.mkdir();

                GuiUtils.blockUntilComplete(new ProgressRunnable() {
                    float[] progress = { 0 };

                    public void run() {
                        try {
                            ZipUtils.unzip(inFile, tmpDir, progress);
                        } catch (Exception ex) {
                            ErrorHandler.defaultHandler.submit(ex);
                        }
                    }

                    public float getProgress() {
                        return (float) progress[0];
                    }
                }, ServerConfigPanel.this);

                File tmpFile = new File(tmpDir, "index.tmp");
                ObjectInputStream input = new ObjectInputStream(new FileInputStream(tmpFile));
                String bookFile = input.readUTF();
                String bookName = input.readUTF();
                String bookDesc = input.readUTF();
                input.close();

                new PresentationImporter().doImport(ServerConfigPanel.this, bookName, bookDesc,
                        new File(tmpDir, bookFile));
                FileUtils.cleanDirectory(tmpDir);
                FileUtils.deleteDirectory(tmpDir);
                updateBooks();
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
        }
    }));
    listPanel.add(importPanel, BorderLayout.SOUTH);
    add(listPanel);

    JPanel setupPanel = new JPanel(
            new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false));
    setupPanel.setBorder(
            BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgBookInfoLabel")));
    usedBox = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseLabel"));
    usedBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book != null) {
                book.used = usedBox.isSelected();
                bookList.repaint();
            }
        }
    });
    setupPanel.add(usedBox);

    JPanel fieldPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, false, SwingConstants.LEFT,
            SwingConstants.TOP, true, false));
    fieldPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTitleLabel")));
    nameField = new JTextField(50);
    nameField.getDocument().addDocumentListener(new DocumentListener() {
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void changedUpdate(DocumentEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book == null)
                return;
            book.name = nameField.getText();
            bookList.repaint();
        }
    });
    fieldPanel.add(nameField);

    fieldPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgDescriptionLabel")));
    descField = new JTextPane();
    //descField.setWrapStyleWord(true);
    descField.getDocument().addDocumentListener(new DocumentListener() {
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        public void changedUpdate(DocumentEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book == null)
                return;
            book.desc = descField.getText();
        }
    });
    scrollPane = new JScrollPane(descField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setPreferredSize(new Dimension(420, 50));
    scrollPane.getVerticalScrollBar().setUnitIncrement(10);
    fieldPanel.add(scrollPane);

    setupPanel.add(fieldPanel);

    exportButton = new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgExportLabel")) {
        public void actionPerformed(ActionEvent e) {
            File file = DocExploreTool.getFileDialogs().saveFile(DocExploreTool.getIBookCategory());
            if (file == null)
                return;
            final Book book = (Book) bookList.getSelectedValue();
            final File indexFile = new File(serverDir, "index.tmp");
            try {
                final File outFile = file;
                ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(indexFile));
                out.writeUTF(book.bookFile.getName());
                out.writeUTF(book.name);
                out.writeUTF(book.desc);
                out.close();

                GuiUtils.blockUntilComplete(new ProgressRunnable() {
                    float[] progress = { 0 };

                    public void run() {
                        try {
                            ZipUtils.zip(serverDir, new File[] { indexFile, book.bookFile, book.bookDir },
                                    outFile, progress, 0, 1, 9);
                        } catch (Exception ex) {
                            ErrorHandler.defaultHandler.submit(ex);
                        }
                    }

                    public float getProgress() {
                        return (float) progress[0];
                    }
                }, ServerConfigPanel.this);
            } catch (Exception ex) {
                ErrorHandler.defaultHandler.submit(ex);
            }
            if (indexFile.exists())
                indexFile.delete();
        }
    });
    deleteButton = new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgDeleteRestoreLabel")) {
        public void actionPerformed(ActionEvent e) {
            Book book = (Book) bookList.getSelectedValue();
            if (book == null)
                return;
            book.deleted = !book.deleted;
            bookList.repaint();
        }
    });

    JPanel actionsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    actionsPanel.add(exportButton);
    actionsPanel.add(deleteButton);
    setupPanel.add(actionsPanel);

    add(setupPanel);

    JPanel optionsPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, false, SwingConstants.LEFT,
            SwingConstants.TOP, true, false));
    optionsPanel
            .setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgOptionsLabel")));
    JPanel timeoutPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    timeoutField = new JTextField(5);
    timeoutPanel.add(timeoutField);
    timeoutPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTimeoutLabel")));
    optionsPanel.add(timeoutPanel);
    add(optionsPanel);

    updateBooks();
    setFields(null);

    final String xml = config.exists() ? StringUtils.readFile(config) : "<config></config>";
    String idle = StringUtils.getTagContent(xml, "idle");
    if (idle != null)
        try {
            timeoutField.setText("" + Integer.parseInt(idle));
        } catch (Throwable e) {
        }
}

From source file:org.isatools.gui.datamanager.studyaccess.StudyAccessionGUI.java

private JPanel createStudySelectionPanel() {

    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));
    container.setOpaque(false);/* w  ww. j  a  v a  2 s  . c o  m*/

    JPanel studyAccessionSelector = new JPanel();
    studyAccessionSelector.setLayout(new BorderLayout());
    studyAccessionSelector.setOpaque(false);

    JLabel information = new JLabel(unloadStudyHeader);
    information.setHorizontalAlignment(SwingConstants.RIGHT);
    information.setVerticalAlignment(SwingConstants.TOP);

    studyAccessionSelector.add(information, BorderLayout.NORTH);

    retrieveAndProcessStudyInformation();

    JScrollPane treeScroller = new JScrollPane(studyAvailabilityTree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    treeScroller.getViewport().setOpaque(false);
    treeScroller.setOpaque(false);
    treeScroller.setBorder(new EmptyBorder(1, 1, 1, 1));

    treeScroller.setPreferredSize(new Dimension(380, 210));

    studyAccessionSelector.add(treeScroller);

    container.add(studyAccessionSelector);

    // and need a convert button!
    JPanel buttonCont = new JPanel(new BorderLayout());
    buttonCont.setOpaque(false);

    final JLabel unload = new JLabel(this.unloadButton, JLabel.RIGHT);

    unload.addMouseListener(new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            unload.setIcon(unloadButtonOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            unload.setIcon(StudyAccessionGUI.this.unloadButton);
        }

        public void mousePressed(MouseEvent mouseEvent) {
            Set<String> studiesToUnload = studyAvailabilityTree
                    .getCheckedStudies(studyAvailabilityTree.getRoot());
            log.info("going to unload: ");
            for (String acc : studiesToUnload) {
                log.info("study with acc " + acc);
            }
            doUnloading(studiesToUnload);
        }

    });
    buttonCont.add(unload, BorderLayout.EAST);

    buttonCont.add(createBackToMainMenuButton(), BorderLayout.WEST);

    container.add(buttonCont);

    return container;
}

From source file:org.isatools.isacreator.gui.DataEntryForm.java

protected JPanel createTextEditEnabledField(JTextComponent component) {
    JPanel container = new JPanel();
    container.setLayout(new BorderLayout());

    container.add(component, BorderLayout.CENTER);

    TextEditUtility textEdit = new TextEditUtility(component);
    textEdit.setVerticalAlignment(SwingConstants.TOP);

    JPanel textEditPanel = new JPanel();
    UIHelper.setLayoutForEditingIcons(textEditPanel, textEdit);

    textEditPanel.setSize(new Dimension(23, 23));

    container.add(textEditPanel, BorderLayout.EAST);

    return container;
}

From source file:org.isatools.isacreatorconfigurator.configui.DataEntryPanel.java

private void createMainSector() {

    JPanel topContainer = new JPanel();
    topContainer.setLayout(new BoxLayout(topContainer, BoxLayout.PAGE_AXIS));
    topContainer.setBackground(UIHelper.BG_COLOR);

    // add logo to the top
    topContainer.add(createMenu());//from   w w w.j a v  a2  s  . c o  m

    JPanel headerImagePanel = new JPanel(new GridLayout(1, 2));
    headerImagePanel.setOpaque(false);

    JLabel logo = new JLabel("");
    logo.setOpaque(false);

    headerImagePanel.add(logo);

    tableInformationDisplay = UIHelper.createLabel("", UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR,
            SwingConstants.RIGHT);
    tableInformationDisplay.setVerticalAlignment(SwingConstants.TOP);
    tableInformationDisplay.setHorizontalAlignment(SwingConstants.RIGHT);

    headerImagePanel.add(UIHelper.wrapComponentInPanel(tableInformationDisplay));

    topContainer.add(headerImagePanel);
    topContainer.add(Box.createVerticalStrut(10));

    add(topContainer, BorderLayout.NORTH);

    // create central console with majority of content!
    createNavigationPanel();

    JPanel bottomContainer = new JPanel();
    bottomContainer.setLayout(new BoxLayout(bottomContainer, BoxLayout.PAGE_AXIS));
    bottomContainer.setBackground(UIHelper.BG_COLOR);

    add(bottomContainer, BorderLayout.SOUTH);

}

From source file:org.isatools.isacreatorconfigurator.configui.FieldInterface.java

private void instantiateFields(String initFieldName) {
    // OVERALL CONTAINER
    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));
    container.setBackground(UIHelper.BG_COLOR);

    JLabel fieldDefinitionLab = new JLabel(fieldDefinitionHeader, JLabel.CENTER);
    container.add(fieldDefinitionLab);//from  ww  w . j  a  v  a  2s . c o m

    container.add(Box.createVerticalStrut(5));

    // FIELD LABEL & INPUT BOX CONTAINER
    JPanel fieldCont = new JPanel(new GridLayout(1, 2));
    fieldCont.setBackground(UIHelper.BG_COLOR);

    fieldName = new RoundedJTextField(15);
    fieldName.setText(initFieldName);
    fieldName.setEditable(false);
    UIHelper.renderComponent(fieldName, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JLabel fieldNameLab = UIHelper.createLabel("Field Name: ", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    fieldCont.add(fieldNameLab);
    fieldCont.add(fieldName);
    container.add(fieldCont);

    JPanel descCont = new JPanel(new GridLayout(1, 2));
    descCont.setBackground(UIHelper.BG_COLOR);
    description = new RoundedJTextArea();
    description.setLineWrap(true);
    description.setWrapStyleWord(true);
    UIHelper.renderComponent(description, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane descScroll = new JScrollPane(description, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    descScroll.setBackground(UIHelper.BG_COLOR);
    descScroll.setPreferredSize(new Dimension(150, 65));
    descScroll.getViewport().setBackground(UIHelper.BG_COLOR);

    IAppWidgetFactory.makeIAppScrollPane(descScroll);

    JLabel descLab = UIHelper.createLabel("Description: ", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    descLab.setVerticalAlignment(JLabel.TOP);
    descCont.add(descLab);
    descCont.add(descScroll);
    container.add(descCont);

    // add datatype information
    JPanel datatypeCont = new JPanel(new GridLayout(1, 2));
    datatypeCont.setBackground(UIHelper.BG_COLOR);

    DataTypes[] allowedDataTypes = initFieldName.equals(UNIT_STR) ? new DataTypes[] { DataTypes.ONTOLOGY_TERM }
            : DataTypes.values();

    datatype = new JComboBox(allowedDataTypes);
    datatype.addActionListener(this);
    UIHelper.renderComponent(datatype, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR);

    JLabel dataTypeLab = UIHelper.createLabel("Datatype:", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    datatypeCont.add(dataTypeLab);
    datatypeCont.add(datatype);
    container.add(datatypeCont);

    defaultValContStd = new JPanel(new GridLayout(1, 2));
    defaultValContStd.setBackground(UIHelper.BG_COLOR);

    defaultValCont = Box.createHorizontalBox();
    defaultValCont.setPreferredSize(new Dimension(150, 25));

    defaultValStd = new RoundedFormattedTextField(null, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR,
            UIHelper.DARK_GREEN_COLOR);
    defaultValCont.setPreferredSize(new Dimension(120, 25));
    defaultValStd.setFormatterFactory(new DefaultFormatterFactory(
            new RegExFormatter(".*", defaultValStd, false, UIHelper.DARK_GREEN_COLOR, UIHelper.RED_COLOR,
                    UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR)));
    defaultValStd.setForeground(UIHelper.DARK_GREEN_COLOR);
    defaultValStd.setFont(UIHelper.VER_11_PLAIN);

    defaultValCont.add(defaultValStd);

    defaultValLabStd = UIHelper.createLabel(DEFAULT_VAL_STR, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);

    defaultValContStd.add(defaultValLabStd);
    defaultValContStd.add(defaultValCont);
    container.add(defaultValContStd);

    defaultValContBool = new JPanel(new GridLayout(1, 2));
    defaultValContBool.setBackground(UIHelper.BG_COLOR);
    defaultValContBool.setVisible(false);

    listDataSourceCont = new JPanel(new GridLayout(2, 1));
    listDataSourceCont.setBackground(UIHelper.BG_COLOR);
    listDataSourceCont.setVisible(false);

    JLabel listValLab = UIHelper.createLabel("Please enter comma separated list of values:",
            UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR);
    listDataSourceCont.add(listValLab);

    listValues = new RoundedJTextArea("SampleVal1, SampleVal2, SampleVal3", 3, 5);
    listValues.setLineWrap(true);
    listValues.setWrapStyleWord(true);
    UIHelper.renderComponent(listValues, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane listScroll = new JScrollPane(listValues, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    listScroll.setBackground(UIHelper.BG_COLOR);
    listScroll.getViewport().setBackground(UIHelper.BG_COLOR);

    listDataSourceCont.add(listScroll);
    container.add(listDataSourceCont);

    IAppWidgetFactory.makeIAppScrollPane(listScroll);

    sourceEntryPanel = new JPanel(new BorderLayout());
    sourceEntryPanel.setSize(new Dimension(125, 190));
    sourceEntryPanel.setOpaque(false);
    sourceEntryPanel.setVisible(false);

    preferredOntologySource = new JPanel();
    preferredOntologySource.setLayout(new BoxLayout(preferredOntologySource, BoxLayout.PAGE_AXIS));
    preferredOntologySource.setVisible(false);
    recommendOntologySource = new JCheckBox("Use recommended ontology source?", false);

    UIHelper.renderComponent(recommendOntologySource, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    recommendOntologySource.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (recommendOntologySource.isSelected()) {
                sourceEntryPanel.setVisible(true);
            } else {
                sourceEntryPanel.setVisible(false);
            }
        }
    });

    JPanel useOntologySourceCont = new JPanel(new GridLayout(1, 1));
    useOntologySourceCont.add(recommendOntologySource);

    preferredOntologySource.add(useOntologySourceCont);

    JPanel infoCont = new JPanel(new GridLayout(1, 1));
    JLabel infoLab = UIHelper.createLabel(
            "<html>click on the <strong>configure ontologies</strong> button to open the ontology configurator to edit the list of ontologies and search areas within an ontology</html>",
            UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR);
    infoLab.setPreferredSize(new Dimension(100, 40));
    infoCont.add(infoLab);

    sourceEntryPanel.add(infoCont, BorderLayout.NORTH);

    JLabel preferredOntologiesLab = new JLabel(preferredOntologiesSidePanelIcon);
    preferredOntologiesLab.setVerticalAlignment(SwingConstants.TOP);

    sourceEntryPanel.add(preferredOntologiesLab, BorderLayout.WEST);

    ontologiesToUseModel = new DefaultTableModel(new String[0][2], ontologyColumnHeaders) {
        @Override
        public boolean isCellEditable(int i, int i1) {
            return false;
        }
    };
    ontologiesToUse = new JTable(ontologiesToUseModel);
    ontologiesToUse.getTableHeader().setBackground(UIHelper.BG_COLOR);

    try {
        ontologiesToUse.setDefaultRenderer(Class.forName("java.lang.Object"),
                new CustomSpreadsheetCellRenderer());
    } catch (ClassNotFoundException e) {
        // empty
    }

    renderTableHeader();

    JScrollPane ontologiesToUseScroller = new JScrollPane(ontologiesToUse,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    ontologiesToUseScroller.setBorder(new EmptyBorder(0, 0, 0, 0));
    ontologiesToUseScroller.setPreferredSize(new Dimension(100, 80));
    ontologiesToUseScroller.setBackground(UIHelper.BG_COLOR);
    ontologiesToUseScroller.getViewport().setBackground(UIHelper.BG_COLOR);

    IAppWidgetFactory.makeIAppScrollPane(ontologiesToUseScroller);

    sourceEntryPanel.add(ontologiesToUseScroller);

    JPanel buttonCont = new JPanel(new BorderLayout());
    final JLabel openConfigButton = new JLabel(ontologyConfigIcon);
    openConfigButton.setVerticalAlignment(SwingConstants.TOP);
    openConfigButton.setHorizontalAlignment(SwingConstants.RIGHT);

    MouseAdapter showOntologyConfigurator = new MouseAdapter() {

        public void mouseEntered(MouseEvent mouseEvent) {
            openConfigButton.setIcon(ontologyConfigIconOver);
        }

        public void mouseExited(MouseEvent mouseEvent) {
            openConfigButton.setIcon(ontologyConfigIcon);
        }

        public void mousePressed(MouseEvent mouseEvent) {

            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    if (openConfigButton.isEnabled()) {
                        openConfigButton.setIcon(ontologyConfigIcon);
                        ontologyConfig = new OntologyConfigUI(ontologiesToQuery, selectedOntologies);
                        ontologyConfig.addPropertyChangeListener("ontologySelected",
                                new PropertyChangeListener() {
                                    public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
                                        selectedOntologies = (ListOrderedMap<String, RecommendedOntology>) propertyChangeEvent
                                                .getNewValue();
                                        updateTable();
                                    }
                                });
                        showPopupInCenter(ontologyConfig);
                    }
                }
            });
        }

    };

    openConfigButton.addMouseListener(showOntologyConfigurator);

    buttonCont.add(openConfigButton, BorderLayout.EAST);

    sourceEntryPanel.add(buttonCont, BorderLayout.SOUTH);
    preferredOntologySource.add(sourceEntryPanel);
    container.add(preferredOntologySource);

    String[] contents = new String[] { "true", "false" };
    defaultValBool = new

    JComboBox(contents);

    UIHelper.renderComponent(defaultValBool, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR,
            UIHelper.BG_COLOR);

    JLabel defaultValLabBool = UIHelper.createLabel(DEFAULT_VAL_STR, UIHelper.VER_12_BOLD,
            UIHelper.DARK_GREEN_COLOR);

    defaultValContBool.add(defaultValLabBool);
    defaultValContBool.add(defaultValBool);
    container.add(defaultValContBool);

    // RegExp data entry
    isInputFormatted = new JCheckBox("Is the input formatted?", false);
    isInputFormatted.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    isInputFormatted.setHorizontalAlignment(SwingConstants.LEFT);

    UIHelper.renderComponent(isInputFormatted, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    isInputFormatted.addActionListener(this);
    container.add(UIHelper.wrapComponentInPanel(isInputFormatted));

    inputFormatCont = new JPanel();

    inputFormatCont.setLayout(new BoxLayout(inputFormatCont, BoxLayout.LINE_AXIS));
    inputFormatCont.setVisible(false);
    inputFormatCont.setBackground(UIHelper.BG_COLOR);
    inputFormat = new RoundedJTextField(10);
    inputFormat.setText(".*");
    inputFormat.setSize(new Dimension(150, 19));

    inputFormat.setPreferredSize(new Dimension(160, 25));
    inputFormat.setToolTipText("Field expects a regular expression describing the input format.");
    UIHelper.renderComponent(inputFormat, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JLabel inputFormatLab = UIHelper.createLabel("Input format:", UIHelper.VER_11_BOLD,
            UIHelper.DARK_GREEN_COLOR);
    inputFormatLab.setVerticalAlignment(SwingConstants.TOP);

    inputFormatCont.add(inputFormatLab);
    inputFormatCont.add(inputFormat);
    JLabel checkRegExp = new JLabel(checkRegExIcon, JLabel.RIGHT);
    checkRegExp.setOpaque(false);
    checkRegExp.addMouseListener(new MouseAdapter() {

        public void mousePressed(MouseEvent event) {
            String regexToCheck = inputFormat.getText();

            final CheckRegExGUI regexChecker = new CheckRegExGUI(regexToCheck);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    regexChecker.createGUI();
                }
            });
            regexChecker.addPropertyChangeListener("close", new PropertyChangeListener() {
                public void propertyChange(PropertyChangeEvent evt) {
                    main.getApplicationContainer().hideSheet();
                }
            });
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    main.getApplicationContainer().showJDialogAsSheet(regexChecker);
                }
            });
        }

    }

    );
    inputFormatCont.add(checkRegExp);
    container.add(inputFormatCont);

    usesTemplateForWizard = new JCheckBox("Requires template for wizard?", false);
    usesTemplateForWizard.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    usesTemplateForWizard.setHorizontalAlignment(SwingConstants.LEFT);

    UIHelper.renderComponent(usesTemplateForWizard, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    usesTemplateForWizard.addActionListener(this);
    container.add(UIHelper.wrapComponentInPanel(usesTemplateForWizard));

    wizardTemplatePanel = new JPanel(new GridLayout(1, 2));
    wizardTemplatePanel.setVisible(false);
    wizardTemplatePanel.setBackground(UIHelper.BG_COLOR);

    wizardTemplate = new RoundedJTextArea();
    wizardTemplate.setToolTipText("A template for the wizard to auto-create the data...");
    wizardTemplate.setLineWrap(true);
    wizardTemplate.setWrapStyleWord(true);
    UIHelper.renderComponent(wizardTemplate, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false);

    JScrollPane wizScroll = new JScrollPane(wizardTemplate, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    wizScroll.getViewport().setBackground(UIHelper.BG_COLOR);
    wizScroll.setPreferredSize(new Dimension(70, 60));

    IAppWidgetFactory.makeIAppScrollPane(wizScroll);

    JLabel wizardTemplateLab = UIHelper.createLabel("Template definition:", UIHelper.VER_11_BOLD,
            UIHelper.DARK_GREEN_COLOR);
    wizardTemplateLab.setVerticalAlignment(JLabel.TOP);

    wizardTemplatePanel.add(wizardTemplateLab);
    wizardTemplatePanel.add(wizScroll);

    container.add(wizardTemplatePanel);

    JPanel checkCont = new JPanel(new GridLayout(3, 2));
    checkCont.setBackground(UIHelper.BG_COLOR);
    checkCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 4),
            "Behavioural Attributes", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION,
            UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR));

    required = new JCheckBox("Required ", true);

    UIHelper.renderComponent(required, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(required);

    acceptsMultipleValues = new JCheckBox("Allow multiple instances", false);

    UIHelper.renderComponent(acceptsMultipleValues, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(acceptsMultipleValues);
    acceptsFileLocations = new JCheckBox("Accepts file locations", false);

    acceptsFileLocations.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            acceptsMultipleValues.setSelected(false);
            acceptsMultipleValues.setEnabled(!acceptsFileLocations.isSelected());
        }
    });

    UIHelper.renderComponent(acceptsFileLocations, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(acceptsFileLocations);

    hidden = new JCheckBox("hidden?", false);

    UIHelper.renderComponent(hidden, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);
    checkCont.add(hidden);

    forceOntologySelection = new JCheckBox("Force ontology selection", false);
    UIHelper.renderComponent(forceOntologySelection, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false);

    checkCont.add(forceOntologySelection);

    container.add(checkCont);

    JScrollPane contScroll = new JScrollPane(container, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    contScroll.setBorder(null);
    contScroll.setAutoscrolls(true);

    IAppWidgetFactory.makeIAppScrollPane(contScroll);

    add(contScroll, BorderLayout.NORTH);
}

From source file:org.jcurl.demo.tactics.JCurlShotPlanner.java

@Override
protected void startup() {
    // set the window icon:
    {//from   w w w  .j a  va 2s.c  o  m
        final Image img;
        if (true)
            img = getContext().getResourceMap().getImageIcon("Application.icon").getImage();
        else {
            final ResourceMap r = getContext().getResourceMap();
            if (true)
                try {
                    img = ImageIO.read(this.getClass()
                            .getResource("/" + r.getResourcesDir() + "/" + r.getString("Application.icon")));
                } catch (final IOException e) {
                    throw new RuntimeException("Unhandled", e);
                }
            else
                img = Toolkit.getDefaultToolkit().createImage(this.getClass()
                        .getResource("/" + r.getResourcesDir() + "/" + r.getString("Application.icon")));
        }
        getMainFrame().setIconImage(img);
        // SystemTray tray = SystemTray.getSystemTray();
    }

    // File Filter
    jcxzPat = gui.createFileFilter("fileFilterJcxz", "jcz", "jcx");
    pngPat = gui.createFileFilter("fileFilterPng", "png");
    svgPat = gui.createFileFilter("fileFilterSvg", "svgz", "svg");

    getMainFrame().setJMenuBar(createMenuBar());

    final JComponent c = new JPanel();
    c.setLayout(new BorderLayout());
    tactics.setPreferredSize(new Dimension(400, 600));
    c.add(tactics, BorderLayout.CENTER);
    c.add(url, BorderLayout.NORTH);
    {
        final JPanel b = new JPanel();
        b.setLayout(new BorderLayout());
        final JTabbedPane t = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT);
        t.add("Rock", broomSwing);
        t.setMnemonicAt(0, 'R');
        t.add("Ice", curlerSwing);
        t.setMnemonicAt(1, 'I');
        t.add("Collission", new JLabel("TODO: Collission settings"));
        t.setMnemonicAt(2, 'C');
        b.add(t, BorderLayout.NORTH);
        if (false)
            b.add(new JLabel("TODO: Bird's eye view"), BorderLayout.CENTER);
        else
            b.add(birdPiccolo, BorderLayout.CENTER);
        c.add(b, BorderLayout.EAST);
    }

    show(c);
    view12Foot();
}

From source file:org.nuxeo.launcher.gui.NuxeoFrame.java

protected JTabbedPane buildLogsTab() {
    JTabbedPane logsTabbedPane = new JTabbedPane(SwingConstants.TOP);
    // Get Launcher log file(s)
    ArrayList<String> logFiles = Log4JHelper.getFileAppendersFiles(LogManager.getLoggerRepository());
    // Add nuxeoctl log file
    File nuxeoctlLog = new File(controller.getConfigurationGenerator().getLogDir(), "nuxeoctl.log");
    if (nuxeoctlLog.exists()) {
        logFiles.add(nuxeoctlLog.getAbsolutePath());
    }//from ww w  .j a  v a2 s.  c  o  m
    // Get server log file(s)
    logFiles.addAll(controller.getConfigurationGenerator().getLogFiles());
    for (String logFile : logFiles) {
        addFileToLogsTab(logsTabbedPane, logFile);
    }
    return logsTabbedPane;
}

From source file:org.nuxeo.launcher.gui.NuxeoFrame.java

protected JComponent buildTabbedPanel() {
    tabbedPanel = new JTabbedPane(SwingConstants.TOP);
    tabbedPanel.addTab(NuxeoLauncherGUI.getMessage("tab.summary.title"), buildSummaryPanel());
    logsTab = buildLogsTab();//from  ww  w  .  j  av a 2 s. c o  m
    tabbedPanel.addTab(NuxeoLauncherGUI.getMessage("tab.logs.title"), logsTab);
    tabbedPanel.addTab(NuxeoLauncherGUI.getMessage("tab.shell.title"), buildConsolePanel());
    tabbedPanel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            JTabbedPane pane = (JTabbedPane) e.getSource();
            if (pane.getSelectedIndex() == 2) {
                consolePanel.getConsole().requestFocusInWindow();
            }
        }
    });
    return tabbedPanel;
}