Example usage for java.awt BorderLayout EAST

List of usage examples for java.awt BorderLayout EAST

Introduction

In this page you can find the example usage for java.awt BorderLayout EAST.

Prototype

String EAST

To view the source code for java.awt BorderLayout EAST.

Click Source Link

Document

The east layout constraint (right side of container).

Usage

From source file:edu.clemson.cs.nestbed.client.gui.TestbedManagerFrame.java

private final JPanel buildConfigurationPanel() {
    JPanel configPanel = new JPanel(new BorderLayout());
    configPanel.setBorder(new TitledBorder("Configurations"));

    // --- left-side -------------------------------------------------
    JPanel sidePanel = new JPanel(new BorderLayout());
    sidePanel.setPreferredSize(new Dimension(WINDOW_WIDTH / 3, SIZE_IGNORED));

    configurationList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    configurationList.addListSelectionListener(new ConfigListSelectionListener());

    sidePanel.add(new JScrollPane(configurationList), BorderLayout.CENTER);
    configPanel.add(sidePanel, BorderLayout.WEST);

    // --- right-side ------------------------------------------------
    sidePanel = new JPanel(new BorderLayout());
    sidePanel.setPreferredSize(new Dimension(310, SIZE_IGNORED));

    JPanel rsTopPanel = new JPanel(new BorderLayout());
    rsTopPanel.setPreferredSize(new Dimension(SIZE_IGNORED, 50));

    JPanel labelPanel = new JPanel(new GridLayout(2, 1, 0, 5));
    labelPanel.add(new JLabel("Name:  "));
    labelPanel.add(new JLabel("Description:  "));

    JPanel infoPanel = new JPanel(new GridLayout(2, 1, 0, 5));
    infoPanel.add(configurationName);/*  w w w  .  ja v  a  2s  .  c o  m*/
    configurationName.setEditable(false);

    infoPanel.add(configurationDesc);
    configurationDesc.setEditable(false);

    rsTopPanel.add(labelPanel, BorderLayout.WEST);
    rsTopPanel.add(infoPanel, BorderLayout.CENTER);

    sidePanel.add(rsTopPanel, BorderLayout.NORTH);

    configPanel.add(sidePanel, BorderLayout.EAST);

    return configPanel;
}

From source file:com.qumasoft.guitools.compare.CompareFrame.java

/**
 * Compare two files.//from   w  w w  .j av a 2 s  .  c  om
 */
public void compare() {
    fitToScreen();
    currentDifferenceIndex = -1;

    // Compare the files
    // <editor-fole>
    String[] compareArgs = new String[3];
    compareArgs[0] = getFirstFileActualName();
    compareArgs[1] = getSecondFileActualName();
    compareArgs[2] = "junk";
    // </editor-fold>
    compareFilesForGUI = new CompareFilesForGUI(compareArgs);
    compareFilesForGUI.setIgnoreAllWhiteSpace(ignoreAllWhiteSpaceFlag);
    compareFilesForGUI.setIgnoreLeadingWhiteSpace(ignoreLeadingWhiteSpaceFlag);
    compareFilesForGUI.setIgnoreCaseFlag(ignoreCaseFlag);
    compareFilesForGUI.setIgnoreEOLChangesFlag(ignoreEOLChangesFlag);
    try {
        Cursor currentCursor = getCursor();
        setCursor(new Cursor(Cursor.WAIT_CURSOR));
        compareFilesForGUI.execute();

        // Enable/disable the forward/backward actions.
        setNextPreviousActionStates(compareFilesForGUI.getNumberOfChanges());

        if (file1ContentsList != null) {
            leftPanel.remove(file1ContentsList);
        }

        if (file2ContentsList != null) {
            rightPanel.remove(file2ContentsList);
        }

        // Set up the model object for the list JList objects.
        file1ContentsListModel = new FileContentsListModel(getFirstFileActualName(), compareFilesForGUI, true,
                null);
        file2ContentsListModel = new FileContentsListModel(getSecondFileActualName(), compareFilesForGUI, false,
                file1ContentsListModel);
        addBlanksToShorterModel();

        file1ContentsList = new FileContentsList(file1ContentsListModel, this);
        leftPanel.add(file1ContentsList);
        rowHeight = file1ContentsList.getRowHeight();
        file1ChangeMarkerPanel = new ChangeMarkerPanel(file1ContentsListModel, rowHeight);

        file2ContentsList = new FileContentsList(file2ContentsListModel, this);
        rightPanel.add(file2ContentsList);
        file2ChangeMarkerPanel = new ChangeMarkerPanel(file2ContentsListModel, rowHeight);

        firstFileDisplayName.setForeground(blackColor);
        firstFileDisplayName.setFont(new java.awt.Font("Arial", 0, DEFAULT_FONT_SIZE));
        firstFileDisplayName.setBorder(bevelBorder);
        leftParentPanel.add(firstFileDisplayName, BorderLayout.NORTH);
        leftParentPanel.add(leftScrollPane, BorderLayout.CENTER);
        leftParentPanel.add(file1ChangeMarkerPanel, BorderLayout.EAST);

        secondFileDisplayName.setForeground(blackColor);
        secondFileDisplayName.setBorder(bevelBorder);
        secondFileDisplayName.setFont(new java.awt.Font("Arial", 0, DEFAULT_FONT_SIZE));
        rightParentPanel.add(secondFileDisplayName, BorderLayout.NORTH);
        rightParentPanel.add(rightScrollPane, BorderLayout.CENTER);
        rightParentPanel.add(file2ChangeMarkerPanel, BorderLayout.EAST);

        // Center the splitter bar
        centerSplitterDivider();

        // Hook the scroll panes up...
        hookScrollPanes();

        setCursor(currentCursor);
        if (!isVisible()) {
            setVisible(true);
        }
    } catch (QVCSOperationException e) {
        LOGGER.log(Level.WARNING, "Caught QVCSOperationException: " + e.getMessage());
    }
}

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java

/**
 * Create a panel containing the webserver (domain+port) and timeouts (connect+request).
 *
 * @return the panel//from   w  ww. j  a v  a 2 s  . c o  m
 */
