Example usage for java.awt BorderLayout WEST

List of usage examples for java.awt BorderLayout WEST

Introduction

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

Prototype

String WEST

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

Click Source Link

Document

The west layout constraint (left side of container).

Usage

From source file:net.sf.jabref.gui.preftabs.PreferencesDialog.java

public PreferencesDialog(JabRefFrame parent) {
    super(parent, Localization.lang("JabRef preferences"), false);
    JabRefPreferences prefs = JabRefPreferences.getInstance();
    frame = parent;//from ww  w  . j a v a2  s . co m

    main = new JPanel();
    JPanel mainPanel = new JPanel();
    JPanel lower = new JPanel();

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(mainPanel, BorderLayout.CENTER);
    getContentPane().add(lower, BorderLayout.SOUTH);

    final CardLayout cardLayout = new CardLayout();
    main.setLayout(cardLayout);

    List<PrefsTab> tabs = new ArrayList<>();
    tabs.add(new GeneralTab(prefs));
    tabs.add(new NetworkTab(prefs));
    tabs.add(new FileTab(frame, prefs));
    tabs.add(new FileSortTab(prefs));
    tabs.add(new EntryEditorPrefsTab(frame, prefs));
    tabs.add(new GroupsPrefsTab(prefs));
    tabs.add(new AppearancePrefsTab(prefs));
    tabs.add(new ExternalTab(frame, this, prefs));
    tabs.add(new TablePrefsTab(prefs));
    tabs.add(new TableColumnsTab(prefs, parent));
    tabs.add(new LabelPatternPrefTab(prefs, parent.getCurrentBasePanel()));
    tabs.add(new PreviewPrefsTab(prefs));
    tabs.add(new NameFormatterTab(prefs));
    tabs.add(new ImportSettingsTab(prefs));
    tabs.add(new XmpPrefsTab(prefs));
    tabs.add(new AdvancedTab(prefs));

    // add all tabs
    tabs.forEach(tab -> main.add((Component) tab, tab.getTabName()));

    mainPanel.setBorder(BorderFactory.createEtchedBorder());

    String[] tabNames = tabs.stream().map(PrefsTab::getTabName).toArray(String[]::new);
    JList<String> chooser = new JList<>(tabNames);
    chooser.setBorder(BorderFactory.createEtchedBorder());
    // Set a prototype value to control the width of the list:
    chooser.setPrototypeCellValue("This should be wide enough");
    chooser.setSelectedIndex(0);
    chooser.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // Add the selection listener that will show the correct panel when
    // selection changes:
    chooser.addListSelectionListener(e -> {
        if (e.getValueIsAdjusting()) {
            return;
        }
        String o = chooser.getSelectedValue();
        cardLayout.show(main, o);
    });

    JPanel buttons = new JPanel();
    buttons.setLayout(new GridLayout(4, 1));
    buttons.add(importPreferences, 0);
    buttons.add(exportPreferences, 1);
    buttons.add(showPreferences, 2);
    buttons.add(resetPreferences, 3);

    JPanel westPanel = new JPanel();
    westPanel.setLayout(new BorderLayout());
    westPanel.add(chooser, BorderLayout.CENTER);
    westPanel.add(buttons, BorderLayout.SOUTH);
    mainPanel.setLayout(new BorderLayout());
    mainPanel.add(main, BorderLayout.CENTER);
    mainPanel.add(westPanel, BorderLayout.WEST);

    JButton ok = new JButton(Localization.lang("OK"));
    JButton cancel = new JButton(Localization.lang("Cancel"));
    ok.addActionListener(new OkAction());
    CancelAction cancelAction = new CancelAction();
    cancel.addActionListener(cancelAction);
    lower.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder(lower);
    buttonBarBuilder.addGlue();
    buttonBarBuilder.addButton(ok);
    buttonBarBuilder.addButton(cancel);
    buttonBarBuilder.addGlue();

    // Key bindings:
    KeyBinder.bindCloseDialogKeyToCancelAction(this.getRootPane(), cancelAction);

    // Import and export actions:
    exportPreferences.setToolTipText(Localization.lang("Export preferences to file"));
    exportPreferences.addActionListener(e -> {
        String filename = FileDialogs.getNewFile(frame, new File(System.getProperty("user.home")),
                Collections.singletonList(".xml"), JFileChooser.SAVE_DIALOG, false);
        if (filename == null) {
            return;
        }
        File file = new File(filename);
        if (!file.exists() || (JOptionPane.showConfirmDialog(PreferencesDialog.this,
                Localization.lang("'%0' exists. Overwrite file?", file.getName()),
                Localization.lang("Export preferences"),
                JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION)) {

            try {
                prefs.exportPreferences(filename);
            } catch (JabRefException ex) {
                LOGGER.warn(ex.getMessage(), ex);
                JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
                        Localization.lang("Export preferences"), JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    importPreferences.setToolTipText(Localization.lang("Import preferences from file"));
    importPreferences.addActionListener(e -> {
        String filename = FileDialogs.getNewFile(frame, new File(System.getProperty("user.home")),
                Collections.singletonList(".xml"), JFileChooser.OPEN_DIALOG, false);
        if (filename != null) {
            try {
                prefs.importPreferences(filename);
                updateAfterPreferenceChanges();
                JOptionPane.showMessageDialog(PreferencesDialog.this,
                        Localization.lang("You must restart JabRef for this to come into effect."),
                        Localization.lang("Import preferences"), JOptionPane.WARNING_MESSAGE);
            } catch (JabRefException ex) {
                LOGGER.warn(ex.getMessage(), ex);
                JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
                        Localization.lang("Import preferences"), JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    showPreferences.addActionListener(
            e -> new PreferencesFilterDialog(new JabRefPreferencesFilter(Globals.prefs), frame)
                    .setVisible(true));
    resetPreferences.addActionListener(e -> {
        if (JOptionPane.showConfirmDialog(PreferencesDialog.this,
                Localization.lang("Are you sure you want to reset all settings to default values?"),
                Localization.lang("Reset preferences"),
                JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
            try {
                prefs.clear();
                JOptionPane.showMessageDialog(PreferencesDialog.this,
                        Localization.lang("You must restart JabRef for this to come into effect."),
                        Localization.lang("Reset preferences"), JOptionPane.WARNING_MESSAGE);
            } catch (BackingStoreException ex) {
                LOGGER.warn(ex.getMessage(), ex);
                JOptionPane.showMessageDialog(PreferencesDialog.this, ex.getLocalizedMessage(),
                        Localization.lang("Reset preferences"), JOptionPane.ERROR_MESSAGE);
            }
            updateAfterPreferenceChanges();
        }
    });

    setValues();

    pack();

}

From source file:pcgen.gui2.sources.AdvancedSourceSelectionPanel.java

private void initComponents() {
    FlippingSplitPane mainPane = new FlippingSplitPane(JSplitPane.VERTICAL_SPLIT, "advSrcMain");
    FlippingSplitPane topPane = new FlippingSplitPane("advSrcTop");
    topPane.setResizeWeight(0.6);/*from  w  w w  .  j  a  v a2  s.co m*/
    JPanel panel = new JPanel(new BorderLayout());
    panel.add(new JLabel(LanguageBundle.getString("in_src_gameLabel")), BorderLayout.WEST); //$NON-NLS-1$

    FacadeComboBoxModel<GameModeDisplayFacade> gameModes = new FacadeComboBoxModel<>();
    gameModes.setListFacade(FacadeFactory.getGameModeDisplays());
    gameModeList.setModel(gameModes);
    gameModeList.addActionListener(this);
    panel.add(gameModeList, BorderLayout.CENTER);

    FilterBar<Object, CampaignFacade> bar = new FilterBar<>(false);
    bar.add(panel, BorderLayout.WEST);
    bar.addDisplayableFilter(new SearchFilterPanel());
    panel = new JPanel(new BorderLayout());
    panel.add(bar, BorderLayout.NORTH);

    availableTable.setDisplayableFilter(bar);
    availableTable.setTreeViewModel(availTreeViewModel);
    availableTable.getSelectionModel().addListSelectionListener(this);
    availableTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) availableTable.getColumnModel()).getAvailableColumns().get(2)
            .setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));

    JScrollPane pane = new JScrollPane(availableTable);
    pane.setPreferredSize(new Dimension(600, 310));
    panel.add(pane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    unloadAllButton.setAction(new UnloadAllAction());
    box.add(unloadAllButton);
    box.add(Box.createHorizontalGlue());
    addButton.setHorizontalTextPosition(SwingConstants.LEADING);
    addButton.setAction(new AddAction());
    box.add(addButton);
    box.add(Box.createHorizontalStrut(5));
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    panel.add(box, BorderLayout.SOUTH);

    topPane.setLeftComponent(panel);

    JPanel selPanel = new JPanel(new BorderLayout());
    FilterBar<Object, CampaignFacade> filterBar = new FilterBar<>();
    filterBar.addDisplayableFilter(new SearchFilterPanel());
    selectedTable.setDisplayableFilter(filterBar);

    selectedTable.setTreeViewModel(selTreeViewModel);
    selectedTable.getSelectionModel().addListSelectionListener(this);
    selectedTable.setTreeCellRenderer(new CampaignRenderer());
    ((DynamicTableColumnModel) selectedTable.getColumnModel()).getAvailableColumns().get(2)
            .setCellRenderer(new TableCellUtilities.AlignRenderer(SwingConstants.CENTER));
    JScrollPane scrollPane = new JScrollPane(selectedTable);
    scrollPane.setPreferredSize(new Dimension(300, 350));
    selPanel.add(scrollPane, BorderLayout.CENTER);
    box = Box.createHorizontalBox();
    box.add(Box.createHorizontalStrut(5));
    removeButton.setAction(new RemoveAction());
    box.add(removeButton);
    box.add(Box.createHorizontalGlue());
    box.setBorder(new EmptyBorder(0, 0, 5, 0));
    selPanel.add(box, BorderLayout.SOUTH);

    topPane.setRightComponent(selPanel);
    mainPane.setTopComponent(topPane);

    linkAction.install();
    infoPane.setPreferredSize(new Dimension(800, 150));
    mainPane.setBottomComponent(infoPane);
    mainPane.setResizeWeight(0.7);
    setLayout(new BorderLayout());
    add(mainPane, BorderLayout.CENTER);
}

From source file:com.rapidminer.gui.plotter.PlotterPanel.java

public PlotterPanel(final PlotterConfigurationModel settings) {
    super(new BorderLayout());
    this.controlPanel = new PlotterControlPanel(settings);
    this.settings = settings;
    settings.registerPlotterListener(new PlotterChangedListener() {

        @Override//from  w w  w . j  a  v a2  s  .  c om
        public void plotterChanged(String plotterName) {
            if (plotterName != null) {
                ActionStatisticsCollector.getInstance().log(ActionStatisticsCollector.TYPE_CHART, plotterName,
                        "select");
            }
            if (oldPlotterComponent != null) {
                mainPanel.remove(oldPlotterComponent);
            }
            JComponent plotterComponent = settings.getPlotter().getPlotter();
            if (plotterComponent != null) {
                mainPanel.add(plotterComponent, BorderLayout.CENTER);
                oldPlotterComponent = plotterComponent;
            }
            repaint();
            revalidate();
        }

        @Override
        public List<PlotterSettingsChangedListener> getListeningObjects() {
            return new ArrayList<>(0);
        }
    });
    JScrollPane plotterScrollPane = new ExtendedJScrollPane(mainPanel);
    settings.registerPlotterListener(controlPanel);
    mainPanel.add(controlPanel, BorderLayout.WEST);
    plotterScrollPane.setBorder(null);

    add(plotterScrollPane, BorderLayout.CENTER);

    JComponent plotterComponent = settings.getPlotter().getPlotter();
    if (plotterComponent != null) {
        mainPanel.add(plotterComponent, BorderLayout.CENTER);
        oldPlotterComponent = plotterComponent;
    }
    repaint();
    revalidate();
}

From source file:com.smart.aqimonitor.client.AqiMonitor.java

/**
 * Create the frame.//from  www  .j a va2s .  com
 */
public AqiMonitor() {
    refSelf = this;
    setPreferredSize(new Dimension(640, 480));
    setTitle("\u7A7A\u6C14\u8D28\u91CF\u76D1\u6D4B");
    setIconImage(Toolkit.getDefaultToolkit()
            .getImage(AqiMonitor.class.getResource("/lombok/installer/eclipse/STS.png")));
    setMinimumSize(new Dimension(640, 480));
    setMaximumSize(new Dimension(1024, 768));
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 636, 412);
    contentPane = new JPanel();
    contentPane.setPreferredSize(new Dimension(640, 480));
    contentPane.setMinimumSize(new Dimension(640, 480));
    contentPane.setMaximumSize(new Dimension(1024, 768));
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);

    JPanel mainPanel = new JPanel();
    contentPane.add(mainPanel, BorderLayout.CENTER);
    mainPanel.setLayout(new BorderLayout(0, 0));

    JPanel contentPanel = new JPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new BorderLayout(0, 0));

    JScrollPane scrollPane = new JScrollPane();
    scrollPane
            .setViewportBorder(new TitledBorder(null, "", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    contentPanel.add(scrollPane, BorderLayout.CENTER);

    textPane = new AqiTextPane();
    textPane.addInputMethodListener(new InputMethodListener() {

        public void caretPositionChanged(InputMethodEvent event) {

        }

        public void inputMethodTextChanged(InputMethodEvent event) {
            textPane.setCaretPosition(document.getLength() + 1);
        }
    });
    textPane.setEditable(false);
    textPane.setOpaque(false);
    textPane.setForeground(Color.BLACK);
    scrollPane.setViewportView(textPane);
    document = textPane.getStyledDocument();

    document.addDocumentListener(new DocumentListener() {

        @Override
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

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

        @Override
        public void changedUpdate(DocumentEvent e) {
            if (e.getDocument() == document) {
                textPane.setCaretPosition(document.getLength());
            }
        }
    });

    JPanel buttonPanel = new JPanel();
    contentPane.add(buttonPanel, BorderLayout.SOUTH);
    buttonPanel.setLayout(new BorderLayout(0, 0));

    JLabel lblTipsLabel = new JLabel(
            "Tips\uFF1A\u6587\u4EF6\u4FDD\u5B58\u683C\u5F0Fcsv\u53EF\u7528Excel\u6253\u5F00");
    lblTipsLabel.setForeground(Color.BLUE);
    buttonPanel.add(lblTipsLabel, BorderLayout.WEST);

    JPanel panel = new JPanel();
    buttonPanel.add(panel, BorderLayout.CENTER);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    JButton btnRetrieve = new JButton("\u624B\u52A8\u83B7\u53D6\u6570\u636E");
    panel.add(btnRetrieve);
    btnRetrieve.setVerticalAlignment(SwingConstants.BOTTOM);

    JButton btnNewButton = new JButton("\u5173\u4E8E");
    btnNewButton.setToolTipText("\u5173\u4E8E");
    btnNewButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JTextArea textArea = new JTextArea(
                    "\n        csv\n\n        smartstudio@foxmail.com");
            textArea.setColumns(35);
            textArea.setRows(6);
            textArea.setLineWrap(true);// 
            textArea.setEditable(false);// 
            textArea.setOpaque(false);
            JOptionPane.showMessageDialog(contentPane, textArea, "", JOptionPane.PLAIN_MESSAGE);
        }
    });

    JButton btnSetting = new JButton("\u8BBE\u7F6E");
    btnSetting.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            Point parentPos = refSelf.getLocation();

            AqiSettingDialog settingDialog = new AqiSettingDialog(refSelf, pm25InDetailJob.getAqiParser());
            settingDialog.setModal(true);
            settingDialog.setLocation(parentPos.x + 100, parentPos.y + 150);
            settingDialog.init();
            settingDialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
            settingDialog.setVisible(true);
        }
    });

    JButton btnExportDir = new JButton("\u67E5\u770B\u6570\u636E");
    btnExportDir.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            try {

                String[] cmd = new String[5];

                String filePath = pm25InDetailJob.getAqiParser().getFilePath();
                File file = new File(filePath);
                if (!file.exists()) {
                    FileUtil.makeDir(file);
                }
                if (!file.isDirectory()) {
                    JOptionPane.showMessageDialog(contentPane, "", "",
                            JOptionPane.ERROR_MESSAGE);
                    return;
                }

                cmd[0] = "cmd";
                cmd[1] = "/c";
                cmd[2] = "start";
                cmd[3] = " ";
                cmd[4] = pm25InDetailJob.getAqiParser().getFilePath();

                Runtime.getRuntime().exec(cmd);

            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    });
    panel.add(btnExportDir);
    panel.add(btnSetting);
    panel.add(btnNewButton);
    btnRetrieve.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!isRetrieving) {
                isRetrieving = true;
                Thread firstRun = new Thread(new Runnable() {

                    @Override
                    public void run() {
                        pm25InDetailJob.refresh();
                        isRetrieving = false;
                    }
                });

                firstRun.start();
            }
        }
    });

    init();
}

