List of usage examples for java.awt BorderLayout EAST
String EAST
To view the source code for java.awt BorderLayout EAST.
Click Source Link
From source file:net.sf.jabref.gui.journals.ManageJournalsPanel.java
public ManageJournalsPanel(final JabRefFrame frame) { this.frame = frame; personalFile.setEditable(false);/*from w ww .j a v a 2s . c om*/ ButtonGroup group = new ButtonGroup(); group.add(newFile); group.add(oldFile); addExtPan.setLayout(new BorderLayout()); JButton addExt = new JButton(IconTheme.JabRefIcon.ADD.getIcon()); addExtPan.add(addExt, BorderLayout.EAST); addExtPan.setToolTipText(Localization.lang("Add")); FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:200dlu:grow, 4dlu, fill:pref", "pref, pref, pref, 20dlu, 20dlu, fill:200dlu, 4dlu, pref"); FormBuilder builder = FormBuilder.create().layout(layout); builder.addSeparator(Localization.lang("Built-in journal list")).xyw(2, 1, 6); JLabel description = new JLabel( "<HTML>" + Localization.lang("JabRef includes a built-in list of journal abbreviations.") + "<br>" + Localization.lang( "You can add additional journal names by setting up a personal journal list,<br>as " + "well as linking to external journal lists.") + "</HTML>"); description.setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); builder.add(description).xyw(2, 2, 6); JButton viewBuiltin = new JButton(Localization.lang("View")); builder.add(viewBuiltin).xy(7, 2); builder.addSeparator(Localization.lang("Personal journal list")).xyw(2, 3, 6); builder.add(newFile).xy(3, 4); builder.add(newNameTf).xy(5, 4); JButton browseNew = new JButton(Localization.lang("Browse")); builder.add(browseNew).xy(7, 4); builder.add(oldFile).xy(3, 5); builder.add(personalFile).xy(5, 5); JButton browseOld = new JButton(Localization.lang("Browse")); builder.add(browseOld).xy(7, 5); userPanel.setLayout(new BorderLayout()); builder.add(userPanel).xyw(2, 6, 4); ButtonStackBuilder butBul = new ButtonStackBuilder(); butBul.addButton(add); butBul.addButton(remove); butBul.addGlue(); builder.add(butBul.getPanel()).xy(7, 6); builder.addSeparator(Localization.lang("External files")).xyw(2, 8, 6); externalFilesPanel.setLayout(new BorderLayout()); setLayout(new BorderLayout()); builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(builder.getPanel(), BorderLayout.NORTH); add(externalFilesPanel, BorderLayout.CENTER); ButtonBarBuilder bb = new ButtonBarBuilder(); bb.addGlue(); JButton ok = new JButton(Localization.lang("OK")); bb.addButton(ok); JButton cancel = new JButton(Localization.lang("Cancel")); bb.addButton(cancel); bb.addUnrelatedGap(); JButton help = new HelpAction(HelpFile.JOURNAL_ABBREV).getHelpButton(); bb.addButton(help); bb.addGlue(); bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); dialog = new JDialog(frame, Localization.lang("Journal abbreviations"), false); dialog.getContentPane().add(this, BorderLayout.CENTER); dialog.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); // Set up panel for editing a single journal, to be used in a dialog box: FormLayout layout2 = new FormLayout("right:pref, 4dlu, fill:180dlu", "p, 2dlu, p"); FormBuilder builder2 = FormBuilder.create().layout(layout2); builder2.add(Localization.lang("Journal name")).xy(1, 1); builder2.add(nameTf).xy(3, 1); builder2.add(Localization.lang("ISO abbreviation")).xy(1, 3); builder2.add(abbrTf).xy(3, 3); journalEditPanel = builder2.getPanel(); viewBuiltin.addActionListener(e -> { JTable table = new JTable(JournalAbbreviationsUtil.getTableModel(Globals.journalAbbreviationLoader .getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs)) .getAbbreviations())); JScrollPane pane = new JScrollPane(table); JOptionPane.showMessageDialog(null, pane, Localization.lang("Journal list preview"), JOptionPane.INFORMATION_MESSAGE); }); browseNew.addActionListener(e -> { Path old = null; if (!newNameTf.getText().isEmpty()) { old = Paths.get(newNameTf.getText()); } String name = FileDialogs.getNewFile(frame, old.toFile(), null, JFileChooser.SAVE_DIALOG, false); if (name != null) { newNameTf.setText(name); newFile.setSelected(true); } }); browseOld.addActionListener(e -> { Path old = null; if (!personalFile.getText().isEmpty()) { old = Paths.get(personalFile.getText()); } String name = FileDialogs.getNewFile(frame, old.toFile(), null, JFileChooser.OPEN_DIALOG, false); if (name != null) { personalFile.setText(name); oldFile.setSelected(true); oldFile.setEnabled(true); setupUserTable(); } }); ok.addActionListener(e -> { if (readyToClose()) { storeSettings(); dialog.dispose(); } }); Action cancelAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }; cancel.addActionListener(cancelAction); add.addActionListener(tableModel); remove.addActionListener(tableModel); addExt.addActionListener(e -> { externals.add(new ExternalFileEntry()); buildExternalsPanel(); }); // Key bindings: ActionMap am = getActionMap(); InputMap im = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close"); am.put("close", cancelAction); int xSize = getPreferredSize().width; dialog.setSize(xSize + 10, 700); }
From source file:com.floreantpos.ui.views.order.modifier.TicketItemModifierTableView.java
private void initComponents() { titledBorder.setTitle(modifierSelectionModel.getTicketItem().getName()); titledBorder.setTitleJustification(TitledBorder.CENTER); setBorder(border);//from www .jav a2s . c o m setLayout(new java.awt.BorderLayout(5, 5)); ticketItemActionPanel = new com.floreantpos.swing.TransparentPanel(); //btnDecreaseAmount = new com.floreantpos.swing.PosButton(); btnScrollDown = new com.floreantpos.swing.PosButton(); modifierViewerTable = new com.floreantpos.ui.views.order.modifier.ModifierViewerTable( modifierSelectionModel.getTicketItem()); ticketScrollPane = new PosScrollPane(modifierViewerTable); ticketScrollPane.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); ticketScrollPane.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER); ticketScrollPane.setPreferredSize(new java.awt.Dimension(180, 200)); createTicketActionPanel(); createTicketItemControlPanel(); JPanel centerPanel = new JPanel(new BorderLayout(5, 5)); centerPanel.add(ticketScrollPane); centerPanel.add(createItemDescriptionPanel(), BorderLayout.NORTH); add(centerPanel); add(ticketActionPanel, BorderLayout.SOUTH); centerPanel.add(ticketItemActionPanel, BorderLayout.EAST); modifierViewerTable.getRenderer().setInTicketScreen(true); modifierViewerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { updateSelectionView(); } } }); modifierViewerTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { Object selected = modifierViewerTable.getSelected(); if (!(selected instanceof ITicketItem)) { return; } ITicketItem item = (ITicketItem) selected; Boolean printedToKitchen = item.isPrintedToKitchen(); btnDelete.setEnabled(!printedToKitchen); } }); setPreferredSize(new java.awt.Dimension(360, 463)); }
From source file:projects.hip.exec.HrDiagram.java
/** * Main constructor.//from ww w . java 2 s. co m */ public HrDiagram() { hipStars = HipUtils.loadHipCatalogue(); method = METHOD.NAIVE; fMax = 1.0; final JComboBox<METHOD> methodComboBox = new JComboBox<METHOD>(METHOD.values()); methodComboBox.setSelectedItem(method); methodComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { method = (METHOD) methodComboBox.getSelectedItem(); updateChart(); } }); final JSlider fSlider = GuiUtil.buildSlider(0.0, 2.0, 5, "%3.3f"); fSlider.setValue((int) Math.rint(100.0 * fMax / 2.0)); final JLabel fLabel = new JLabel(getFLabel()); // Create a change listener fot these ChangeListener cl = new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (source == fSlider) { // Compute fractional parallax error from slider position double newF = (2.0 * source.getValue() / 100.0); fMax = newF; fLabel.setText(getFLabel()); } updateChart(); } }; fSlider.addChangeListener(cl); // Add a bit of padding to space things out fSlider.setBorder(new EmptyBorder(5, 5, 5, 5)); // Present controls below the HR diagram JPanel controls = new JPanel(new GridLayout(2, 2)); controls.add(new JLabel("Distance estimation method:")); controls.add(methodComboBox); controls.add(fLabel); controls.add(fSlider); // Initialise the ChartPanel updateChart(); // Build the panel contents setLayout(new BorderLayout()); add(hrDiagPanel, BorderLayout.WEST); add(dDistPanel, BorderLayout.EAST); add(controls, BorderLayout.SOUTH); }
From source file:net.sf.mzmine.modules.visualization.intensityplot.IntensityPlotWindow.java
public IntensityPlotWindow(ParameterSet parameters) { PeakList peakList = parameters.getParameter(IntensityPlotParameters.peakList).getValue() .getMatchingPeakLists()[0];//from ww w .java2 s. c om String title = "Intensity plot [" + peakList + "]"; String xAxisLabel = parameters.getParameter(IntensityPlotParameters.xAxisValueSource).getValue().toString(); String yAxisLabel = parameters.getParameter(IntensityPlotParameters.yAxisValueSource).getValue().toString(); // create dataset dataset = new IntensityPlotDataset(parameters); // create new JFreeChart logger.finest("Creating new chart instance"); Object xAxisValueSource = parameters.getParameter(IntensityPlotParameters.xAxisValueSource).getValue(); boolean isCombo = (xAxisValueSource instanceof ParameterWrapper) && (!(((ParameterWrapper) xAxisValueSource).getParameter() instanceof DoubleParameter)); if ((xAxisValueSource == IntensityPlotParameters.rawDataFilesOption) || isCombo) { chart = ChartFactory.createLineChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // set renderer StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer(false, true); renderer.setBaseStroke(new BasicStroke(2)); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.white); // set tooltip generator CategoryToolTipGenerator toolTipGenerator = new IntensityPlotTooltipGenerator(); renderer.setBaseToolTipGenerator(toolTipGenerator); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); } else { chart = ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); XYErrorRenderer renderer = new XYErrorRenderer(); renderer.setBaseStroke(new BasicStroke(2)); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.white); // set tooltip generator XYToolTipGenerator toolTipGenerator = new IntensityPlotTooltipGenerator(); renderer.setBaseToolTipGenerator(toolTipGenerator); } chart.setBackgroundPaint(Color.white); // create chart JPanel ChartPanel chartPanel = new ChartPanel(chart); add(chartPanel, BorderLayout.CENTER); IntensityPlotToolBar toolBar = new IntensityPlotToolBar(this); add(toolBar, BorderLayout.EAST); // disable maximum size (we don't want scaling) chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); // set title properties TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); LegendTitle legend = chart.getLegend(); legend.setItemFont(legendFont); legend.setBorder(0, 0, 0, 0); Plot plot = chart.getPlot(); // set shape provider IntensityPlotDrawingSupplier shapeSupplier = new IntensityPlotDrawingSupplier(); plot.setDrawingSupplier(shapeSupplier); // set y axis properties NumberAxis yAxis; if (plot instanceof CategoryPlot) yAxis = (NumberAxis) ((CategoryPlot) plot).getRangeAxis(); else yAxis = (NumberAxis) ((XYPlot) plot).getRangeAxis(); NumberFormat yAxisFormat = MZmineCore.getConfiguration().getIntensityFormat(); if (parameters.getParameter(IntensityPlotParameters.yAxisValueSource).getValue() == YAxisValueSource.RT) yAxisFormat = MZmineCore.getConfiguration().getRTFormat(); yAxis.setNumberFormatOverride(yAxisFormat); setTitle(title); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBackground(Color.white); // Add the Windows menu JMenuBar menuBar = new JMenuBar(); menuBar.add(new WindowsMenu()); setJMenuBar(menuBar); pack(); // get the window settings parameter ParameterSet paramSet = MZmineCore.getConfiguration().getModuleParameters(IntensityPlotModule.class); WindowSettingsParameter settings = paramSet.getParameter(IntensityPlotParameters.windowSettings); // update the window and listen for changes settings.applySettingsToWindow(this); this.addComponentListener(settings); }
From source file:analysis.postRun.PostRunWindow.java
/** * Constructor - creates window and tabs. *//*ww w . j av a 2s . c o m*/ private PostRunWindow() { dcLegend = false; stats = false; readStats = false; save = false; // Create frame MainFrame = new JFrame("Cloudsim Post-Run Analysis"); MainFrame.setSize(1150, 768); MainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //MainFrame.addComponentListener(this); // Create panel MainPanel = new JPanel(); MainPanel.setLayout(new BorderLayout()); MainFrame.add(MainPanel, BorderLayout.CENTER); // Create button panel ButtonPanel = new JPanel(); ButtonPanel.setLayout(new BorderLayout()); MainFrame.add(ButtonPanel, BorderLayout.NORTH); // Create "change log" button JButton fileButton = new JButton("Change log"); fileButton.addActionListener(this); ButtonPanel.add(fileButton, BorderLayout.WEST); // Create "Compare multiple logs" button JButton compButton = new JButton("Compare multiple logs"); compButton.addActionListener(this); ButtonPanel.add(compButton, BorderLayout.CENTER); // Create "Save Charts" button JButton saveButton = new JButton("Save Charts"); saveButton.addActionListener(this); ButtonPanel.add(saveButton, BorderLayout.EAST); // Find out which log file to look at & load the data failureSet = new DefaultXYDataset(); cpuSet = new DefaultXYDataset(); servSet = new DefaultXYDataset(); costSet = new DefaultXYDataset(); chooseFile1(); //getFileName(); getData(currFile); // Create tabs tabbedPane = new JTabbedPane(); failureTab(true); cpuTab(true); servTab(true); costTab(true); consistencyTab(true); tabbedPane.setSelectedIndex(0); // Add + show window MainPanel.add(tabbedPane, BorderLayout.CENTER); MainFrame.add(MainPanel, BorderLayout.CENTER); MainFrame.add(ButtonPanel, BorderLayout.NORTH); MainFrame.setLocationByPlatform(true); MainFrame.setVisible(true); }
From source file:net.sf.vfsjfilechooser.accessories.bookmarks.BookmarksManagerPanel.java
public BookmarksManagerPanel(BookmarksDialog parentDialog, VFSJFileChooser chooser) { this.parentDialog = parentDialog; this.chooser = chooser; model = new Bookmarks(); table = new JTable(model); scrollPane = new JScrollPane(table); table.setPreferredScrollableViewportSize(tableSize); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); bCancel = new JButton(VFSResources.getMessage("VFSJFileChooser.closeButtonText")); bOpen = new JButton(VFSResources.getMessage("VFSJFileChooser.openButtonText")); bOpen.setIcon(/*from ww w .j a v a 2 s .c o m*/ new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/document-open.png"))); bOpen.setHorizontalAlignment(SwingConstants.LEFT); bAdd = new JButton(VFSResources.getMessage("VFSJFileChooser.addButtonText")); bAdd.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/list-add.png"))); bAdd.setHorizontalAlignment(SwingConstants.LEFT); bEdit = new JButton(VFSResources.getMessage("VFSJFileChooser.editButtonText")); bEdit.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/book_edit.png"))); bEdit.setHorizontalAlignment(SwingConstants.LEFT); bDelete = new JButton(VFSResources.getMessage("VFSJFileChooser.deleteButtonText")); bDelete.setIcon( new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/list-remove.png"))); bDelete.setHorizontalAlignment(SwingConstants.LEFT); bMoveUp = new JButton(VFSResources.getMessage("VFSJFileChooser.moveUpButtonText")); bMoveUp.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/go-up.png"))); bMoveUp.setHorizontalAlignment(SwingConstants.LEFT); bMoveDown = new JButton(VFSResources.getMessage("VFSJFileChooser.moveDownButtonText")); bMoveDown.setIcon(new ImageIcon(getClass().getResource("/net/sf/vfsjfilechooser/plaf/icons/go-down.png"))); bMoveDown.setHorizontalAlignment(SwingConstants.LEFT); final ActionHandler ah = new ActionHandler(); bOpen.addActionListener(ah); bCancel.addActionListener(ah); bEdit.addActionListener(ah); bAdd.addActionListener(ah); bDelete.addActionListener(ah); bMoveUp.addActionListener(ah); bMoveDown.addActionListener(ah); final Box south = Box.createHorizontalBox(); south.add(Box.createHorizontalGlue()); south.add(bCancel); south.add(Box.createHorizontalGlue()); final JPanel buttons = new JPanel(new GridLayout(0, 1, 5, 5)); buttons.add(bAdd); buttons.add(bEdit); buttons.add(bDelete); buttons.add(bOpen); buttons.add(Box.createVerticalStrut(10)); buttons.add(bMoveUp); buttons.add(bMoveDown); JPanel east = new JPanel(); east.add(buttons, BorderLayout.NORTH); east.add(new JPanel(), BorderLayout.CENTER); // don't ask setLayout(new BorderLayout(10, 10)); add(scrollPane, BorderLayout.CENTER); add(south, BorderLayout.SOUTH); add(east, BorderLayout.EAST); setBorder(BorderFactory.createMatteBorder(10, 10, 10, 10, UIManager.getColor("Panel.background"))); }
From source file:org.kepler.gui.lsid.LSIDViewer.java
public void initialize(NamedObj no) { if (isDebugging) { log.debug("initialize( " + no.getName() + " " + no.getClass().getName() + " )"); }//from w w w. ja v a2 s.co m _no = no; JPanel layoutPanel = new JPanel(); layoutPanel.setLayout(new BorderLayout()); JPanel lsidPanel = new JPanel(); lsidPanel.setLayout(new BorderLayout()); JLabel lsidLabel = new JLabel("LSID:"); lsidPanel.add(lsidLabel, BorderLayout.WEST); _lsidField = new JTextField(""); _lsidField.setEditable(false); lsidPanel.add(_lsidField, BorderLayout.CENTER); JPanel dfPanel = new JPanel(); dfPanel.setLayout(new BorderLayout()); _derivedFromField = new JTextArea(""); _derivedFromField.setEditable(false); _derivedFromScrollPane = new JScrollPane(_derivedFromField); _derivedFromScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); _derivedFromScrollPane .setBorder( BorderFactory.createCompoundBorder( BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Derived From"), BorderFactory.createEmptyBorder(5, 5, 5, 5)), _derivedFromScrollPane.getBorder())); dfPanel.add(_derivedFromScrollPane, BorderLayout.CENTER); JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new BorderLayout()); String infStr = "Name: " + _no.getName(); JLabel objInfo = new JLabel(infStr); if (isEditingEnabled()) { bottomPanel.add(objInfo, BorderLayout.NORTH); } else { bottomPanel.add(objInfo, BorderLayout.CENTER); } JPanel buttonPanel = new JPanel(); if (isEditingEnabled()) { JButton newObjButton = new JButton("New Object ID"); newObjButton.addActionListener(this); buttonPanel.add(newObjButton); JButton revisionButton = new JButton("Roll Revision"); revisionButton.addActionListener(this); buttonPanel.add(revisionButton); } JButton refreshButton = new JButton("Refresh"); refreshButton.addActionListener(this); buttonPanel.add(refreshButton); bottomPanel.add(buttonPanel, BorderLayout.EAST); layoutPanel.add(lsidPanel, BorderLayout.NORTH); layoutPanel.add(dfPanel, BorderLayout.CENTER); layoutPanel.add(bottomPanel, BorderLayout.SOUTH); getContentPane().add(layoutPanel); refreshValues(); }
From source file:org.rimudb.editor.DescriptorEditor.java
/** * Constructor for DescriptorEditor.//from w w w . j a v a 2 s .co m */ public DescriptorEditor(RimuDBEditor rimuDBEditor) { super(); this.rimuDBEditor = rimuDBEditor; setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(0, 7, 7, 7)); // Load the illegal properties list. These are property names that // are not permitted because they are already used by a DataObject // or a superclass. illegalPropertiesList.add("class"); illegalPropertiesList.add("changedproperties"); illegalPropertiesList.add("database"); illegalPropertiesList.add("lockresult"); illegalPropertiesList.add("originalrecord"); illegalPropertiesList.add("primarykeylist"); illegalPropertiesList.add("record"); illegalPropertiesList.add("table"); illegalPropertiesList.add("tablemetadata"); illegalPropertiesList.add("adding"); illegalPropertiesList.add("modified"); illegalPropertiesList.add("noargsconstructorused"); illegalPropertiesList.add("isrecordconstructorused"); illegalPropertiesList.add("isvirtual"); JPanel descriptorPanel = new JPanel(); descriptorPanel.setLayout(new BorderLayout()); descriptorPanel.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 5)); descriptorPanel.add(createDefinitionPanel(), BorderLayout.NORTH); descriptorPanel.add(createColumnTablePanel(), BorderLayout.CENTER); descriptorPanel.add(createButtonPanel(), BorderLayout.EAST); add(descriptorPanel, BorderLayout.CENTER); setPreferredSize(new Dimension(750, 500)); }
From source file:com.igormaznitsa.jhexed.swing.editor.ui.MainForm.java
private static void setComponentForPosition(final JPanel panel, final UIComponentPosition position, final JComponent component) { if (component != null) { final Object layoutPosition; switch (position) { case BOTTOM_PANEL: layoutPosition = BorderLayout.SOUTH; break; case LEFT_PANEL: layoutPosition = BorderLayout.WEST; break; case RIGHT_PANEL: layoutPosition = BorderLayout.EAST; break; case TOP_PANEL: layoutPosition = BorderLayout.NORTH; break; default:// w ww. j a v a 2s .co m throw new Error("Unexpected position [" + position + ']'); } panel.add(component, layoutPosition); } }
From source file:au.org.ala.delta.intkey.ui.OpenDataSetDialog.java
public OpenDataSetDialog(Frame owner, List<Pair<String, String>> datasetIndexData, File startBrowseDirectory) { super(owner, true); setPreferredSize(new Dimension(450, 300)); ActionMap actionMap = Application.getInstance().getContext().getActionMap(this); ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(OpenDataSetDialog.class); resourceMap.injectFields(this); setTitle(title);//from w w w . j a va2 s. co m _selectedDatasetPath = null; _pnlList = new JPanel(); _pnlList.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(_pnlList, BorderLayout.CENTER); _pnlList.setLayout(new BorderLayout(0, 0)); _lblSelectByTitle = new JLabel(selectByTitleCaption); _pnlList.add(_lblSelectByTitle, BorderLayout.NORTH); _sclPnList = new JScrollPane(); _pnlList.add(_sclPnList, BorderLayout.CENTER); _listDatasetIndex = new JList(); _sclPnList.setViewportView(_listDatasetIndex); _pnlBottom = new JPanel(); _pnlBottom.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(_pnlBottom, BorderLayout.SOUTH); _pnlBottom.setLayout(new BorderLayout(0, 0)); _lblSelectByFileName = new JLabel(selectByFileCaption); _pnlBottom.add(_lblSelectByFileName, BorderLayout.NORTH); _pnlButtons = new JPanel(); _pnlButtons.setBorder(new EmptyBorder(10, 0, 0, 0)); _pnlBottom.add(_pnlButtons, BorderLayout.SOUTH); _btnOK = new JButton(); _btnOK.setAction(actionMap.get("OpenDataSetDialog_OK")); _pnlButtons.add(_btnOK); _btnCancel = new JButton(); _btnCancel.setAction(actionMap.get("OpenDataSetDialog_Cancel")); _pnlButtons.add(_btnCancel); _btnHelp = new JButton(); _btnHelp.setAction(actionMap.get("OpenDataSetDialog_Help")); _pnlButtons.add(_btnHelp); _pnlFile = new JPanel(); _pnlBottom.add(_pnlFile, BorderLayout.CENTER); _pnlFile.setLayout(new BorderLayout(0, 0)); _txtFldFileName = new JTextField(); _pnlFile.add(_txtFldFileName, BorderLayout.CENTER); _txtFldFileName.setColumns(10); _txtFldFileName.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { // Clear any selected item in the list of the text field is // modified. _listDatasetIndex.clearSelection(); } @Override public void keyReleased(KeyEvent e) { // do nothing } @Override public void keyPressed(KeyEvent e) { // do nothing } }); _btnBrowse = new JButton(); _btnBrowse.setAction(actionMap.get("OpenDataSetDialog_Browse")); _pnlFile.add(_btnBrowse, BorderLayout.EAST); DefaultListModel model = new DefaultListModel(); for (Pair<String, String> datasetInfo : datasetIndexData) { model.addElement(datasetInfo); } _listDatasetIndex.setModel(model); _listDatasetIndex.setCellRenderer(new DatasetIndexCellRenderer()); _listDatasetIndex.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { // Clear any filename in the text field if an item is selected // from the text box. _txtFldFileName.setText(null); } }); _startBrowseDirectory = startBrowseDirectory; }