protected final JPanel getWebServerTimeoutPanel() {
    // WEB SERVER PANEL
    JPanel webServerPanel = new HorizontalPanel();
    webServerPanel.setBorder(
            BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), UPMPConstant.upmp_server)); // $NON-NLS-1$
    final JPanel domainPanel = getDomainPanel();
    final JPanel portPanel = getPortPanel();
    webServerPanel.add(domainPanel, BorderLayout.CENTER);
    webServerPanel.add(portPanel, BorderLayout.EAST);

    JPanel timeOut = new HorizontalPanel();
    timeOut.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),
            UPMPConstant.upmp_server_timeout_title)); // $NON-NLS-1$
    final JPanel connPanel = getConnectTimeOutPanel();
    final JPanel reqPanel = getResponseTimeOutPanel();
    timeOut.add(connPanel);
    timeOut.add(reqPanel);

    JPanel webServerTimeoutPanel = new VerticalPanel();
    webServerTimeoutPanel.add(webServerPanel, BorderLayout.CENTER);
    webServerTimeoutPanel.add(timeOut, BorderLayout.EAST);

    JPanel bigPanel = new VerticalPanel();
    bigPanel.add(webServerTimeoutPanel);
    return bigPanel;
}

From source file:op.care.nursingprocess.DlgNursingProcess.java

/**
 * This method is called from within the constructor to
 * initialize the form.//www.j av  a 2  s .c om
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jPanel5 = new JPanel();
    lblTopic = new JLabel();
    txtStichwort = new JTextField();
    lblCat = new JLabel();
    cmbKategorie = new JComboBox<>();
    panel4 = new JPanel();
    lblSituation = new JLabel();
    btnPopoutSituation = new JButton();
    jScrollPane3 = new JScrollPane();
    txtSituation = new JTextArea();
    panel5 = new JPanel();
    lblGoal = new JLabel();
    btnPopoutGoal = new JButton();
    jScrollPane1 = new JScrollPane();
    txtZiele = new JTextArea();
    lblFirstRevision = new JLabel();
    jdcKontrolle = new JDateChooser();
    panel2 = new JPanel();
    jspPlanung = new JScrollPane();
    tblPlanung = new JTable();
    panel3 = new JPanel();
    btnAddIntervention = new JButton();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnSave = new JButton();

    //======== this ========
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("14dlu, $lcgap, 280dlu:grow, $ugap, pref, $lcgap, 14dlu",
            "fill:14dlu, $lgap, fill:default:grow, $rgap, pref, $lgap, 14dlu"));

    //======== jPanel5 ========
    {
        jPanel5.setLayout(new FormLayout("default, $lcgap, default:grow",
                "fill:default, $rgap, default, 2*($lgap, fill:default:grow), $lgap, 70dlu, $lgap, pref"));

        //---- lblTopic ----
        lblTopic.setFont(new Font("Arial", Font.PLAIN, 14));
        lblTopic.setText("Stichwort");
        jPanel5.add(lblTopic, CC.xy(1, 1, CC.DEFAULT, CC.TOP));

        //---- txtStichwort ----
        txtStichwort.setFont(new Font("Arial", Font.BOLD, 20));
        txtStichwort.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                txtStichwortFocusGained(e);
            }
        });
        jPanel5.add(txtStichwort, CC.xy(3, 1));

        //---- lblCat ----
        lblCat.setFont(new Font("Arial", Font.PLAIN, 14));
        lblCat.setText("Kategorie");
        jPanel5.add(lblCat, CC.xy(1, 3));

        //---- cmbKategorie ----
        cmbKategorie
                .setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbKategorie.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel5.add(cmbKategorie, CC.xy(3, 3));

        //======== panel4 ========
        {
            panel4.setLayout(new BorderLayout());

            //---- lblSituation ----
            lblSituation.setFont(new Font("Arial", Font.PLAIN, 14));
            lblSituation.setText("Situation");
            panel4.add(lblSituation, BorderLayout.CENTER);

            //---- btnPopoutSituation ----
            btnPopoutSituation.setText(null);
            btnPopoutSituation.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/popup.png")));
            btnPopoutSituation.setBorderPainted(false);
            btnPopoutSituation.setContentAreaFilled(false);
            btnPopoutSituation
                    .setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
            btnPopoutSituation.setBorder(null);
            btnPopoutSituation.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnPopoutSituation.addActionListener(e -> btnPopoutSituationActionPerformed(e));
            panel4.add(btnPopoutSituation, BorderLayout.EAST);
        }
        jPanel5.add(panel4, CC.xy(1, 5, CC.DEFAULT, CC.TOP));

        //======== jScrollPane3 ========
        {

            //---- txtSituation ----
            txtSituation.setColumns(20);
            txtSituation.setLineWrap(true);
            txtSituation.setRows(5);
            txtSituation.setWrapStyleWord(true);
            txtSituation.setFont(new Font("Arial", Font.PLAIN, 14));
            txtSituation.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtSituationFocusGained(e);
                }
            });
            jScrollPane3.setViewportView(txtSituation);
        }
        jPanel5.add(jScrollPane3, CC.xy(3, 5));

        //======== panel5 ========
        {
            panel5.setLayout(new BorderLayout());

            //---- lblGoal ----
            lblGoal.setFont(new Font("Arial", Font.PLAIN, 14));
            lblGoal.setText("Ziele");
            panel5.add(lblGoal, BorderLayout.CENTER);

            //---- btnPopoutGoal ----
            btnPopoutGoal.setText(null);
            btnPopoutGoal.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/popup.png")));
            btnPopoutGoal.setBorderPainted(false);
            btnPopoutGoal.setContentAreaFilled(false);
            btnPopoutGoal
                    .setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
            btnPopoutGoal.setBorder(null);
            btnPopoutGoal.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnPopoutGoal.addActionListener(e -> btnPopoutGoalActionPerformed(e));
            panel5.add(btnPopoutGoal, BorderLayout.EAST);
        }
        jPanel5.add(panel5, CC.xy(1, 7, CC.DEFAULT, CC.TOP));

        //======== jScrollPane1 ========
        {

            //---- txtZiele ----
            txtZiele.setColumns(20);
            txtZiele.setLineWrap(true);
            txtZiele.setRows(5);
            txtZiele.setWrapStyleWord(true);
            txtZiele.setFont(new Font("Arial", Font.PLAIN, 14));
            txtZiele.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtZieleFocusGained(e);
                }
            });
            jScrollPane1.setViewportView(txtZiele);
        }
        jPanel5.add(jScrollPane1, CC.xy(3, 7));

        //---- lblFirstRevision ----
        lblFirstRevision.setFont(new Font("Arial", Font.PLAIN, 14));
        lblFirstRevision.setText("Erste Kontrolle am");
        jPanel5.add(lblFirstRevision, CC.xy(1, 11));

        //---- jdcKontrolle ----
        jdcKontrolle.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel5.add(jdcKontrolle, CC.xy(3, 11));
    }
    contentPane.add(jPanel5, CC.xy(3, 3, CC.DEFAULT, CC.FILL));

    //======== panel2 ========
    {
        panel2.setLayout(new FormLayout("default:grow", "default, $lgap, default"));

        //======== jspPlanung ========
        {
            jspPlanung.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentResized(ComponentEvent e) {
                    jspPlanungComponentResized(e);
                }
            });

            //---- tblPlanung ----
            tblPlanung.setModel(new DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null }, },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
            tblPlanung.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
            tblPlanung.addMouseListener(new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                    tblPlanungMousePressed(e);
                }
            });
            jspPlanung.setViewportView(tblPlanung);
        }
        panel2.add(jspPlanung, CC.xy(1, 1));

        //======== panel3 ========
        {
            panel3.setLayout(new BoxLayout(panel3, BoxLayout.X_AXIS));

            //---- btnAddIntervention ----
            btnAddIntervention.setText(null);
            btnAddIntervention.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnAddIntervention.setContentAreaFilled(false);
            btnAddIntervention.setBorderPainted(false);
            btnAddIntervention.setBorder(null);
            btnAddIntervention
                    .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnAddIntervention.addActionListener(e -> btnAddInterventionActionPerformed(e));
            panel3.add(btnAddIntervention);
        }
        panel2.add(panel3, CC.xy(1, 3));
    }
    contentPane.add(panel2, CC.xy(5, 3));

    //======== panel1 ========
    {
        panel1.setLayout(new HorizontalLayout(5));

        //---- btnCancel ----
        btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
        btnCancel.setText(null);
        btnCancel.addActionListener(e -> btnCancelActionPerformed(e));
        panel1.add(btnCancel);

        //---- btnSave ----
        btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnSave.setText(null);
        btnSave.addActionListener(e -> btnSaveActionPerformed(e));
        panel1.add(btnSave);
    }
    contentPane.add(panel1, CC.xy(5, 5, CC.RIGHT, CC.DEFAULT));
    setSize(1145, 695);
    setLocationRelativeTo(getOwner());
}

From source file:edu.brown.gui.CatalogViewer.java

/**
 * /*from   w  w w  . ja v  a  2s . co  m*/
 */
