List of usage examples for javax.swing Box createRigidArea
public static Component createRigidArea(Dimension d)
From source file:ome.formats.importer.gui.FileQueueChooser.java
/** * File chooser on the file picker tab of the importer * /* w ww. j a v a2 s. com*/ * @param config ImportConfig * @param scanReader OmeroWrapper */ FileQueueChooser(ImportConfig config, OMEROWrapper scanReader) { try { JPanel fp = null; JToolBar tb = null; String refreshIcon = "gfx/recycled12.png"; refreshBtn = GuiCommonElements.addBasicButton("Refresh ", refreshIcon, null); refreshBtn.setActionCommand(REFRESHED); refreshBtn.addActionListener(this); JPanel panel = new JPanel(); // Set up the main panel for tPane, quit, and send buttons double mainTable[][] = { { 10, TableLayout.FILL, TableLayout.PREFERRED, TableLayout.FILL, 10 }, // columns { TableLayout.PREFERRED } }; // rows TableLayout tl = new TableLayout(mainTable); panel.setLayout(tl); // Here's a nice little pieces of test code to find all components if (DEBUG) { try { Component[] components = this.getComponents(); Component component = null; System.err.println("Components: " + components.length); for (int i = 0; i < components.length; i++) { component = components[i]; System.err.println("Component " + i + " = " + component.getClass()); } } catch (Exception e) { log.info("component exception ignore"); } } if (laf.contains("AquaLookAndFeel")) { //Do Aqua implimentation fp = (JPanel) this.getComponent(1); fp.setLayout(new BoxLayout(fp, BoxLayout.X_AXIS)); fp.add(refreshBtn); } else if (laf.contains("QuaquaLookAndFeel")) { //do Quaqua implimentation fp = (JPanel) this.getComponent(1); panel.add(refreshBtn, "1,0,C,C"); panel.add(fp.getComponent(0), "2,0,C,C"); fp.add(panel, BorderLayout.NORTH); } else if (laf.contains("Windows")) { try { //Do windows implimentation tb = (JToolBar) this.getComponent(1); refreshBtn.setToolTipText("Refresh"); refreshBtn.setText(null); tb.add(refreshBtn, 8); } catch (Exception e) { log.info("Exception ignored."); } } /* Disabled temporarily */ else if (laf.contains("MetalLookAndFeel")) { //Do Metal implimentation JPanel prefp = (JPanel) this.getComponent(0); fp = (JPanel) prefp.getComponent(0); refreshBtn.setToolTipText("Refresh"); refreshBtn.setText(null); Dimension size = new Dimension(24, 24); refreshBtn.setMaximumSize(size); refreshBtn.setPreferredSize(size); refreshBtn.setMinimumSize(size); refreshBtn.setSize(size); fp.add(Box.createRigidArea(new Dimension(5, 0))); fp.add(refreshBtn); } else if (laf.contains("GTKLookAndFeel")) { //do GTK implimentation fp = (JPanel) this.getComponent(0); refreshBtn.setIcon(null); fp.add(refreshBtn); } else if (laf.contains("MotifLookAndFeel")) { //do Motif implimentation fp = (JPanel) this.getComponent(0); fp.add(refreshBtn); } if (fp != null && DEBUG == true) { fp.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), fp.getBorder())); System.err.println(fp.getLayout()); } if (tb != null && DEBUG == true) { tb.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), tb.getBorder())); System.err.println(tb.getLayout()); } } catch (ArrayIndexOutOfBoundsException e) { } File dir = null; if (config != null) dir = config.savedDirectory.get(); if (dir != null) { this.setCurrentDirectory(dir); } else { this.setCurrentDirectory(this.getFileSystemView().getHomeDirectory()); } this.setControlButtonsAreShown(false); this.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); this.setMultiSelectionEnabled(true); this.setDragEnabled(true); setAcceptAllFileFilterUsed(false); FileFilter[] originalFF = null; int readerFFSize = 0; if (scanReader != null) { originalFF = loci.formats.gui.GUITools.buildFileFilters(scanReader.getImageReader()); FileFilter filter; List<FileFilter> extensionFilters = new ArrayList<FileFilter>(); for (int i = 0; i < originalFF.length; i++) { filter = originalFF[i]; if (filter instanceof ComboFileFilter) { ComboFileFilter cff = (ComboFileFilter) filter; extensionFilters.add(cff); extensionFilters.addAll(Arrays.asList(cff.getFilters())); break; } } if (extensionFilters != null) { originalFF = extensionFilters.toArray(new FileFilter[extensionFilters.size()]); } readerFFSize = originalFF.length; } FileFilter[] ff = new FileFilter[readerFFSize + 7]; ff[0] = new DashFileFilter(); ff[readerFFSize + 1] = new DashFileFilter(); ff[readerFFSize + 2] = new R3DNewFileFilter(); ff[readerFFSize + 3] = new R3DOldFileFilter(); ff[readerFFSize + 4] = new D3DNewFileFilter(); ff[readerFFSize + 5] = new D3DOldFileFilter(); ff[readerFFSize + 6] = new D3DNPrjFileFilter(); if (originalFF != null) System.arraycopy(originalFF, 0, ff, 1, originalFF.length); //this.addChoosableFileFilter(new DashFileFilter()); //FileFilter combo = null; for (int i = 0; i < ff.length; i++) this.addChoosableFileFilter(ff[i]); this.setFileFilter(ff[1]); //Retrieve all JLists and JTables from the fileChooser fileListObjects = getFileListObjects(this); //For now, assume the first list/table found is the correct one //(this will need to be adjusted if LAF bugs crop up) //Shouldn't break anything since dblclick will just stop working if //this changes for some reason if (fileListObjects.length > 0 && !laf.contains("Windows")) { fileList = fileListObjects[0]; MouseCommand mc = new MouseCommand(); fileList.addMouseListener(mc); } }
From source file:org.jcurl.demo.tactics.TacticsApp.java
public TacticsApp() { addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { TacticsApp.this.cmdExit(); }//from ww w. ja v a 2 s.c o m }); master = new RockEditDisplay(); master.setPos(mod_locations); master.setSpeed(mod_speeds); final PositionDisplay pnl2 = new PositionDisplay(); pnl2.setPos(mod_locations); pnl2.setZoom(Zoomer.HOG2HACK); final Container con = getContentPane(); { final JPanel p = new JPanel(new BorderLayout()); p.add(new SumWaitDisplay(mod_locations), "West"); p.add(master, "Center"); p.add(new SumShotDisplay(mod_locations), "East"); con.add(p, "Center"); } // con.add(new SumWaitDisplay(mod_locations), "West"); con.add(new SumOutDisplay(mod_locations), "West"); { final Box b1 = Box.createHorizontalBox(); b1.add(Box.createRigidArea(new Dimension(0, 75))); b1.add(pnl2); con.add(b1, "South"); } final JTabbedPane t = new JTabbedPane(); con.add(t, "East"); { final Box b0 = Box.createHorizontalBox(); t.add("Rock", b0); { final JPanel b1 = new JPanel(new BorderLayout()); final Box b2 = Box.createVerticalBox(); b2.add(new JComboBox(new String[] { "Dark", "Light" })); b2.add(new JLabel("Broom", SwingConstants.LEFT)); b1.add(b2, "North"); JSlider s = new JSlider(-2000, 2000, 0); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(1000); s.setMinorTickSpacing(100); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final Box b3 = Box.createHorizontalBox(); b3.add(new JFormattedTextField()); b3.add(new JLabel("mm", SwingConstants.LEFT)); b1.add(b3, "South"); b0.add(b1); } { final JPanel b1 = new JPanel(new BorderLayout()); final Box b2 = Box.createVerticalBox(); b2.add(new JComboBox(new String[] { "1", "2", "3", "4", "5", "6", "7", "8" })); b2.add(new JLabel("Splittime", SwingConstants.LEFT)); b1.add(b2, "North"); JSlider s = new JSlider(500, 2500, 1500); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(1000); s.setMinorTickSpacing(100); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final Box b3 = Box.createHorizontalBox(); b3.add(new JSpinner()); b3.add(new JLabel("ms", SwingConstants.LEFT)); b1.add(b3, "South"); b0.add(b1); } } { final Box b0 = Box.createHorizontalBox(); t.add("Ice", b0); { final JPanel b1 = new JPanel(new BorderLayout()); b1.add(new JLabel("Curl"), "North"); JSlider s = new JSlider(0, 5000, 0); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(1000); s.setMinorTickSpacing(100); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final JSpinner s1 = new JSpinner(); b1.add(s1, "South"); b0.add(b1); } { final JPanel b1 = new JPanel(new BorderLayout()); b1.add(new JLabel("DrawToTee"), "North"); JSlider s = new JSlider(15000, 30000, 25000); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(5000); s.setMinorTickSpacing(1000); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final JSpinner s1 = new JSpinner(); b1.add(s1, "South"); b0.add(b1); } } setJMenuBar(createMenu()); refreshTitle(); this.setSize(900, 400); new SpeedController(mod_locations, mod_speeds, master); new LocationController(mod_locations, pnl2); lastSaved = mod_locations.getLastChanged(); }
From source file:components.ListDialog.java
private ListDialog(Frame frame, Component locationComp, String labelText, String title, Object[] data, String initialValue, String longValue) { super(frame, title, true); //Create and initialize the buttons. JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(this); //// ww w. ja va 2 s . c om final JButton setButton = new JButton("Set"); setButton.setActionCommand("Set"); setButton.addActionListener(this); getRootPane().setDefaultButton(setButton); //main part of the dialog list = new JList(data) { //Subclass JList to workaround bug 4832765, which can cause the //scroll pane to not let the user easily scroll up to the beginning //of the list. An alternative would be to set the unitIncrement //of the JScrollBar to a fixed value. You wouldn't get the nice //aligned scrolling, but it should work. public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { int row; if (orientation == SwingConstants.VERTICAL && direction < 0 && (row = getFirstVisibleIndex()) != -1) { Rectangle r = getCellBounds(row, row); if ((r.y == visibleRect.y) && (row != 0)) { Point loc = r.getLocation(); loc.y--; int prevIndex = locationToIndex(loc); Rectangle prevR = getCellBounds(prevIndex, prevIndex); if (prevR == null || prevR.y >= r.y) { return 0; } return prevR.height; } } return super.getScrollableUnitIncrement(visibleRect, orientation, direction); } }; list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); if (longValue != null) { list.setPrototypeCellValue(longValue); //get extra space } list.setLayoutOrientation(JList.HORIZONTAL_WRAP); list.setVisibleRowCount(-1); list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { setButton.doClick(); //emulate button click } } }); JScrollPane listScroller = new JScrollPane(list); listScroller.setPreferredSize(new Dimension(250, 80)); listScroller.setAlignmentX(LEFT_ALIGNMENT); //Create a container so that we can add a title around //the scroll pane. Can't add a title directly to the //scroll pane because its background would be white. //Lay out the label and scroll pane from top to bottom. JPanel listPane = new JPanel(); listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); JLabel label = new JLabel(labelText); label.setLabelFor(list); listPane.add(label); listPane.add(Box.createRigidArea(new Dimension(0, 5))); listPane.add(listScroller); listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); //Lay out the buttons from left to right. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(cancelButton); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(setButton); //Put everything together, using the content pane's BorderLayout. Container contentPane = getContentPane(); contentPane.add(listPane, BorderLayout.CENTER); contentPane.add(buttonPane, BorderLayout.PAGE_END); //Initialize values. setValue(initialValue); pack(); setLocationRelativeTo(locationComp); }
From source file:sim.app.sugarscape.SugarscapeWithUIHigh.java
void addChartPanel(Controller c, Sugarscape model) { charts = new Charts(model); ChartPanel ginipanel = null;/*from w ww . j a v a 2 s. c o m*/ ChartPanel wealthpanel = null; ChartPanel agentspanel = null; ChartPanel agepanel = null; ChartPanel evolutionpanel = null; ChartPanel culturetagpanel = null; ChartPanel tradepanel = null; if (model.gini_chart_on) { ginipanel = new ChartPanel(charts.createGiniChart()); } if (model.wealth_chart_on) { wealthpanel = new ChartPanel(charts.createChart4()); } if (model.population_chart_on) { agentspanel = new ChartPanel(charts.createAgentsChart()); } if (model.age_chart_on) { agepanel = new ChartPanel(charts.createAgeHistoChart()); } if (model.evolution_chart_on) { evolutionpanel = new ChartPanel(charts.createEvolution()); } if (model.culture_tag_chart_on) { culturetagpanel = new ChartPanel(charts.createCultureTagChart()); } if (model.trade_chart_on) { tradepanel = new ChartPanel(charts.createTradeChart()); } if ((!model.gini_chart_on) && (!model.wealth_chart_on) && (!model.population_chart_on) && (!model.age_chart_on) && (!model.evolution_chart_on) && (!model.culture_tag_chart_on) && (!model.trade_chart_on)) { return; } // create the chart frame chartFrame = new JFrame(); chartFrame.setResizable(true); Container cp = chartFrame.getContentPane(); cp.setLayout(new BoxLayout(cp, BoxLayout.Y_AXIS)); if (agepanel != null) { cp.add(agepanel); cp.add(Box.createRigidArea(new Dimension(0, 6))); } if (tradepanel != null) { cp.add(tradepanel); cp.add(Box.createRigidArea(new Dimension(0, 6))); } if (ginipanel != null) { cp.add(ginipanel); cp.add(Box.createRigidArea(new Dimension(0, 6))); } if (wealthpanel != null) { cp.add(wealthpanel); cp.add(Box.createRigidArea(new Dimension(0, 6))); } if (agentspanel != null) { cp.add(agentspanel); cp.add(Box.createRigidArea(new Dimension(0, 6))); } if (culturetagpanel != null) { cp.add(culturetagpanel); cp.add(Box.createRigidArea(new Dimension(0, 6))); } if (evolutionpanel != null) { cp.add(evolutionpanel); cp.add(Box.createRigidArea(new Dimension(0, 6))); } //cp.add(chartPanel2); //cp.add(Box.createRigidArea(new Dimension(0,6))); //cp.add(chartPanel3); chartFrame.setTitle("Live Agent Statistics"); chartFrame.pack(); // register the chartFrame so it appears in the "Display" list c.registerFrame(chartFrame); // make the frame visible chartFrame.setVisible(true); }
From source file:ome.formats.importer.gui.FileQueueTable.java
/** * Set up and display the file queue table *//*from w w w . ja v a 2 s . co m*/ FileQueueTable() { // ----- Variables ----- // Debug Borders Boolean debugBorders = false; // Size of the add/remove/refresh buttons (which are square). int buttonSize = 40; // Add graphic for the refresh button //String refreshIcon = "gfx/recycled.png"; // Add graphic for add button String addIcon = "gfx/add.png"; // Remove graphics for remove button String removeIcon = "gfx/remove.png"; // Width of the status columns int statusWidth = 100; // ----- GUI Layout Elements ----- // Start layout here setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); setBorder(BorderFactory.createEmptyBorder(6, 5, 9, 8)); JPanel buttonPanel = new JPanel(); if (debugBorders == true) buttonPanel.setBorder(BorderFactory.createLineBorder(Color.red, 1)); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.PAGE_AXIS)); // refreshBtn = addButton("+", refreshIcon, null); // refreshBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setSize(new Dimension(buttonSize, buttonSize)); // refreshBtn.setActionCommand(Actions.REFRESH); // refreshBtn.addActionListener(this); addBtn = GuiCommonElements.addBasicButton(null, addIcon, null); addBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); addBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); addBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); addBtn.setSize(new Dimension(buttonSize, buttonSize)); addBtn.setActionCommand(FileQueueHandler.ADD); addBtn.addActionListener(this); addBtn.setToolTipText("Add files to the import queue."); removeBtn = GuiCommonElements.addBasicButton(null, removeIcon, null); removeBtn.setMaximumSize(new Dimension(buttonSize, buttonSize)); removeBtn.setPreferredSize(new Dimension(buttonSize, buttonSize)); removeBtn.setMinimumSize(new Dimension(buttonSize, buttonSize)); removeBtn.setSize(new Dimension(buttonSize, buttonSize)); removeBtn.setActionCommand(FileQueueHandler.REMOVE); removeBtn.addActionListener(this); removeBtn.setToolTipText("Remove files from the import queue."); buttonPanel.add(Box.createRigidArea(new Dimension(0, 60))); //buttonPanel.add(refreshBtn); buttonPanel.add(Box.createVerticalGlue()); buttonPanel.add(addBtn); buttonPanel.add(Box.createRigidArea(new Dimension(0, 5))); buttonPanel.add(removeBtn); buttonPanel.add(Box.createVerticalGlue()); buttonPanel.add(Box.createRigidArea(new Dimension(0, 60))); add(buttonPanel); add(Box.createRigidArea(new Dimension(5, 0))); JPanel queuePanel = new JPanel(); if (debugBorders == true) queuePanel.setBorder(BorderFactory.createLineBorder(Color.red, 1)); queuePanel.setLayout(new BoxLayout(queuePanel, BoxLayout.PAGE_AXIS)); //queuePanel.add(Box.createRigidArea(new Dimension(0,10))); JPanel labelPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.LINE_AXIS)); JLabel label = new JLabel("Import Queue:"); labelPanel.add(label); labelPanel.add(Box.createHorizontalGlue()); groupBtn = GuiCommonElements.addBasicButton("Group: ", null, "Current Group"); groupBtn.setToolTipText("The user group you are logged into."); //groupBtn.setEnabled(false); labelPanel.add(groupBtn); queuePanel.add(labelPanel); queuePanel.add(Box.createRigidArea(new Dimension(0, 5))); TableColumnModel cModel = getQueue().getColumnModel(); headerCellRenderer = new MyTableHeaderRenderer(); fileCellRenderer = new LeftDotRenderer(); dpCellRenderer = new CenterTextRenderer(); statusCellRenderer = new CenterTextRenderer(); // Create a custom header for the table cModel.getColumn(0).setHeaderRenderer(headerCellRenderer); cModel.getColumn(1).setHeaderRenderer(headerCellRenderer); cModel.getColumn(2).setHeaderRenderer(headerCellRenderer); cModel.getColumn(0).setCellRenderer(fileCellRenderer); cModel.getColumn(1).setCellRenderer(dpCellRenderer); cModel.getColumn(2).setCellRenderer(statusCellRenderer); // Set the width of the status column TableColumn statusColumn = getQueue().getColumnModel().getColumn(2); statusColumn.setPreferredWidth(statusWidth); statusColumn.setMaxWidth(statusWidth); statusColumn.setMinWidth(statusWidth); SelectionListener listener = new SelectionListener(getQueue()); getQueue().getSelectionModel().addListSelectionListener(listener); //queue.getColumnModel().getSelectionModel() // .addListSelectionListener(listener); // Hide 3rd to 6th columns TableColumnModel tcm = getQueue().getColumnModel(); TableColumn projectColumn = tcm.getColumn(6); tcm.removeColumn(projectColumn); TableColumn userPixelColumn = tcm.getColumn(6); tcm.removeColumn(userPixelColumn); TableColumn userSpecifiedNameColumn = tcm.getColumn(6); tcm.removeColumn(userSpecifiedNameColumn); TableColumn datasetColumn = tcm.getColumn(3); tcm.removeColumn(datasetColumn); TableColumn pathColumn = tcm.getColumn(3); tcm.removeColumn(pathColumn); TableColumn archiveColumn = tcm.getColumn(3); tcm.removeColumn(archiveColumn); // Add the table to the scollpane JScrollPane scrollPane = new JScrollPane(getQueue()); queuePanel.add(scrollPane); JPanel importPanel = new JPanel(); importPanel.setLayout(new BoxLayout(importPanel, BoxLayout.LINE_AXIS)); clearDoneBtn = GuiCommonElements.addBasicButton("Clear Done", null, null); clearFailedBtn = GuiCommonElements.addBasicButton("Clear Failed", null, null); importBtn = GuiCommonElements.addBasicButton("Import", null, null); importPanel.add(Box.createHorizontalGlue()); importPanel.add(clearDoneBtn); clearDoneBtn.setEnabled(false); clearDoneBtn.setActionCommand(FileQueueHandler.CLEARDONE); clearDoneBtn.addActionListener(this); clearDoneBtn.setToolTipText("Clear all 'done' entries from the import queue."); importPanel.add(Box.createRigidArea(new Dimension(0, 5))); importPanel.add(clearFailedBtn); clearFailedBtn.setEnabled(false); clearFailedBtn.setActionCommand(FileQueueHandler.CLEARFAILED); clearFailedBtn.addActionListener(this); clearFailedBtn.setToolTipText("Clear all 'failed' entries from the import queue."); importPanel.add(Box.createRigidArea(new Dimension(0, 10))); importPanel.add(importBtn); importBtn.setEnabled(false); importBtn.setActionCommand(FileQueueHandler.IMPORT); importBtn.addActionListener(this); importBtn.setToolTipText("Begin importing files."); GuiCommonElements.enterPressesWhenFocused(importBtn); queuePanel.add(Box.createRigidArea(new Dimension(0, 5))); queuePanel.add(importPanel); add(queuePanel); }
From source file:org.ash.gui.MainFrame.java
/** * Jb init.// www .j a v a2 s .co m * * @throws Exception the exception */ private void jbInit() throws Exception { /** set layout */ this.setLayout(new BorderLayout()); this.tabsMain = new JTabbedPane(); this.model = new Model(); this.splitPaneMain = new JSplitPane(); this.statusBar = new StatusBar(); this.jButtonSettings.setMnemonic(Options.getInstance().getResource("settingsMain.mnemonic").charAt(0)); this.jButtonSettings.setText(Options.getInstance().getResource("settingsMain.text")); this.jButtonSettings.setPreferredSize(new Dimension(100, 30)); this.jButtonSettings.addActionListener(this); this.jButtonThumbnail.setMnemonic(Options.getInstance().getResource("ThumbnailMain.mnemonic").charAt(0)); this.jButtonThumbnail.setText(Options.getInstance().getResource("ThumbnailMain.text")); this.jButtonThumbnail.setPreferredSize(new Dimension(100, 30)); this.jButtonThumbnail.addActionListener(this); /** Button panel fot buttons */ this.buttonPanel = new JToolBar("PanelButton"); this.buttonPanel.setFloatable(false); this.buttonPanel.setBorder(new EtchedBorder()); /** Layout of buttons */ this.buttonPanel.add(Box.createRigidArea(new Dimension(20, 0))); this.buttonPanel.add(this.jButtonSettings); this.buttonPanel.add(Box.createRigidArea(new Dimension(10, 0))); //this.buttonPanel.add(this.jButtonThumbnail); //this.buttonPanel.add(Box.createRigidArea(new Dimension(10, 0))); //this.buttonPanel.add(this.jButtonDetail); //this.buttonPanel.add(Box.createRigidArea(new Dimension(10, 0))); //this.buttonPanel.add(this.spinerRangeWindowLabel); //this.buttonPanel.add(Box.createRigidArea(new Dimension(5, 0))); //this.buttonPanel.add(this.spinerRangeWindow); //this.buttonPanel.add(Box.createRigidArea(new Dimension(this.getWidth()-250, 0))); this.mainPanel = new JPanel(); this.mainPanel.setLayout(new BorderLayout()); this.mainPanel.setVisible(true); this.settingsDialog = new Settings(this); this.settingsDialog.setLocation(buttonPanel.getX() + 100, buttonPanel.getY() + 50); this.settingsDialog.setVisible(false); }
From source file:fungus.MycoNodeFrame.java
public MycoNodeFrame(MycoNode node) { this.node = node; this.setTitle("Node " + node.getID()); graph = JungGraphObserver.getGraph(); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); JPanel labelPane = new JPanel(); labelPane.setLayout(new GridLayout(7, 2)); JPanel neighborPane = new JPanel(); neighborPane.setLayout(new BoxLayout(neighborPane, BoxLayout.PAGE_AXIS)); JPanel logPane = new JPanel(); logPane.setLayout(new BoxLayout(logPane, BoxLayout.PAGE_AXIS)); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); loggingTextArea = new JTextArea("", 25, 100); loggingTextArea.setLineWrap(true);//from w ww . j a v a 2 s.c om loggingTextArea.setEditable(false); handler = new MycoNodeLogHandler(node, loggingTextArea); handler.addChangeListener(this); JScrollPane logScrollPane = new JScrollPane(loggingTextArea); logScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); logPane.add(logScrollPane); contentPane.add(labelPane); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); contentPane.add(neighborPane); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); contentPane.add(logPane); contentPane.add(buttonPane); data = node.getHyphaData(); link = node.getHyphaLink(); mycocast = node.getMycoCast(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); stateLabel = new JLabel(); typeLabel = new JLabel(); queueLengthLabel = new JLabel(); sameLabel = new JLabel(); differentLabel = new JLabel(); maxCapacityLabel = new JLabel(); idealImmobileLabel = new JLabel(); idealHyphaeLabel = new JLabel(); idealBiomassLabel = new JLabel(); degreeLabel = new JLabel(); hyphaDegreeLabel = new JLabel(); biomassDegreeLabel = new JLabel(); hyphaUtilizationLabel = new JLabel(); biomassUtilizationLabel = new JLabel(); capacityUtilizationLabel = new JLabel(); labelPane.add(new JLabel("state")); labelPane.add(stateLabel); labelPane.add(new JLabel("type")); labelPane.add(typeLabel); labelPane.add(new JLabel("queue")); labelPane.add(queueLengthLabel); labelPane.add(new JLabel("")); labelPane.add(new JLabel("")); labelPane.add(new JLabel("same")); labelPane.add(sameLabel); labelPane.add(new JLabel("different")); labelPane.add(differentLabel); //labelPane.add(new JLabel("immobile")); //labelPane.add(idealImmobileLabel); labelPane.add(new JLabel("")); labelPane.add(new JLabel("actual")); labelPane.add(new JLabel("ideal")); labelPane.add(new JLabel("utilization")); labelPane.add(new JLabel("hyphae")); labelPane.add(hyphaDegreeLabel); labelPane.add(idealHyphaeLabel); labelPane.add(hyphaUtilizationLabel); labelPane.add(new JLabel("biomass")); labelPane.add(biomassDegreeLabel); labelPane.add(idealBiomassLabel); labelPane.add(biomassUtilizationLabel); labelPane.add(new JLabel("capacity")); labelPane.add(degreeLabel); labelPane.add(maxCapacityLabel); labelPane.add(capacityUtilizationLabel); neighborListControl = new JList(); neighborListControl.setLayoutOrientation(JList.VERTICAL_WRAP); neighborListControl.setVisibleRowCount(-1); neighborListScroller = new JScrollPane(neighborListControl); neighborListScroller.setPreferredSize(new Dimension(250, 150)); neighborListScroller.setMinimumSize(new Dimension(250, 150)); neighborPane.add(neighborListScroller); JButton updateButton = new JButton("Refresh"); ActionListener updater = new ActionListener() { public void actionPerformed(ActionEvent e) { refreshData(); } }; updateButton.addActionListener(updater); JButton closeButton = new JButton("Close"); ActionListener closer = new ActionListener() { public void actionPerformed(ActionEvent e) { closeFrame(); } }; closeButton.addActionListener(closer); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add(updateButton); buttonPane.add(Box.createRigidArea(new Dimension(5, 0))); buttonPane.add(closeButton); refreshData(); JungGraphObserver.addChangeListener(this); this.pack(); this.setVisible(true); }
From source file:org.obiba.onyx.jade.instrument.summitdoppler.VantageABIInstrumentRunner.java
protected JPanel buildFileSelectionSubPanel() { final JPanel panel = new JPanel(); panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(Box.createVerticalGlue()); JButton openButton = new JButton(resourceBundle.getString("Select_file")); openButton.setMnemonic('O'); openButton.setToolTipText(resourceBundle.getString("ToolTip.Select_file")); panel.add(openButton);/*from w w w . j a va 2 s.c om*/ panel.add(Box.createRigidArea(new Dimension(10, 10))); JLabel fileLabel = new ABIFileLabel(); panel.add(fileLabel); // Open button listener. openButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int returnVal = fileChooser.showOpenDialog(appWindow); if (returnVal == JFileChooser.APPROVE_OPTION) { abiFile = fileChooser.getSelectedFile(); panel.repaint(); saveButton.setEnabled(true); } } }); panel.setAlignmentX(Component.LEFT_ALIGNMENT); return panel; }
From source file:BorderDemo.java
void addCompForBorder(Border border, String description, Container container) { JPanel comp = new JPanel(false); JLabel label = new JLabel(description, JLabel.CENTER); comp.setLayout(new GridLayout(1, 1)); comp.add(label);//ww w. jav a2s . c o m comp.setBorder(border); container.add(Box.createRigidArea(new Dimension(0, 10))); container.add(comp); }
From source file:com.univocity.app.swing.DataAnalysisWindow.java
private void addWithSpace(JPanel panel, Component c, int width) { panel.add(Box.createRigidArea(new Dimension(width, 0))); panel.add(c);/*from ww w .j av a 2 s . c o m*/ panel.add(Box.createRigidArea(new Dimension(width, 0))); }