From source file:filterviewplugin.FilterViewSettingsTab.java

public JPanel createSettingsPanel() {
    final EnhancedPanelBuilder panelBuilder = new EnhancedPanelBuilder(FormFactory.RELATED_GAP_COLSPEC.encode()
            + ',' + FormFactory.PREF_COLSPEC.encode() + ',' + FormFactory.RELATED_GAP_COLSPEC.encode() + ','
            + FormFactory.PREF_COLSPEC.encode() + ", fill:default:grow");
    final CellConstraints cc = new CellConstraints();

    final JLabel label = new JLabel(mLocalizer.msg("daysToShow", "Days to show"));

    panelBuilder.addRow();/* w  w w.j  a  v a  2  s .  c om*/
    panelBuilder.add(label, cc.xy(2, panelBuilder.getRow()));

    final SpinnerNumberModel model = new SpinnerNumberModel(3, 1, 7, 1);
    mSpinner = new JSpinner(model);
    mSpinner.setValue(mSettings.getDays());
    panelBuilder.add(mSpinner, cc.xy(4, panelBuilder.getRow()));

    panelBuilder.addParagraph(mLocalizer.msg("filters", "Filters to show"));

    mFilterList = new SelectableItemList(mSettings.getActiveFilterNames(),
            FilterViewSettings.getAvailableFilterNames());
    mIcons.clear();
    for (String filterName : FilterViewSettings.getAvailableFilterNames()) {
        mIcons.put(filterName, mSettings.getFilterIconName(mSettings.getFilter(filterName)));
    }
    mFilterList.addCenterRendererComponent(String.class, new SelectableItemRendererCenterComponentIf() {
        private DefaultListCellRenderer mRenderer = new DefaultListCellRenderer();

        public void calculateSize(JList list, int index, JPanel contentPane) {
        }

        public JPanel createCenterPanel(JList list, Object value, int index, boolean isSelected,
                boolean isEnabled, JScrollPane parentScrollPane, int leftColumnWidth) {
            DefaultListCellRenderer label = (DefaultListCellRenderer) mRenderer
                    .getListCellRendererComponent(list, value, index, isSelected, false);
            String filterName = value.toString();
            String iconFileName = mIcons.get(filterName);
            Icon icon = null;
            if (!StringUtils.isEmpty(iconFileName)) {
                try {
                    icon = FilterViewPlugin.getInstance().getIcon(
                            FilterViewSettings.getIconDirectoryName() + File.separatorChar + iconFileName);
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                label.setIcon(icon);
            }
            String text = filterName;
            if (icon == null) {
                text += " (" + mLocalizer.msg("noIcon", "no icon") + ')';
            }
            label.setText(text);
            label.setHorizontalAlignment(SwingConstants.LEADING);
            label.setVerticalAlignment(SwingConstants.CENTER);
            label.setOpaque(false);

            JPanel panel = new JPanel(new BorderLayout());
            if (isSelected && isEnabled) {
                panel.setOpaque(true);
                panel.setForeground(list.getSelectionForeground());
                panel.setBackground(list.getSelectionBackground());
            } else {
                panel.setOpaque(false);
                panel.setForeground(list.getForeground());
                panel.setBackground(list.getBackground());
            }
            panel.add(label, BorderLayout.WEST);
            return panel;
        }
    });

    panelBuilder.addGrowingRow();
    panelBuilder.add(mFilterList, cc.xyw(2, panelBuilder.getRow(), panelBuilder.getColumnCount() - 1));

    panelBuilder.addRow();
    mFilterButton = new JButton(mLocalizer.msg("changeIcon", "Change icon"));
    mFilterButton.setEnabled(false);
    panelBuilder.add(mFilterButton, cc.xyw(2, panelBuilder.getRow(), 1));

    mRemoveButton = new JButton(mLocalizer.msg("deleteIcon", "Remove icon"));
    mRemoveButton.setEnabled(false);
    panelBuilder.add(mRemoveButton, cc.xyw(4, panelBuilder.getRow(), 1));

    mFilterButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SelectableItem item = (SelectableItem) mFilterList.getSelectedValue();
            String filterName = (String) item.getItem();
            chooseIcon(filterName);
        }
    });

    mFilterList.addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            mFilterButton.setEnabled(mFilterList.getSelectedValue() != null);
            mRemoveButton.setEnabled(mFilterButton.isEnabled());
        }
    });

    mRemoveButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SelectableItem item = (SelectableItem) mFilterList.getSelectedValue();
            String filterName = (String) item.getItem();
            mIcons.put(filterName, "");
            mFilterList.updateUI();
        }
    });

    return panelBuilder.getPanel();
}