protected void viewerInit() {
    // ----------------------------------------------
    // MENU
    // ----------------------------------------------
    JMenu menu;
    JMenuItem menuItem;

    // 
    // File Menu
    //
    menu = new JMenu("File");
    menu.getPopupMenu().setLightWeightPopupEnabled(false);
    menu.setMnemonic(KeyEvent.VK_F);
    menu.getAccessibleContext().setAccessibleDescription("File Menu");
    menuBar.add(menu);

    menuItem = new JMenuItem("Open Catalog From File");
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From File");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_FILE);
    menu.add(menuItem);

    menuItem = new JMenuItem("Open Catalog From Jar");
    menuItem.setAccelerator(
            KeyStroke.getKeyStroke(KeyEvent.VK_O, ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Open Catalog From Project Jar");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.CATALOG_OPEN_JAR);
    menu.add(menuItem);

    menu.addSeparator();

    menuItem = new JMenuItem("Quit", KeyEvent.VK_Q);
    menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
    menuItem.getAccessibleContext().setAccessibleDescription("Quit Program");
    menuItem.addActionListener(this.menuHandler);
    menuItem.putClientProperty(MenuHandler.MENU_ID, MenuOptions.QUIT);
    menu.add(menuItem);

    // ----------------------------------------------
    // CATALOG TREE PANEL
    // ----------------------------------------------
    this.catalogTree = new JTree();
    this.catalogTree.setEditable(false);
    this.catalogTree.setCellRenderer(new CatalogViewer.CatalogTreeRenderer());
    this.catalogTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    this.catalogTree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) CatalogViewer.this.catalogTree
                    .getLastSelectedPathComponent();
            if (node == null)
                return;

            Object user_obj = node.getUserObject();
            String new_text = ""; // <html>";
            boolean text_mode = true;
            if (user_obj instanceof WrapperNode) {
                CatalogType catalog_obj = ((WrapperNode) user_obj).getCatalogType();
                new_text += CatalogViewer.this.getAttributesText(catalog_obj);
            } else if (user_obj instanceof AttributesNode) {
                AttributesNode wrapper = (AttributesNode) user_obj;
                new_text += wrapper.getAttributes();

            } else if (user_obj instanceof PlanTreeCatalogNode) {
                final PlanTreeCatalogNode wrapper = (PlanTreeCatalogNode) user_obj;
                text_mode = false;

                CatalogViewer.this.mainPanel.remove(0);
                CatalogViewer.this.mainPanel.add(wrapper.getPanel(), BorderLayout.CENTER);
                CatalogViewer.this.mainPanel.validate();
                CatalogViewer.this.mainPanel.repaint();

                if (SwingUtilities.isEventDispatchThread() == false) {
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            wrapper.centerOnRoot();
                        }
                    });
                } else {
                    wrapper.centerOnRoot();
                }

            } else {
                new_text += CatalogViewer.this.getSummaryText();
            }

            // Text Mode
            if (text_mode) {
                if (CatalogViewer.this.text_mode == false) {
                    CatalogViewer.this.mainPanel.remove(0);
                    CatalogViewer.this.mainPanel.add(CatalogViewer.this.textInfoPanel);
                }
                CatalogViewer.this.textInfoTextArea.setText(new_text);

                // Scroll to top
                CatalogViewer.this.textInfoTextArea.grabFocus();
            }

            CatalogViewer.this.text_mode = text_mode;
        }
    });
    this.generateCatalogTree(this.catalog, this.catalog_file_path.getName());

    //
    // Text Information Panel
    //
    this.textInfoPanel = new JPanel();
    this.textInfoPanel.setLayout(new BorderLayout());
    this.textInfoTextArea = new JTextArea();
    this.textInfoTextArea.setEditable(false);
    this.textInfoTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12));
    this.textInfoTextArea.setText(this.getSummaryText());
    this.textInfoTextArea.addFocusListener(new FocusListener() {
        @Override
        public void focusLost(FocusEvent e) {
            // TODO Auto-generated method stub
        }

        @Override
        public void focusGained(FocusEvent e) {
            CatalogViewer.this.scrollTextInfoToTop();
        }
    });
    this.textInfoScroller = new JScrollPane(this.textInfoTextArea);
    this.textInfoPanel.add(this.textInfoScroller, BorderLayout.CENTER);
    this.mainPanel = new JPanel(new BorderLayout());
    this.mainPanel.add(textInfoPanel, BorderLayout.CENTER);

    //
    // Search Toolbar
    //
    JPanel searchPanel = new JPanel();
    searchPanel.setLayout(new BorderLayout());
    JPanel innerSearchPanel = new JPanel();
    innerSearchPanel.setLayout(new BoxLayout(innerSearchPanel, BoxLayout.X_AXIS));
    innerSearchPanel.add(new JLabel("Search: "));
    this.searchField = new JTextField(30);
    innerSearchPanel.add(this.searchField);
    searchPanel.add(innerSearchPanel, BorderLayout.EAST);

    this.searchField.addKeyListener(new KeyListener() {
        private String last = null;

        @Override
        public void keyReleased(KeyEvent e) {
            String value = CatalogViewer.this.searchField.getText().toLowerCase().trim();
            if (!value.isEmpty() && (this.last == null || !this.last.equals(value))) {
                CatalogViewer.this.search(value);
            }
            this.last = value;
        }

        @Override
        public void keyTyped(KeyEvent e) {
            // Do nothing...
        }

        @Override
        public void keyPressed(KeyEvent e) {
            // Do nothing...
        }
    });

    // Putting it all together
    JScrollPane scrollPane = new JScrollPane(this.catalogTree);
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BorderLayout());
    topPanel.add(searchPanel, BorderLayout.NORTH);
    topPanel.add(scrollPane, BorderLayout.CENTER);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topPanel, this.mainPanel);
    splitPane.setDividerLocation(400);

    this.add(splitPane, BorderLayout.CENTER);
}

