List of usage examples for javax.swing Box add
public Component add(Component comp)
From source file:com.isencia.passerelle.hmi.specific.HMITest.java
/** * @param frame/*from www .j a v a2s . c o m*/ */ @Override protected void showModelForm(final String modelKey) { clearModelForms(); if ("HelloWorld".equals(modelKey)) { frame.getContentPane().setLayout(new BorderLayout()); final Box formBox = Box.createVerticalBox(); final FormField valueField = new FormField(); valueField.setEditable(true); formBox.add(new FormEntry(new JLabel(VALUE_FIELD), (FormField) registerBinding(VALUE_FIELD, valueField, (ParameterToWidgetBinder) new ParameterToTextFieldBinder()))); frame.getContentPane().add(formBox, BorderLayout.NORTH); } else if ("LaunchNotepad".equals(modelKey)) { frame.getContentPane().setLayout(new BorderLayout()); final Box formBox = Box.createVerticalBox(); final FormField cmdField = new FormField(); cmdField.setEditable(true); formBox.add(new FormEntry(new JLabel(COMMAND_FIELD), (FormField) registerBinding(COMMAND_FIELD, cmdField, (ParameterToWidgetBinder) new ParameterToTextFieldBinder()))); frame.getContentPane().add(formBox, BorderLayout.NORTH); } else if ("test1_samba".equals(modelKey)) { frame.getContentPane().add(getEditSequencePanelRM4()); } else if ("test-loop".equals(modelKey)) { frame.getContentPane().setLayout(new BorderLayout()); final Box formBox = Box.createVerticalBox(); final FormField valueField = new FormField(); valueField.setEditable(true); formBox.add(new FormEntry(new JLabel(VALUE_FIELD), (FormField) registerBinding(VALUE_FIELD, valueField, (ParameterToWidgetBinder) new ParameterToTextFieldBinder()))); final FormField delayField = new FormField(); delayField.setEditable(true); formBox.add(new FormEntry(new JLabel(DELAYTIME_FIELD), (FormField) registerBinding(DELAYTIME_FIELD, delayField, (ParameterToWidgetBinder) new ParameterToTextFieldBinder()))); final FormField loopCountField = new FormField(); loopCountField.setEditable(true); formBox.add(new FormEntry(new JLabel(LOOPCOUNT_FIELD), (FormField) registerBinding(LOOPCOUNT_FIELD, loopCountField, (ParameterToWidgetBinder) new ParameterToTextFieldBinder()))); frame.getContentPane().add(formBox, BorderLayout.NORTH); } frame.show(); }
From source file:brainflow.app.presentation.controls.FileObjectGroupSelector.java
public FileObjectGroupSelector(FileObject root) throws FileSystemException { if (root.getType() != FileType.FOLDER) { throw new IllegalArgumentException("root file must be a directory"); }/*from ww w. j a v a 2s . co m*/ rootFolder = root; explorer = new FileExplorer(rootFolder); explorer.getJTree().setRootVisible(false); explorer.getJTree().getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); setLayout(new BorderLayout()); Box topPanel = new Box(BoxLayout.X_AXIS); topPanel.setBorder(BorderFactory.createEmptyBorder(8, 12, 8, 8)); topPanel.add(regexLabel); topPanel.add(regexField); topPanel.add(Box.createHorizontalStrut(4)); topPanel.add(searchType); add(topPanel, BorderLayout.NORTH); //JPanel mainPanel = new JPanel(); //MigLayout layout = new MigLayout(""); // mainPanel.setLayout(layout); //add(regexLabel); //add(regexField, "gap left 0, growx"); //add(findButton, "align right, wrap"); //add(searchType, "wrap"); //add(createSplitPane(), "span 3, grow, wrap"); add(createSplitPane(), BorderLayout.CENTER); depthSpinner.setMaximumSize(new Dimension(50, 200)); depthSpinner.setModel(new SpinnerNumberModel(recursiveDepth, 0, 5, 1)); JPanel bottomPanel = new JPanel(); MigLayout layout = new MigLayout("", "[][grow]", "[][]"); bottomPanel.setLayout(layout); //bottomPanel.setBorder(BorderFactory.createEmptyBorder(4,12,8,8)); bottomPanel.add(new JLabel("Root Folder: ")); rootField.setEditable(false); rootField.setText(root.getName().getBaseName()); bottomPanel.add(rootField, "wrap, width 150:150:150"); bottomPanel.add(new JLabel("Search Depth: "), "gap top 8"); bottomPanel.add(depthSpinner, "width 35:45:55, wrap"); add(bottomPanel, BorderLayout.SOUTH); explorer.addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getPath(); Object[] obj = path.getPath(); Object lastNode = obj[obj.length - 1]; if (lastNode instanceof FileExplorer.FileObjectNode) { FileExplorer.FileObjectNode fnode = (FileExplorer.FileObjectNode) lastNode; try { if (fnode.getFileObject().getType() == FileType.FOLDER) { rootField.setText(fnode.getFileObject().getName().getBaseName()); rootFolder = fnode.getFileObject(); updateFileList(); } } catch (FileSystemException ex) { throw new RuntimeException(ex); } } } }); depthSpinner.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { recursiveDepth = ((Number) depthSpinner.getValue()).intValue(); updateFileList(); } }); regexField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateFileList(); System.out.println(Arrays.toString(explorer.getSelectedNodes().toArray())); } }); }
From source file:sim.util.media.chart.BoxPlotGenerator.java
protected void buildGlobalAttributes(LabelledList list) { // create the chart ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(false); ((CategoryPlot) (chart.getPlot())).setRangeGridlinePaint(new Color(200, 200, 200)); xLabel = new PropertyField() { public String newValue(String newValue) { setXAxisLabel(newValue);//from ww w.j av a2 s. c o m getChartPanel().repaint(); return newValue; } }; xLabel.setValue(getXAxisLabel()); list.add(new JLabel("X Label"), xLabel); yLabel = new PropertyField() { public String newValue(String newValue) { setYAxisLabel(newValue); getChartPanel().repaint(); return newValue; } }; yLabel.setValue(getYAxisLabel()); list.add(new JLabel("Y Label"), yLabel); yLog = new JCheckBox(); yLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (yLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(yLabel.getValue()); logAxis.setStrictValuesFlag(false); ((CategoryPlot) (chart.getPlot())).setRangeAxis(logAxis); } else ((CategoryPlot) (chart.getPlot())).setRangeAxis(new NumberAxis(yLabel.getValue())); } }); list.add(new JLabel("Y Log Axis"), yLog); final JCheckBox ygridlines = new JCheckBox(); ygridlines.setSelected(false); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(true); } else { ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(false); } } }; ygridlines.addItemListener(il); // JFreeChart's Box Plots look awful when wide because the mean // circle is based on the width of the bar to the exclusion of all // else. So I've restricted the width to be no more than 0.4, and 0.1 // is the suggested default. final double INITIAL_WIDTH = 0.1; final double MAXIMUM_RATIONAL_WIDTH = 0.4; maximumWidthField = new NumberTextField(INITIAL_WIDTH, 2.0, 0) { public double newValue(double newValue) { if (newValue <= 0.0 || newValue > MAXIMUM_RATIONAL_WIDTH) newValue = currentValue; ((BoxAndWhiskerRenderer) (((CategoryPlot) (chart.getPlot())).getRenderer())) .setMaximumBarWidth(newValue); //update(); return newValue; } }; list.addLabelled("Max Width", maximumWidthField); Box box = Box.createHorizontalBox(); box.add(new JLabel(" Y")); box.add(ygridlines); box.add(Box.createGlue()); list.add(new JLabel("Y Grid Lines"), ygridlines); mean = new JCheckBox(); mean.setSelected(true); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot())) .getRenderer()); renderer.setMeanVisible(mean.isSelected()); } }; mean.addItemListener(il); median = new JCheckBox(); median.setSelected(true); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot())) .getRenderer()); renderer.setMedianVisible(median.isSelected()); } }; median.addItemListener(il); list.add(new JLabel("Mean"), mean); list.add(new JLabel("Median"), median); final JCheckBox horizontal = new JCheckBox(); horizontal.setSelected(false); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { CategoryPlot plot = (CategoryPlot) (chart.getPlot()); if (e.getStateChange() == ItemEvent.SELECTED) { plot.setOrientation(PlotOrientation.HORIZONTAL); } else { plot.setOrientation(PlotOrientation.VERTICAL); } //updateGridLines(); } }; horizontal.addItemListener(il); list.add(new JLabel("Horizontal"), horizontal); final JCheckBox whiskersUseFillColorButton = new JCheckBox(); whiskersUseFillColorButton.setSelected(false); whiskersUseFillColorButton.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot())) .getRenderer()); renderer.setUseOutlinePaintForWhiskers(!whiskersUseFillColorButton.isSelected()); } }); box = Box.createHorizontalBox(); box.add(new JLabel(" Colored")); box.add(whiskersUseFillColorButton); box.add(Box.createGlue()); list.add(new JLabel("Whiskers"), box); }
From source file:edu.gmu.cs.sim.util.media.chart.BoxPlotGenerator.java
protected void buildGlobalAttributes(LabelledList list) { // create the chart ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(false); ((CategoryPlot) (chart.getPlot())).setRangeGridlinePaint(new Color(200, 200, 200)); xLabel = new PropertyField() { public String newValue(String newValue) { setXAxisLabel(newValue);/*from ww w .j a va 2s.c o m*/ getChartPanel().repaint(); return newValue; } }; xLabel.setValue(getXAxisLabel()); list.add(new JLabel("X Label"), xLabel); yLabel = new PropertyField() { public String newValue(String newValue) { setYAxisLabel(newValue); getChartPanel().repaint(); return newValue; } }; yLabel.setValue(getYAxisLabel()); list.add(new JLabel("Y Label"), yLabel); yLog = new JCheckBox(); yLog.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { if (yLog.isSelected()) { LogarithmicAxis logAxis = new LogarithmicAxis(yLabel.getValue()); logAxis.setStrictValuesFlag(false); ((CategoryPlot) (chart.getPlot())).setRangeAxis(logAxis); } else { ((CategoryPlot) (chart.getPlot())).setRangeAxis(new NumberAxis(yLabel.getValue())); } } }); list.add(new JLabel("Y Log Axis"), yLog); final JCheckBox ygridlines = new JCheckBox(); ygridlines.setSelected(false); ItemListener il = new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(true); } else { ((CategoryPlot) (chart.getPlot())).setRangeGridlinesVisible(false); } } }; ygridlines.addItemListener(il); // JFreeChart's Box Plots look awful when wide because the mean // circle is based on the width of the bar to the exclusion of all // else. So I've restricted the width to be no more than 0.4, and 0.1 // is the suggested default. final double INITIAL_WIDTH = 0.1; final double MAXIMUM_RATIONAL_WIDTH = 0.4; maximumWidthField = new NumberTextField(INITIAL_WIDTH, 2.0, 0) { public double newValue(double newValue) { if (newValue <= 0.0 || newValue > MAXIMUM_RATIONAL_WIDTH) { newValue = currentValue; } ((BoxAndWhiskerRenderer) (((CategoryPlot) (chart.getPlot())).getRenderer())) .setMaximumBarWidth(newValue); //update(); return newValue; } }; list.addLabelled("Max Width", maximumWidthField); Box box = Box.createHorizontalBox(); box.add(new JLabel(" Y")); box.add(ygridlines); box.add(Box.createGlue()); list.add(new JLabel("Y Grid Lines"), ygridlines); mean = new JCheckBox(); mean.setSelected(true); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot())) .getRenderer()); renderer.setMeanVisible(mean.isSelected()); } }; mean.addItemListener(il); median = new JCheckBox(); median.setSelected(true); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot())) .getRenderer()); renderer.setMedianVisible(median.isSelected()); } }; median.addItemListener(il); list.add(new JLabel("Mean"), mean); list.add(new JLabel("Median"), median); final JCheckBox horizontal = new JCheckBox(); horizontal.setSelected(false); il = new ItemListener() { public void itemStateChanged(ItemEvent e) { CategoryPlot plot = (CategoryPlot) (chart.getPlot()); if (e.getStateChange() == ItemEvent.SELECTED) { plot.setOrientation(PlotOrientation.HORIZONTAL); } else { plot.setOrientation(PlotOrientation.VERTICAL); } //updateGridLines(); } }; horizontal.addItemListener(il); list.add(new JLabel("Horizontal"), horizontal); final JCheckBox whiskersUseFillColorButton = new JCheckBox(); whiskersUseFillColorButton.setSelected(false); whiskersUseFillColorButton.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { BoxAndWhiskerRenderer renderer = ((BoxAndWhiskerRenderer) ((CategoryPlot) (chart.getPlot())) .getRenderer()); renderer.setUseOutlinePaintForWhiskers(!whiskersUseFillColorButton.isSelected()); } }); box = Box.createHorizontalBox(); box.add(new JLabel(" Colored")); box.add(whiskersUseFillColorButton); box.add(Box.createGlue()); list.add(new JLabel("Whiskers"), box); }
From source file:it.iit.genomics.cru.igb.bundles.mi.view.StructuresPanel.java
public StructuresPanel(IgbService service, String label) { super("MI Structures", "MI Structures", "Display structure", true); igbLogger = IGBLogger.getInstance(label); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // Create hidden JmolFrame jmolFrame = new JFrame(); jmolPanel = new JmolPanel(); jmolPanel.setPreferredSize(new Dimension(500, 500)); Box jmolBox = new Box(BoxLayout.Y_AXIS); Box jmolButtonBox = new Box(BoxLayout.X_AXIS); jmolFrame.add(jmolBox);/* ww w. j a v a2 s .com*/ jmolBox.add(jmolPanel); jmolBox.add(jmolButtonBox); jmolButtonBox.add(new JLabel("Display type:")); ButtonGroup displayGroup = new ButtonGroup(); JRadioButton cartoonButton = new JRadioButton(JMOL_DISPLAY_CARTOON); JRadioButton ballAndSticksButton = new JRadioButton(JMOL_DISPLAY_BALL_AND_STICK); JmolDisplayListener listener = new JmolDisplayListener(); cartoonButton.addActionListener(listener); ballAndSticksButton.addActionListener(listener); displayGroup.add(cartoonButton); displayGroup.add(ballAndSticksButton); jmolButtonBox.add(cartoonButton); jmolButtonBox.add(ballAndSticksButton); ballAndSticksButton.setSelected(true); jmolFrame.pack(); jmolFrame.setVisible(false); jmolButton.addActionListener(new JmolActionListener()); jmolButton.setIcon(new ImageIcon(getClass().getResource("/jmol.jpg"))); linkButton.addActionListener(new ExternalLinkActionListener()); linkButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/searchweb.png")); StructureTableModel model = new StructureTableModel(new ArrayList<StructureItem>(0)); structureList = new StructureTable(model, service); structureList.setTableHeader(null); structureList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane structureListPane = new JScrollPane(structureList); add(structureListPane); }
From source file:com.diversityarrays.dal.server.ServerGui.java
public ServerGui(Image serverIconImage, IDalServer svr, DalServerFactory factory, File wwwRoot, DalServerPreferences prefs) {/*from www. jav a 2 s. c o m*/ this.serverIconImage = serverIconImage; this.dalServerFactory = factory; this.wwwRoot = wwwRoot; this.preferences = prefs; JMenuBar menuBar = new JMenuBar(); JMenu serverMenu = new JMenu("Server"); menuBar.add(serverMenu); serverMenu.add(serverStartAction); serverMenu.add(serverStopAction); serverMenu.add(exitAction); JMenu commandMenu = new JMenu("Command"); menuBar.add(commandMenu); commandMenu.add(doSql); JMenu urlMenu = new JMenu("URL"); menuBar.add(urlMenu); urlMenu.add(new JMenuItem(copyDalUrlAction)); urlMenu.add(new JMenuItem(showDalUrlQRcodeAction)); setJMenuBar(menuBar); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); messages.setFont(GuiUtil.createMonospacedFont(12)); messages.setEditable(false); setServer(svr); quietOption.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boolean q = quietOption.isSelected(); if (server != null) { server.setQuiet(q); } } }); JScrollPane scrollPane = new JScrollPane(messages, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); final JScrollBar verticalScrollBar = scrollPane.getVerticalScrollBar(); JButton clear = new JButton(new AbstractAction("Clear") { @Override public void actionPerformed(ActionEvent e) { messages.setText(""); } }); final boolean[] follow = new boolean[] { true }; final JCheckBox followTail = new JCheckBox("Follow", follow[0]); followTail.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { follow[0] = followTail.isSelected(); } }); final OutputStream os = new OutputStream() { @Override public void write(int b) throws IOException { char ch = (char) b; messages.append(new Character(ch).toString()); if (ch == '\n' && follow[0]) { verticalScrollBar.setValue(verticalScrollBar.getMaximum()); } } }; TeePrintStream pso = new TeePrintStream(System.out, os); TeePrintStream pse = new TeePrintStream(System.err, os); System.setErr(pse); System.setOut(pso); Box box = Box.createHorizontalBox(); box.add(clear); box.add(followTail); box.add(quietOption); box.add(Box.createHorizontalGlue()); JPanel bottom = new JPanel(new BorderLayout()); bottom.add(BorderLayout.NORTH, box); bottom.add(BorderLayout.SOUTH, statusInfoLine); Container cp = getContentPane(); cp.add(BorderLayout.CENTER, scrollPane); cp.add(BorderLayout.SOUTH, bottom); pack(); setSize(640, 480); final MemoryUsageMonitor mum = new MemoryUsageMonitor(); mum.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { statusInfoLine.setMessage(mum.getMemoryUsage()); } }); if (server == null) { // If initial server is null, allow user to specify addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); serverStartAction.actionPerformed(null); } }); } else { addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { removeWindowListener(this); ensureDatabaseInitialisedThenStartServer(); } }); } }
From source file:pcgen.gui2.tabs.DomainInfoTab.java
private void initComponents() { setOrientation(VERTICAL_SPLIT);/*from w w w .java2s . c o m*/ JPanel panel = new JPanel(new BorderLayout()); FilterBar bar = new FilterBar(); bar.addDisplayableFilter(new SearchFilterPanel()); deityTable.setDisplayableFilter(bar); panel.add(bar, BorderLayout.NORTH); deityTable.setSortingPriority(Collections.singletonList(new SortingPriority(0, SortMode.ASCENDING))); deityTable.sortModel(); ListSelectionModel selectionModel = deityTable.getSelectionModel(); selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); panel.add(new JScrollPane(deityTable), BorderLayout.CENTER); Box box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); box.add(new JLabel("Deity:")); box.add(Box.createHorizontalStrut(5)); box.add(selectedDeity); box.add(Box.createHorizontalStrut(5)); box.add(selectDeity); box.add(Box.createHorizontalGlue()); panel.add(box, BorderLayout.SOUTH); FlippingSplitPane splitPane = new FlippingSplitPane(); splitPane.setLeftComponent(panel); panel = new JPanel(new BorderLayout()); bar = new FilterBar(); bar.addDisplayableFilter(new SearchFilterPanel()); domainFilter = bar; panel.add(bar, BorderLayout.NORTH); selectionModel = domainTable.getSelectionModel(); selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollPane = TableUtils.createCheckBoxSelectionPane(domainTable, domainRowHeaderTable); panel.add(scrollPane, BorderLayout.CENTER); box = Box.createHorizontalBox(); box.add(Box.createHorizontalGlue()); box.add(new JLabel("Domains Remaining to be Selected:")); box.add(Box.createHorizontalStrut(5)); box.add(selectedDomain); box.add(Box.createHorizontalGlue()); panel.add(box, BorderLayout.SOUTH); splitPane.setRightComponent(panel); setTopComponent(splitPane); splitPane = new FlippingSplitPane(); splitPane.setLeftComponent(deityInfo); splitPane.setRightComponent(domainInfo); setBottomComponent(splitPane); setResizeWeight(.65); }
From source file:net.sf.jhylafax.AbstractFaxDialog.java
protected void addNumberTextField() { Box box = Box.createHorizontalBox(); addressBookAction = new AddressBookAction(); numberTextField = new JTextField(); numberTextField.setMaximumSize(new Dimension(Integer.MAX_VALUE, numberTextField.getPreferredSize().height)); numberTextField.setTransferHandler(new ContactTransferHandler()); //numberTextField.setDragEnabled(true); box.add(numberTextField); box.add(Box.createHorizontalStrut(4)); box.add(Builder.createIconButton(addressBookAction)); numberLabel = builder.append("", box, 4); builder.nextLine();//w ww.ja v a 2 s . c om numberCompletionModel = new DefaultCompletionModel(); numberCompletion = Builder.addCompletion(numberTextField, numberCompletionModel); new CompletionSettingDirector(Settings.backstore, "number").restore(numberCompletion); }
From source file:pcgen.gui2.dialog.ExportDialog.java
private void initLayout() { Container contentPane = getContentPane(); contentPane.setLayout(new BorderLayout()); Box topPanel = Box.createHorizontalBox(); topPanel.add(new JLabel("Select Character:")); topPanel.add(Box.createHorizontalStrut(5)); topPanel.add(characterBox);/*from ww w .jav a 2s.c o m*/ topPanel.add(Box.createHorizontalStrut(5)); topPanel.add(partyBox); topPanel.add(Box.createHorizontalGlue()); topPanel.add(Box.createHorizontalStrut(50)); topPanel.add(new JLabel("Export to:")); topPanel.add(Box.createHorizontalStrut(5)); topPanel.add(exportBox); contentPane.add(topPanel, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(fileList); scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Templates"), scrollPane.getBorder())); contentPane.add(scrollPane, BorderLayout.CENTER); Box bottomPanel = Box.createHorizontalBox(); bottomPanel.add(progressBar); bottomPanel.add(Box.createHorizontalGlue()); bottomPanel.add(Box.createHorizontalStrut(5)); bottomPanel.add(exportButton); bottomPanel.add(Box.createHorizontalStrut(5)); bottomPanel.add(closeButton); contentPane.add(bottomPanel, BorderLayout.SOUTH); topPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); bottomPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); pack(); }
From source file:org.intermine.modelviewer.swing.ModelViewer.java
/** * Lays out the components within this panel and wires up the relevant * event listeners.//from w w w . j av a 2 s . co m */ private void init() { FileFilter xmlFilter = new XmlFileFilter(); projectFileChooser = new JFileChooser(); projectFileChooser.addChoosableFileFilter(xmlFilter); projectFileChooser.setAcceptAllFileFilterUsed(false); projectFileChooser.setFileFilter(xmlFilter); File lastProjectFile = MineManagerBackingStore.getInstance().getLastProjectFile(); if (lastProjectFile != null) { projectFileChooser.setSelectedFile(lastProjectFile); } initButtonPanel(); classTreeModel = new ClassTreeModel(); classTree = new JTree(classTreeModel); classTree.setCellRenderer(new ClassTreeCellRenderer()); classTree.setRootVisible(false); classTree.setShowsRootHandles(true); Box vbox = Box.createVerticalBox(); vbox.add(new JScrollPane(classTree)); vbox.add(buttonPanel); DefaultTreeSelectionModel selectionModel = new DefaultTreeSelectionModel(); selectionModel.setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); classTree.setSelectionModel(selectionModel); classTree.addTreeSelectionListener(new ClassTreeSelectionListener()); attributeTableModel = new AttributeTableModel(); attributeTable = new AttributeTable(attributeTableModel); referenceTableModel = new ReferenceTableModel(); referenceTable = new ReferenceTable(referenceTableModel); graphModel = new mxGraphModel(); graph = new CustomisedMxGraph(graphModel); graphComponent = new mxGraphComponent(graph); graphComponent.setEscapeEnabled(true); JTabbedPane tableTab = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT); tableTab.add(Messages.getMessage("tab.attributes"), new JScrollPane(attributeTable)); tableTab.add(Messages.getMessage("tab.references"), new JScrollPane(referenceTable)); JSplitPane rightSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tableTab, graphComponent); JSplitPane mainSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, vbox, rightSplit); setOpaque(true); setLayout(new BorderLayout()); add(mainSplit, BorderLayout.CENTER); rightSplit.setDividerLocation(150); mainSplit.setDividerLocation(200); }