From source file:playground.sergioo.workplaceCapacities2012.gui.ClustersWindow.java

public ClustersWindow(String title, List<CentroidCluster<PointPerson>> clusters) {
    setTitle(title);/* www .j  a v  a 2 s  . com*/
    setDefaultCloseOperation(HIDE_ON_CLOSE);
    this.setLocation(0, 0);
    this.setLayout(new BorderLayout());
    layersPanels.put(PanelIds.ONE, new ClustersPanel(this, clusters));
    this.add(layersPanels.get(PanelIds.ONE), BorderLayout.CENTER);
    option = Options.ZOOM;
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(Options.values().length, 1));
    for (Options option : Options.values()) {
        JButton optionButton = new JButton(option.getCaption());
        optionButton.setActionCommand(option.getCaption());
        optionButton.addActionListener(this);
        buttonsPanel.add(optionButton);
    }
    this.add(buttonsPanel, BorderLayout.EAST);
    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new BorderLayout());
    readyButton = new JButton("Ready to exit");
    readyButton.addActionListener(this);
    readyButton.setActionCommand(READY_TO_EXIT);
    infoPanel.add(readyButton, BorderLayout.WEST);
    JPanel labelsPanel = new JPanel();
    labelsPanel.setLayout(new GridLayout(1, Labels.values().length));
    labelsPanel.setBorder(new TitledBorder("Information"));
    labels = new JTextField[Labels.values().length];
    for (int i = 0; i < Labels.values().length; i++) {
        labels[i] = new JTextField("");
        labels[i].setEditable(false);
        labels[i].setBackground(null);
        labels[i].setBorder(null);
        labelsPanel.add(labels[i]);
    }
    infoPanel.add(labelsPanel, BorderLayout.CENTER);
    JPanel coordsPanel = new JPanel();
    coordsPanel.setLayout(new GridLayout(1, 2));
    coordsPanel.setBorder(new TitledBorder("Coordinates"));
    coordsPanel.add(lblCoords[0]);
    coordsPanel.add(lblCoords[1]);
    infoPanel.add(coordsPanel, BorderLayout.EAST);
    this.add(infoPanel, BorderLayout.SOUTH);
    pack();
}