From source file:org.jajuk.ui.widgets.JajukJMenuBar.java

/**
 * Instantiates a new jajuk j menu bar.//from  w  w w  . j  a v a 2s . c om
 */
private JajukJMenuBar() {
    setAlignmentX(0.0f);
    // File menu
    file = new JMenu(Messages.getString("JajukJMenuBar.0"));
    jmiFileExit = new JMenuItem(ActionManager.getAction(JajukActions.EXIT));
    file.add(jmiFileExit);
    // Properties menu
    properties = new JMenu(Messages.getString("JajukJMenuBar.5"));
    jmiNewProperty = new JMenuItem(ActionManager.getAction(CUSTOM_PROPERTIES_ADD));
    jmiRemoveProperty = new JMenuItem(ActionManager.getAction(CUSTOM_PROPERTIES_REMOVE));
    jmiActivateTags = new JMenuItem(ActionManager.getAction(EXTRA_TAGS_WIZARD));
    properties.add(jmiNewProperty);
    properties.add(jmiRemoveProperty);
    properties.add(jmiActivateTags);
    // View menu
    views = new JMenu(Messages.getString("JajukJMenuBar.8"));
    jmiRestoreDefaultViews = new JMenuItem(ActionManager.getAction(VIEW_RESTORE_DEFAULTS));
    jmiRestoreDefaultViewsAllPerpsectives = new JMenuItem(
            ActionManager.getAction(JajukActions.ALL_VIEW_RESTORE_DEFAULTS));
    views.add(jmiRestoreDefaultViews);
    views.add(jmiRestoreDefaultViewsAllPerpsectives);
    views.addSeparator();
    // Add the list of available views parsed in XML files at startup
    JMenu jmViews = new JMenu(Messages.getString("JajukJMenuBar.25"));
    for (final Class<? extends IView> view : ViewFactory.getKnownViews()) {
        JMenuItem jmi = null;
        try {
            jmi = new JMenuItem(view.newInstance().getDesc(), IconLoader.getIcon(JajukIcons.LOGO_FRAME));
        } catch (Exception e1) {
            Log.error(e1);
            continue;
        }
        jmi.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // Simply add the new view in the current perspective
                PerspectiveAdapter current = (PerspectiveAdapter) PerspectiveManager.getCurrentPerspective();
                IView newView = ViewFactory.createView(view, current,
                        Math.abs(UtilSystem.getRandom().nextInt()));
                newView.initUI();
                newView.setPopulated();
                current.addDockable(newView);
            }
        });
        jmViews.add(jmi);
    }
    views.add(jmViews);
    // Mode menu
    String modeText = Messages.getString("JajukJMenuBar.9");
    mode = new JMenu(ActionUtil.strip(modeText));
    jcbmiRepeat = new JCheckBoxMenuItem(ActionManager.getAction(REPEAT_MODE));
    jcbmiRepeat.setSelected(Conf.getBoolean(Const.CONF_STATE_REPEAT));
    jcbmiRepeatAll = new JCheckBoxMenuItem(ActionManager.getAction(REPEAT_ALL_MODE));
    jcbmiRepeatAll.setSelected(Conf.getBoolean(Const.CONF_STATE_REPEAT_ALL));
    jcbmiShuffle = new JCheckBoxMenuItem(ActionManager.getAction(SHUFFLE_MODE));
    jcbmiShuffle.setSelected(Conf.getBoolean(Const.CONF_STATE_SHUFFLE));
    jcbmiContinue = new JCheckBoxMenuItem(ActionManager.getAction(CONTINUE_MODE));
    jcbmiContinue.setSelected(Conf.getBoolean(Const.CONF_STATE_CONTINUE));
    jcbmiIntro = new JCheckBoxMenuItem(ActionManager.getAction(INTRO_MODE));
    jcbmiIntro.setSelected(Conf.getBoolean(Const.CONF_STATE_INTRO));
    jcbmiKaraoke = new JCheckBoxMenuItem(ActionManager.getAction(JajukActions.KARAOKE_MODE));
    if (Conf.getBoolean(Const.CONF_BIT_PERFECT)) {
        jcbmiKaraoke.setEnabled(false);
        jcbmiKaraoke.setSelected(false);
        Conf.setProperty(Const.CONF_STATE_KARAOKE, Const.FALSE);
    } else {
        jcbmiKaraoke.setSelected(Conf.getBoolean(Const.CONF_STATE_KARAOKE));
    }
    mode.add(jcbmiRepeat);
    mode.add(jcbmiRepeatAll);
    mode.add(jcbmiShuffle);
    mode.add(jcbmiContinue);
    mode.add(jcbmiIntro);
    mode.add(jcbmiKaraoke);
    // Smart Menu
    smart = new JMenu(Messages.getString("JajukJMenuBar.29"));
    jmiShuffle = new SizedJMenuItem(ActionManager.getAction(JajukActions.SHUFFLE_GLOBAL));
    jmiBestof = new SizedJMenuItem(ActionManager.getAction(JajukActions.BEST_OF));
    jmiNovelties = new SizedJMenuItem(ActionManager.getAction(JajukActions.NOVELTIES));
    jmiFinishAlbum = new SizedJMenuItem(ActionManager.getAction(JajukActions.FINISH_ALBUM));
    smart.add(jmiShuffle);
    smart.add(jmiBestof);
    smart.add(jmiNovelties);
    smart.add(jmiFinishAlbum);
    // Tools Menu
    tools = new JMenu(Messages.getString("JajukJMenuBar.28"));
    jmiduplicateFinder = new JMenuItem(ActionManager.getAction(JajukActions.FIND_DUPLICATE_FILES));
    jmialarmClock = new JMenuItem(ActionManager.getAction(JajukActions.ALARM_CLOCK));
    jmiprepareParty = new JMenuItem(ActionManager.getAction(JajukActions.PREPARE_PARTY));
    tools.add(jmiduplicateFinder);
    tools.add(jmialarmClock);
    tools.add(jmiprepareParty);
    // tools.addSeparator();
    // Configuration menu
    configuration = new JMenu(Messages.getString("JajukJMenuBar.21"));
    jmiDJ = new JMenuItem(ActionManager.getAction(CONFIGURE_DJS));
    // Overwrite default icon
    jmiDJ.setIcon(IconLoader.getIcon(JajukIcons.DIGITAL_DJ_16X16));
    jmiAmbience = new JMenuItem(ActionManager.getAction(CONFIGURE_AMBIENCES));
    jmiWizard = new JMenuItem(ActionManager.getAction(SIMPLE_DEVICE_WIZARD));
    jmiOptions = new JMenuItem(ActionManager.getAction(OPTIONS));
    jmiUnmounted = new JCheckBoxMenuItem(ActionManager.getAction(JajukActions.UNMOUNTED));
    jmiUnmounted.setSelected(Conf.getBoolean(Const.CONF_OPTIONS_HIDE_UNMOUNTED));
    jmiUnmounted.putClientProperty(Const.DETAIL_ORIGIN, jmiUnmounted);
    jcbShowPopups = new JCheckBoxMenuItem(Messages.getString("ParameterView.228"));
    jcbShowPopups.setSelected(Conf.getBoolean(Const.CONF_SHOW_POPUPS));
    jcbShowPopups.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Conf.setProperty(Const.CONF_SHOW_POPUPS, Boolean.toString(jcbShowPopups.isSelected()));
            // force parameter view to take this into account
            ObservationManager.notify(new JajukEvent(JajukEvents.PARAMETERS_CHANGE));
        }
    });
    jcbNoneInternetAccess = new JCheckBoxMenuItem(Messages.getString("ParameterView.264"));
    jcbNoneInternetAccess.setToolTipText(Messages.getString("ParameterView.265"));
    jcbNoneInternetAccess.setSelected(Conf.getBoolean(Const.CONF_NETWORK_NONE_INTERNET_ACCESS));
    jcbNoneInternetAccess.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Conf.setProperty(Const.CONF_NETWORK_NONE_INTERNET_ACCESS,
                    Boolean.toString(jcbNoneInternetAccess.isSelected()));
            // force parameter view to take this into account
            ObservationManager.notify(new JajukEvent(JajukEvents.PARAMETERS_CHANGE));
        }
    });
    configuration.add(jmiUnmounted);
    configuration.add(jcbShowPopups);
    configuration.add(jcbNoneInternetAccess);
    configuration.addSeparator();
    configuration.add(jmiDJ);
    configuration.add(jmiAmbience);
    configuration.add(jmiWizard);
    configuration.add(jmiOptions);
    // Help menu
    String helpText = Messages.getString("JajukJMenuBar.14");
    help = new JMenu(ActionUtil.strip(helpText));
    jmiHelp = new JMenuItem(ActionManager.getAction(HELP_REQUIRED));
    jmiDonate = new JMenuItem(ActionManager.getAction(SHOW_DONATE));
    jmiAbout = new JMenuItem(ActionManager.getAction(SHOW_ABOUT));
    jmiTraces = new JMenuItem(ActionManager.getAction(SHOW_TRACES));
    jmiTraces = new JMenuItem(ActionManager.getAction(SHOW_TRACES));
    jmiCheckforUpdates = new JMenuItem(ActionManager.getAction(JajukActions.CHECK_FOR_UPDATES));
    jmiTipOfTheDay = new JMenuItem(ActionManager.getAction(TIP_OF_THE_DAY));
    help.add(jmiHelp);
    help.add(jmiTipOfTheDay);
    // Install this action only if Desktop class is supported, it is used to
    // open default mail client
    if (UtilSystem.isBrowserSupported()) {
        jmiQualityAgent = new JMenuItem(ActionManager.getAction(QUALITY));
        help.add(jmiQualityAgent);
    }
    help.add(jmiTraces);
    help.add(jmiCheckforUpdates);
    help.add(jmiDonate);
    help.add(jmiAbout);
    mainmenu = new JMenuBar();
    mainmenu.add(file);
    mainmenu.add(views);
    mainmenu.add(properties);
    mainmenu.add(mode);
    mainmenu.add(smart);
    mainmenu.add(tools);
    mainmenu.add(configuration);
    mainmenu.add(help);
    // Apply mnemonics (Alt + first char of the menu keystroke)
    applyMnemonics();
    if (SessionService.isTestMode()) {
        jbGC = new JajukButton(ActionManager.getAction(JajukActions.GC));
    }
    jbSlim = new JajukButton(ActionManager.getAction(JajukActions.SLIM_JAJUK));
    jbFull = new JajukButton(ActionManager.getAction(JajukActions.FULLSCREEN_JAJUK));
    JMenuBar eastmenu = new JMenuBar();
    // only show GC-button in test-mode
    if (SessionService.isTestMode()) {
        eastmenu.add(jbGC);
    }
    eastmenu.add(jbSlim);
    eastmenu.add(jbFull);
    setLayout(new BorderLayout());
    add(mainmenu, BorderLayout.WEST);
    add(eastmenu, BorderLayout.EAST);
    // Check for new release and display the icon if a new release is available
    SwingWorker<Void, Void> sw = new SwingWorker<Void, Void>() {
        @Override
        public Void doInBackground() {
            UpgradeManager.checkForUpdate();
            return null;
        }

        @Override
        public void done() {
            // add the new release label if required
            if (UpgradeManager.getNewVersionName() != null) {
                jlUpdate = new JLabel(" ", IconLoader.getIcon(JajukIcons.UPDATE_MANAGER), SwingConstants.RIGHT);
                String newRelease = UpgradeManager.getNewVersionName();
                if (newRelease != null) {
                    jlUpdate.setToolTipText(Messages.getString("UpdateManager.0") + newRelease
                            + Messages.getString("UpdateManager.1"));
                }
                add(Box.createHorizontalGlue());
                add(jlUpdate);
            }
        }
    };
    // Search online for upgrade if the option is set and if the none Internet
    // access option is not set
    if (Conf.getBoolean(Const.CONF_CHECK_FOR_UPDATE)
            && !Conf.getBoolean(Const.CONF_NETWORK_NONE_INTERNET_ACCESS)) {
        sw.execute();
    }
    ObservationManager.register(this);
}

From source file:snepsui.Interface.TestDraw.java

private void initGUI() {
    nodesList = new LinkedList<Node>();
    molNodes = new Hashtable<String, CaseFrame>();
    builtMolNodes = new Hashtable<String, Node>();

    this.setPreferredSize(new Dimension(815, 600));

    graph = new DirectedOrderedSparseMultigraph<String, String>();

    this.layout = new StaticLayout<String, String>(graph, new Dimension(700, 450));

    shape = new Transformer<String, Integer>() {
        public Integer transform(String vertex) {
            int stringLength = 0;
            if (molNodes.containsKey(vertex)) {
                stringLength = 3;//from  w w w. ja  v  a  2s  . co m
            } else {
                for (Node node : nodesList) {
                    if (vertex.equals(node.getIdentifier())) {
                        stringLength = node.getIdentifier().length();
                    }
                }
            }
            return stringLength;
        }
    };

    vertexPaint = new Transformer<String, Paint>() {
        public Paint transform(String vertex) {
            //              if(molNodes.containsKey(vertex)) {
            //                 if(builtMolNodes.containsKey(vertex)) {
            //                    Node node = builtMolNodes.get(vertex);
            //                    if (node.getClass().getSimpleName().equals("PatternNode")) {
            //                      return Color.blue;
            //                   } else if (node.getClass().getSimpleName().equals("ClosedNode")) {
            //                      return Color.yellow;
            //                   }
            //                 } else
            //                    return Color.white;
            //              } else {
            //                 for(Node node : nodesList) {
            //                    if(node.getIdentifier().equals(vertex)) {
            //                       if(node.getClass().getSimpleName().equals("BaseNode")) {
            //                          return Color.green;
            //                       } else if (node.getClass().getSimpleName().equals("VariableNode")) {
            //                          return Color.gray;
            //                       } else if (node.getClass().getSimpleName().equals("PatternNode")) {
            //                          return Color.blue;
            //                       } else if (node.getClass().getSimpleName().equals("ClosedNode")) {
            //                          return Color.yellow;
            //                       } else {
            //                          return Color.magenta;
            //                       }
            //                    }
            //                  }
            //              }
            return Color.white;
        }
    };

    edgeLabel = new Transformer<String, String>() {
        public String transform(String edge) {
            String result = "";

            if (edge.isEmpty())
                graph.removeEdge("");
            vv.repaint();
            try {
                result = edge.substring(0, edge.indexOf(":"));
            } catch (StringIndexOutOfBoundsException e) {

            }
            return result;
        }
    };

    VertexShapeSizeAspect<String> vssa = new VertexShapeSizeAspect<String>(graph, shape);

    vv = new VisualizationViewer<String, String>(layout, new Dimension(700, 470));
    vv.setBackground(Color.white);

    vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<String, String>getInstance(
            LazyMap.<String, String>decorate(new HashMap<String, String>(), new ToStringLabeller<String>())));
    vv.getRenderContext().setEdgeLabelTransformer(MapTransformer.<String, String>getInstance(
            LazyMap.<String, String>decorate(new HashMap<String, String>(), new ToStringLabeller<String>())));
    vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer());
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    vv.getRenderContext().setVertexShapeTransformer(vssa);
    vv.getRenderContext()
            .setEdgeLabelClosenessTransformer(new ConstantDirectionalEdgeValueTransformer(0.5, 0.5));
    vv.getRenderContext().setEdgeLabelTransformer(edgeLabel);
    vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
    vv.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            point = e.getPoint();
        }

        public void mouseReleased(MouseEvent e) {
            vv.repaint();
        }
    });
    vssa.setScaling(true);

    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    this.add(panel);
    Factory<String> vertexFactory = new VertexFactory();
    Factory<String> edgeFactory = new EdgeFactory();

    final EditingModalGraphMouse<String, String> graphMouse = new EditingModalGraphMouse<String, String>(
            vv.getRenderContext(), vertexFactory, edgeFactory);

    graphMouse.add(new CustomEditingPopupGraphMousePlugin<String>(vertexFactory, edgeFactory));
    graphMouse.remove(graphMouse.getPopupEditingPlugin());

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    graphMouse.setMode(ModalGraphMouse.Mode.EDITING);

    final ScalingControl scaler = new CrossoverScalingControl();

    vv.scaleToLayout(scaler);

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });

    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    String path = "src/snepsui/Interface/resources/icons/";

    JButton infoButton = new JButton(new ImageIcon(path + "info.png"));
    infoButton.setBounds(710, 320, 16, 16);
    infoButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog(vv, instructions);
        }
    });

    JButton resetbutton = new JButton(new ImageIcon(path + "resetnet.png"));
    resetbutton.setBounds(710, 300, 16, 16);
    resetbutton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            int result = JOptionPane.showConfirmDialog(vv, "Are you sure you want to reset the drawing area?",
                    "Reset", JOptionPane.YES_NO_OPTION);
            if (result == JOptionPane.YES_OPTION) {
                builtMolNodes.clear();
                molNodes.clear();
                nodesList.clear();

                LinkedList<String> vertexList = new LinkedList<String>();
                Collection<String> vertices = graph.getVertices();
                for (String vertex : vertices) {
                    vertexList.add(vertex);
                }

                for (String item : vertexList) {
                    graph.removeVertex(item);
                }
                vv.repaint();
            }
        }
    });

    JLabel caseframeLabel = new JLabel("Case Frames");
    DefaultComboBoxModel caseframeComboBoxModel = new DefaultComboBoxModel(
            new String[] { "define-caseframe", "undefine-caseframe" });
    caseframeComboBox = new JComboBox();
    caseframeComboBox.setModel(caseframeComboBoxModel);

    JLabel relationsLabel = new JLabel("Relations");
    DefaultComboBoxModel relationsComboBoxModel = new DefaultComboBoxModel(
            new String[] { "define", "undefine" });
    relationsComboBox = new JComboBox();
    relationsComboBox.setModel(relationsComboBoxModel);

    this.add(infoButton, BorderLayout.EAST);
    this.add(resetbutton);
    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(scaleGrid);
    controls.add(relationsLabel);
    controls.add(relationsComboBox);
    controls.add(caseframeLabel);
    controls.add(caseframeComboBox);
    JComboBox modeBox = graphMouse.getModeComboBox();
    controls.add(modeBox);
    this.add(controls, BorderLayout.SOUTH);
}