From source file:org.rdv.ui.ConsoleDialog.java

public ConsoleDialog(JDialog owner) {
    super(owner);

    setName("consoleDialog");

    setDefaultCloseOperation(AboutDialog.DISPOSE_ON_CLOSE);

    JPanel container = new JPanel();
    container.setLayout(new BorderLayout());
    container.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    setContentPane(container);/* ww w .j a va  2s.  co  m*/

    InputMap inputMap = container.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    ActionMap actionMap = container.getActionMap();

    Action disposeAction = new AbstractAction() {
        /** serialized version identifier */
        private static final long serialVersionUID = 4380189911762232261L;

        public void actionPerformed(ActionEvent ae) {
            dispose();
        }
    };

    Action copyAction = new AbstractAction() {

        /** serialized version identifier */
        private static final long serialVersionUID = 2596081241883913660L;

        public void actionPerformed(ActionEvent e) {
            textArea.selectAll();
            textArea.copy();
        }
    };

    //    Action scrollLockAction = new AbstractAction() {
    //      /** serialized version identifier */
    //      private static final long serialVersionUID = -8089076016097529064L;
    //
    //      public void actionPerformed(ActionEvent e) {
    //        //toggle scroll lock
    //        scrollLock_=!scrollLock_;
    //      }
    //    };

    disposeAction.putValue(Action.NAME, "OK");
    inputMap.put(KeyStroke.getKeyStroke("ENTER"), "dispose");
    inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), "dispose");
    actionMap.put("dispose", disposeAction);
    copyAction.putValue(Action.NAME, "Copy");
    actionMap.put("copy", copyAction);
    //    actionMap.put("scroll lock", scrollLockAction);
    //    scrollLockAction.putValue(Action.NAME, "Scroll Lock");

    textArea = new JTextArea();
    textArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    textArea.setBackground(Color.WHITE);
    textArea.setForeground(Color.BLACK);
    textArea.setEditable(false);
    textArea.setLineWrap(false);

    Iterator<String> msgIt = messageBuffer.getMessages().iterator();

    //add all the messages in the buffer to this point
    while (msgIt.hasNext()) {
        addMessage(msgIt.next());
    }

    JScrollPane scrollPane = new JScrollPane(textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setPreferredSize(new Dimension(640, 480));
    container.add(scrollPane, BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BorderLayout());
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JButton okButton = new JButton(disposeAction);
    buttonPanel.add(okButton, BorderLayout.EAST);

    JPanel leftBtnsPanel = new JPanel();
    leftBtnsPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    buttonPanel.add(leftBtnsPanel, BorderLayout.WEST);

    JButton copyButton = new JButton(copyAction);
    leftBtnsPanel.add(copyButton);

    //    JButton scrollLockButton = new JButton(scrollLockAction);
    //    leftBtnsPanel.add(scrollLockButton);

    container.add(buttonPanel, BorderLayout.SOUTH);

    // inject resources from the properties for this component
    ResourceMap resourceMap = RDV.getInstance().getContext().getResourceMap(getClass());
    resourceMap.injectComponents(this);

    pack();
    okButton.requestFocusInWindow();
    setLocationByPlatform(true);
    setVisible(true);

    messageBuffer.addObserver(this);
}