From source file:com.diversityarrays.kdxplore.KDXploreFrame.java

KDXploreFrame(ApplicationFolder appFolder, String title, int versionCode, String version,
        Closure<UpdateCheckContext> updateChecker) throws IOException {
    super(title);

    this.applicationFolder = appFolder;
    this.baseTitle = title;
    this.versionCode = versionCode;
    this.version = version;
    this.updateChecker = updateChecker;

    KdxploreConfig config = KdxploreConfig.getInstance();
    this.onlineHelpUrl = config.getOnlineHelpUrl();

    String supportEmail = config.getSupportEmail();
    if (Check.isEmpty(supportEmail)) {
        supportEmail = "someone@somewhere"; //$NON-NLS-1$
    }//from   w w w .  j ava2  s.com
    DefaultUncaughtExceptionHandler eh = new DefaultUncaughtExceptionHandler(this,
            appFolder.getApplicationName() + "_Error", //$NON-NLS-1$
            supportEmail, version + "(" + versionCode + ")"); //$NON-NLS-1$ //$NON-NLS-2$
    Thread.setDefaultUncaughtExceptionHandler(eh);
    MsgBox.DEFAULT_PROBLEM_REPORTER = eh;

    this.userDataFolder = applicationFolder.getUserDataFolder();

    this.loginUrlsProvider = new PropertiesLoginUrlsProvider(CommandArgs.getPropertiesFile(applicationFolder));

    displayVersion = RunMode.getRunMode().isDeveloper() ? version + "-dev" //$NON-NLS-1$
            : version;

    List<? extends Image> iconImages = loadIconImages();
    iconImage = iconImageBig != null ? iconImageBig : iconImageSmall;
    kdxploreIcon = new ImageIcon(iconImageSmall != null ? iconImageSmall : iconImageBig);
    setIconImages(iconImages);

    if (Util.isMacOS()) {
        try {
            System.setProperty("apple.laf.useScreenMenuBar", "true"); //$NON-NLS-1$ //$NON-NLS-2$

            macapp = new MacApplication(null);
            macapp.setAboutHandler(aboutAction);
            macapp.setQuitHandler(exitAction);
            if (iconImage != null) {
                macapp.setDockIconImage(iconImage);
            }
            macapp.setPreferencesHandler(settingsAction);
            macapp.setAboutHandler(aboutAction);
            macapp.setQuitHandler(exitAction);
        } catch (MacApplicationException e) {
            macapp = null;
            Shared.Log.w(TAG, "isMacOS", e); //$NON-NLS-1$
        }
    }

    if (iconImage != null) {
        this.setIconImage(iconImage);
    }

    clientProvider = new DefaultDALClientProvider(this, loginUrlsProvider, createBrandingImageComponent());
    clientProvider.setCanChangeUrl(false);
    clientProvider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            handleClientChanged();
        }
    });

    connectDisconnectActions = new ConnectDisconnectActions(clientProvider, Msg.TOOLTIP_CONNECT_TO_DATABASE(),
            Msg.TOOLTIP_DISCONNECT_FROM_DATABASE());
    connectDisconnectActions.setConnectIntercept(connectIntercept);

    desktopSupport = new DefaultDesktopSupport(KDXploreFrame.this, baseTitle);

    frameWindowOpener = new DefaultFrameWindowOpener(desktopSupport) {
        @Override
        public Image getIconImage() {
            return iconImage;
        }
    };
    frameWindowOpener.setOpenOnSameScreenAs(KDXploreFrame.this);

    setGlassPane(desktopSupport.getBlockingPane());

    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

    addWindowListener(windowListener);

    initialiseKdxApps();

    JMenuBar mb = buildMenuBar();

    if (iconImage != null) {
        backgroundPanel.setBackgroundImage(iconImage);
    } else {
        backgroundPanel.setBackgroundImage(KDClientUtils.getImage(ImageId.DART_LOGO_128x87));
    }
    backgroundPanel.setBackground(Color.decode("0xccffff")); //$NON-NLS-1$

    splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, cardPanel, messagesPanel);
    splitPane.setResizeWeight(0.8);

    // = = = = = =

    Container cp = getContentPane();
    cp.add(splitPane, BorderLayout.CENTER);

    statusInfoLine.setHorizontalAlignment(SwingConstants.LEFT);
    logoImagesLabel = new LogoImagesLabel();
    JPanel bottom = new JPanel(new BorderLayout());
    bottom.add(statusInfoLine, BorderLayout.CENTER);
    bottom.add(logoImagesLabel, BorderLayout.EAST);
    cp.add(bottom, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            removeWindowListener(this);
            logoImagesLabel.startCycling();
        }
    });

    showCard(CARD_KDXAPPS);

    setJMenuBar(mb);

    pack();

    Dimension size = getSize();
    boolean changed = false;
    if (size.width < MINIMUM_SIZE.width) {
        size.width = MINIMUM_SIZE.width;
        changed = true;
    }
    if (size.height < MINIMUM_SIZE.height) {
        size.height = MINIMUM_SIZE.height;
        changed = true;
    }
    if (changed) {
        setSize(size);
    }

    setLocationRelativeTo(null);

    final MemoryUsageMonitor mum = new MemoryUsageMonitor();
    mum.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            updateStatusLineWithMemoryUsage(mum.getMemoryUsage());
        }
    });
}

From source file:ca.sqlpower.architect.swingui.enterprise.SecurityPanel.java

private User createUserFromPrompter() {
    JTextField nameField = new JTextField(15);
    JTextField passField = new JPasswordField(15);
    JTextField confirmField = new JPasswordField(15);

    JPanel namePanel = new JPanel(new BorderLayout());
    namePanel.add(new JLabel("User Name"), BorderLayout.WEST);
    namePanel.add(nameField, BorderLayout.EAST);

    JPanel passPanel = new JPanel(new BorderLayout());
    passPanel.add(new JLabel("Password"), BorderLayout.WEST);
    passPanel.add(passField, BorderLayout.EAST);

    JPanel confirmPanel = new JPanel(new BorderLayout());
    confirmPanel.add(new JLabel("Confirm Password"), BorderLayout.WEST);
    confirmPanel.add(confirmField, BorderLayout.EAST);

    Object[] messages = new Object[] { "Specify the User's Name and Password.", namePanel, passPanel,
            confirmPanel };//from   w ww . ja v  a  2 s.com

    String[] options = { "OK", "Cancel", };
    int option = JOptionPane.showOptionDialog(getPanel(), messages, "Specify the User's Name and Password",
            JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);

    if (nameField.getText().equals("") || nameField.getText() == null || passField.getText().equals("")
            || passField.getText() == null) {
        return null;
    }

    if (!passField.getText().equals(confirmField.getText())) {
        JOptionPane.showMessageDialog(getPanel(), "The passwords you entered do not match.", "Error",
                JOptionPane.ERROR_MESSAGE);
        return null;
    }

    User user = null;
    if (option == 0) {
        String password;
        try {
            password = new String(Hex.encodeHex(digester.digest(passField.getText().getBytes("UTF-8"))));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("Unable to encode password", e);
        }
        user = new User(nameField.getText(), password);
    }

    return user;
}