From source file:playground.sergioo.facilitiesGenerator2012.gui.ClustersWindow.java

public ClustersWindow(String title, List<CentroidCluster<PointPerson>> clusters, int numTotalPoints) {
    setTitle(title);//from  w w  w . ja v a 2s  .com
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setLocation(0, 0);
    this.setLayout(new BorderLayout());
    layersPanels.put(PanelIds.ONE, new ClustersPanel(this, clusters, numTotalPoints));
    this.add(layersPanels.get(PanelIds.ONE), BorderLayout.CENTER);
    option = Options.ZOOM;
    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new GridLayout(Options.values().length, 1));
    for (Options option : Options.values()) {
        JButton optionButton = new JButton(option.getCaption());
        optionButton.setActionCommand(option.getCaption());
        optionButton.addActionListener(this);
        buttonsPanel.add(optionButton);
    }
    this.add(buttonsPanel, BorderLayout.EAST);
    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new BorderLayout());
    readyButton = new JButton("Ready to exit");
    readyButton.addActionListener(this);
    readyButton.setActionCommand(READY_TO_EXIT);
    infoPanel.add(readyButton, BorderLayout.WEST);
    JPanel labelsPanel = new JPanel();
    labelsPanel.setLayout(new GridLayout(1, Labels.values().length));
    labelsPanel.setBorder(new TitledBorder("Information"));
    labels = new JTextField[Labels.values().length];
    for (int i = 0; i < Labels.values().length; i++) {
        labels[i] = new JTextField("");
        labels[i].setEditable(false);
        labels[i].setBackground(null);
        labels[i].setBorder(null);
        labelsPanel.add(labels[i]);
    }
    infoPanel.add(labelsPanel, BorderLayout.CENTER);
    JPanel coordsPanel = new JPanel();
    coordsPanel.setLayout(new GridLayout(1, 2));
    coordsPanel.setBorder(new TitledBorder("Coordinates"));
    coordsPanel.add(lblCoords[0]);
    coordsPanel.add(lblCoords[1]);
    infoPanel.add(coordsPanel, BorderLayout.EAST);
    this.add(infoPanel, BorderLayout.SOUTH);
    pack();
}