From source file:org.pegadi.client.ApplicationLauncher.java

private void jbInit() {
    ImageIcon icon = new ImageIcon(getClass().getResource("/images/pegadi.gif"));
    setIconImage(icon.getImage());/*  w w w  . j  ava  2  s  . co  m*/

    this.getContentPane().setLayout(borderLayout1);
    jPanel1.setLayout(flowLayout1);
    listerButton.setEnabled(false);
    publicationButton.setEnabled(false);
    tetrisButton.setEnabled(false);

    // ImageIcon reportBugIcon = new
    // ImageIcon(getClass().getResource(appStrings.getString("icon_open")));

    reportBugAction = new AbstractAction(str.getString("menu_help_report")) {
        public void actionPerformed(ActionEvent e) {
            reportBug_actionPerformed(e);
        }
    };

    prefsMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            prefsMenuItem_actionPerformed(e);
        }
    });

    listerMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(76, java.awt.event.KeyEvent.CTRL_MASK, false));
    listerMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            listerButton_actionPerformed(e);
        }
    });

    sourcesMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(73, java.awt.event.KeyEvent.CTRL_MASK, false));
    sourcesMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            sourcesButton_actionPerformed();
        }
    });

    tetrisMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(84, java.awt.event.KeyEvent.CTRL_MASK, false));
    tetrisMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tetrisButton_actionPerformed(e);
        }
    });

    logoutMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(87, java.awt.event.KeyEvent.CTRL_MASK, false));
    logoutMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            logoutMenuItem_actionPerformed(e);
        }
    });

    quitMenuItem
            .setAccelerator(javax.swing.KeyStroke.getKeyStroke(81, java.awt.event.KeyEvent.CTRL_MASK, false));
    quitMenuItem.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            quitMenuItem_actionPerformed(e);
        }
    });

    this.getContentPane().add(jPanel1, BorderLayout.NORTH);
    jPanel1.add(listerButton, null);

    listerButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            listerButton_actionPerformed(e);
        }
    });

    publicationButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            publicationButton_actionPerformed(e);
        }
    });

    sourcesButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            sourcesButton_actionPerformed();
        }
    });

    tetrisButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tetrisButton_actionPerformed(e);
        }
    });

    logoutButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            logoutButton_actionPerformed(e);
        }
    });

    quitButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(ActionEvent e) {
            quitButton_actionPerformed(e);
        }
    });

    jPanel1.add(publicationButton, null);
    jPanel1.add(sourcesButton, null);
    jPanel1.add(tetrisButton, null);
    this.getContentPane().add(jPanel2, BorderLayout.EAST);
    jPanel2.add(usrlabel, null);
    jPanel2.add(logoutButton, null);
    jPanel2.add(quitButton, null);
    menuBar.add(fileMenu);
    menuBar.add(editMenu);
    menuBar.add(helpMenu);
    editMenu.add(prefsMenuItem);
    fileMenu.add(listerMenuItem);
    fileMenu.add(sourcesMenuItem);
    fileMenu.add(tetrisMenuItem);
    fileMenu.add(logoutMenuItem);
    fileMenu.add(quitMenuItem);
    helpMenu.add(reportBugAction);
    this.setJMenuBar(menuBar);
    this.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            conditionalExit();
        }
    });
    this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);

}