From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformHistogramChart.java

protected void setMixPanel() {

    dataPanel2.removeAll();/*  w w  w  . j  a v  a  2  s .  co m*/
    graphPanel2.removeAll();

    chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 3));
    graphPanel2.add(chartPanel);
    graphPanel2.validate();

    dataPanel2.add(new JLabel(" "));
    dataPanel2.add(new JLabel("Data"));
    JScrollPane dt = new JScrollPane(dataTable);
    dt.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y * 3 / 8));

    dataPanel2.add(dt);
    JScrollPane st = new JScrollPane(summaryPanel);
    st.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 6));
    dataPanel2.add(st);
    st.validate();

    dataPanel2.add(new JLabel(" "));
    dataPanel2.add(new JLabel("Mapping"));
    mapPanel.setPreferredSize(new Dimension(CHART_SIZE_X / 3, CHART_SIZE_Y / 2));
    dataPanel2.add(mapPanel);

    dataPanel2.validate();

    mixPanel.removeAll();
    mixPanel.add(graphPanel2, BorderLayout.WEST);
    mixPanel.add(new JScrollPane(dataPanel2), BorderLayout.CENTER);
    mixPanel.validate();
}

From source file:press.gfw.Windows.java

private void initBorder() {

    // //from  ww w  .  ja v  a 2  s.c  o m
    add(new JLabel(), BorderLayout.EAST);

    add(new JLabel(), BorderLayout.NORTH);

    add(new JLabel(), BorderLayout.WEST);

}