List of usage examples for javax.swing BoxLayout BoxLayout
@ConstructorProperties({ "target", "axis" }) public BoxLayout(Container target, int axis)
From source file:gdt.jgui.entity.fields.JFieldsEditor.java
/** * The default constructor./*w w w .j a v a 2s. com*/ */ public JFieldsEditor() { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); scrollPane = new JScrollPane(); add(scrollPane); }
From source file:au.org.ala.delta.ui.SearchDialog.java
/** * Create the dialog.// w w w . j a va2 s.c om */ public SearchDialog(SearchController controller) { super(UIUtils.getParentFrame(controller.getOwningComponent())); hookInternalFrame(controller.getOwningComponent()); _controller = controller; UIUtils.centerDialog(this, controller.getOwningComponent().getParent()); setTitle(controller.getTitle()); setName(_controller.getTitle()); setBounds(100, 100, 366, 229); getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); SingleFrameApplication application = (SingleFrameApplication) Application.getInstance(); ResourceMap messages = application.getContext().getResourceMap(); JLabel lblFind = new JLabel(messages.getString("searchDialog.lblFind")); lblFind.setMinimumSize(new Dimension(30, 0)); textField = new JTextField(); textField.setColumns(10); JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(null, messages.getString("searchDialog.groupDirection"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); buttonGroup = new ButtonGroup(); rdbtnForwards = new JRadioButton(messages.getString("searchDialog.directionForwards")); rdbtnForwards.setSelected(true); buttonGroup.add(rdbtnForwards); rdbtnBackwards = new JRadioButton(messages.getString("searchDialog.directionBackwards")); buttonGroup.add(rdbtnBackwards); contentPanel.setLayout(new MigLayout("", "[growprio 0,grow,left][grow][grow]", "[20px][21px,grow][grow]")); contentPanel.add(lblFind, "cell 0 0,alignx left,aligny top"); contentPanel.add(textField, "cell 1 0 2 1,growx,aligny top"); final JPanel panel_1 = new JPanel(); panel_1.setBorder(new TitledBorder(null, messages.getString("searchDialog.optionsPanelTitle"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); contentPanel.add(panel_1, "cell 0 1 2 1,grow"); panel_1.setLayout(new BoxLayout(panel_1, BoxLayout.Y_AXIS)); chckbxMatchCase = new JCheckBox(messages.getString("searchDialog.lblMatchCase")); panel_1.add(chckbxMatchCase); chckbxWrapSearch = new JCheckBox(messages.getString("searchDialog.lblWrapSearch")); panel_1.add(chckbxWrapSearch); chckbxWrapSearch.setSelected(true); contentPanel.add(panel, "cell 2 1,grow"); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(rdbtnForwards); panel.add(rdbtnBackwards); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton findButton = new JButton(messages.getString("searchDialog.btnFindNext")); findButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { findNext(); } }); buttonPane.add(findButton); getRootPane().setDefaultButton(findButton); } { JButton cancelButton = new JButton(messages.getString("searchDialog.btnCancel")); buttonPane.add(cancelButton); cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }); } } }
From source file:fungus.UtilizationChartFrame.java
public UtilizationChartFrame(String prefix) { simulationCycles = Configuration.getDouble(PAR_SIMULATION_CYCLES); this.setTitle("MycoNet Statistics Chart"); graph = JungGraphObserver.getGraph(); //data.add(-1,0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.setAutoWidth(false);//from ww w .j a va 2 s . c om dataset.setIntervalWidth(simulationCycles); averageUtilizationData = new XYSeries("Average Utilization"); dataset.addSeries(averageUtilizationData); averageStableUtilizationData = new XYSeries("Avg Stable Util"); dataset.addSeries(averageStableUtilizationData); hyphaRatioData = new XYSeries("Hypha Ratio"); dataset.addSeries(hyphaRatioData); stableHyphaRatioData = new XYSeries("Stable Hypha Ratio"); dataset.addSeries(stableHyphaRatioData); //XYSeriesCollection dataset; JFreeChart utilizationChart = ChartFactory.createXYLineChart("Utilization Metrics", "Cycle", "Average Utilization", dataset, PlotOrientation.VERTICAL, true, false, false); ChartPanel utilizationChartPanel = new ChartPanel(utilizationChart); //chart.setBackgroundPaint(Color.white); //XYPlot plot = chart.getXYPlot(); // BufferedImage chartImage = chart.createBufferedImage(500,300); // chartLabel = new JLabel(); //chartLabel.setIcon(new ImageIcon(chartImage)); Container contentPane = getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); JPanel labelPane = new JPanel(); labelPane.setLayout(new GridLayout(1, 1)); //chartPane.setPreferredSize(new java.awt.Dimension(500, 300)); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); ////contentPane.add(labelPane,BorderLayout.PAGE_START); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); contentPane.add(utilizationChartPanel, BorderLayout.CENTER); //contentPane.add(Box.createRigidArea(new Dimension(0,5))); ////contentPane.add(buttonPane, BorderLayout.PAGE_END); //data = node.getHyphaData(); //link = node.getHyphaLink(); //mycocast = node.getMycoCast(); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); //chartPanel.add(chartLabel); /*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:edu.ku.brc.stats.StatGroupTable.java
/** * Constructor with the localized name of the Group * @param name name of the group (already been localized) *///from w w w . j a va 2 s . co m public StatGroupTable(final String name, @SuppressWarnings("unused") final String[] columnNames) { this.name = name; this.skinItem = SkinsMgr.getSkinItem("StatGroup"); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); //setBorder(BorderFactory.createCompoundBorder(new CurvedBorder(new Color(160,160,160)), BorderFactory.createEmptyBorder(15, 2, 2, 2))); //setBackground(Color.WHITE); setOpaque(SkinsMgr.shouldBeOpaque(skinItem)); if (progressIcon == null) { progressIcon = IconManager.getIcon("Progress", IconManager.IconSize.Std16); } if (this.skinItem != null) { this.skinItem.setupPanel(this); } else { setOpaque(true); } }
From source file:org.peerfact.impl.service.aggregation.skyeye.visualization.SkyNetVisualization.java
private SkyNetVisualization() { super("Metric-Visualization"); createLookAndFeel();/*from ww w. j av a2s. c om*/ displayedMetrics = new LinkedHashMap<String, MetricsPlot>(); setLayout(new GridLayout(1, 1)); addWindowListener(this); graphix = new JPanel(new GridBagLayout()); graphix.setLayout(new BoxLayout(graphix, BoxLayout.PAGE_AXIS)); mb = new JMenuBar(); JScrollPane scroller = new JScrollPane(graphix, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); // calculating the size of the application-window as well as of all // components, that depend on the size of the window Toolkit kit = Toolkit.getDefaultToolkit(); int appWidth = kit.getScreenSize().width * 3 / 4; int appHeight = kit.getScreenSize().height * 3 / 4; scroller.setPreferredSize(new Dimension(appWidth, appHeight)); getContentPane().add(scroller); maxPlotsPerRow = 1; while ((maxPlotsPerRow + 1) * PLOT_WIDTH < appWidth) { maxPlotsPerRow++; } log.warn("Creating the visualization..."); mb.add(new JMenu("File")); JMenu met = new JMenu("Available Metrics"); met.setEnabled(false); mb.add(met); setJMenuBar(mb); }
From source file:es.emergya.ui.gis.popups.GenericDialog.java
public GenericDialog(T i, final String titulo, final String icon) { super();//from w ww .j a va2s. com log.trace("GenericDialog(" + i + ")"); setAlwaysOnTop(true); setResizable(false); setBackground(Color.WHITE); setPreferredSize(new Dimension(500, 500)); setTitle(titulo); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); base.setBackground(Color.WHITE); JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JLabel labelTitle = new JLabel(titulo, LogicConstants.getIcon(icon), JLabel.LEFT); labelTitle.setFont(LogicConstants.deriveBoldFont(12f)); title.setBackground(Color.WHITE); title.add(labelTitle); base.add(title); mid = new JPanel(new SpringLayout()); mid.setBackground(Color.WHITE); loadDialog(i); SpringUtilities.makeCompactGrid(mid, rows, cols, initialX, initialY, xPad, yPad); base.add(mid); JPanel buttons = new JPanel(); buttons.setBackground(Color.WHITE); JButton accept = new JButton(i18n.getString("Buttons.ok"), LogicConstants.getIcon("button_accept")); accept.addActionListener(closeListener); accept.addActionListener(saveListener); buttons.add(accept); JButton cancel = new JButton(i18n.getString("Buttons.cancel"), LogicConstants.getIcon("button_cancel")); cancel.addActionListener(closeListener); buttons.add(cancel); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } }
From source file:marytts.tools.voiceimport.DatabaseImportMain.java
protected void setupGUI() { // A scroll pane containing one labelled checkbox per component, // and a "run selected components" button below. GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridC = new GridBagConstraints(); getContentPane().setLayout(gridBagLayout); JPanel checkboxPane = new JPanel(); checkboxPane.setLayout(new BoxLayout(checkboxPane, BoxLayout.Y_AXIS)); //checkboxPane.setPreferredSize(new Dimension(300, 300)); int compIndex = 0; for (int j = 0; j < groups2Comps.length; j++) { String[] nextGroup = groups2Comps[j]; JPanel groupPane = new JPanel(); groupPane.setLayout(new BoxLayout(groupPane, BoxLayout.Y_AXIS)); groupPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(nextGroup[0]), BorderFactory.createEmptyBorder(1, 1, 1, 1))); for (int i = 1; i < nextGroup.length; i++) { JButton configButton = new JButton(); Icon configIcon = new ImageIcon(DatabaseImportMain.class.getResource("configure.png"), "Configure"); configButton.setIcon(configIcon); configButton.setPreferredSize(new Dimension(configIcon.getIconWidth(), configIcon.getIconHeight())); configButton.addActionListener(new ConfigButtonActionListener(nextGroup[i])); configButton.setBorderPainted(false); //System.out.println("Adding checkbox for "+components[i].getClass().getName()); checkboxes[compIndex] = new JCheckBox(nextGroup[i]); checkboxes[compIndex].setFocusable(true); //checkboxes[i].setPreferredSize(new Dimension(200, 30)); JPanel line = new JPanel(); line.setLayout(new BorderLayout(5, 0)); line.add(configButton, BorderLayout.WEST); line.add(checkboxes[compIndex], BorderLayout.CENTER); groupPane.add(line);//from w w w. ja v a 2 s.co m compIndex++; } checkboxPane.add(groupPane); } gridC.gridx = 0; gridC.gridy = 0; gridC.fill = GridBagConstraints.BOTH; JScrollPane scrollPane = new JScrollPane(checkboxPane); scrollPane.setPreferredSize(new Dimension(450, 300)); gridBagLayout.setConstraints(scrollPane, gridC); getContentPane().add(scrollPane); JButton helpButton = new JButton("Help"); helpButton.setMnemonic(KeyEvent.VK_H); helpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { displayHelpGUI(); } }); JButton settingsButton = new JButton("Settings"); settingsButton.setMnemonic(KeyEvent.VK_S); settingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { currentComponent = "Global properties"; displaySettingsGUI(); } }); runButton = new JButton("Run"); runButton.setMnemonic(KeyEvent.VK_R); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { runSelectedComponents(); } }); JButton quitAndSaveButton = new JButton("Quit"); quitAndSaveButton.setMnemonic(KeyEvent.VK_Q); quitAndSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); gridC.gridy = 1; JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); //buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS)); //runButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(runButton); //helpButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(helpButton); //settingsButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(settingsButton); //buttonPanel.add(Box.createHorizontalGlue()); //quitAndSaveButton.setAlignmentX(JButton.RIGHT_ALIGNMENT); buttonPanel.add(quitAndSaveButton); gridBagLayout.setConstraints(buttonPanel, gridC); getContentPane().add(buttonPanel); //getContentPane().setPreferredSize(new Dimension(300, 300)); // End program when closing window: addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); }
From source file:gdt.jgui.console.JItemPanel.java
/** * The default constructor.//from ww w. ja v a2s . co m */ public JItemPanel() { super(); setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); setAlignmentX(Component.LEFT_ALIGNMENT); }
From source file:ListSelectionDemo.java
public ListSelectionDemo() { super(new BorderLayout()); String[] listData = { "one", "two", "three", "four", "five", "six", "seven" }; String[] columnNames = { "French", "Spanish", "Italian" }; list = new JList(listData); listSelectionModel = list.getSelectionModel(); listSelectionModel.addListSelectionListener(new SharedListSelectionHandler()); JScrollPane listPane = new JScrollPane(list); JPanel controlPane = new JPanel(); String[] modes = { "SINGLE_SELECTION", "SINGLE_INTERVAL_SELECTION", "MULTIPLE_INTERVAL_SELECTION" }; final JComboBox comboBox = new JComboBox(modes); comboBox.setSelectedIndex(2);//from w ww . j a v a 2 s. c o m comboBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newMode = (String) comboBox.getSelectedItem(); if (newMode.equals("SINGLE_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); } else if (newMode.equals("SINGLE_INTERVAL_SELECTION")) { listSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); } else { listSelectionModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); } output.append("----------" + "Mode: " + newMode + "----------" + newline); } }); controlPane.add(new JLabel("Selection mode:")); controlPane.add(comboBox); // Build output area. output = new JTextArea(1, 10); output.setEditable(false); JScrollPane outputPane = new JScrollPane(output, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); // Do the layout. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); add(splitPane, BorderLayout.CENTER); JPanel topHalf = new JPanel(); topHalf.setLayout(new BoxLayout(topHalf, BoxLayout.LINE_AXIS)); JPanel listContainer = new JPanel(new GridLayout(1, 1)); listContainer.setBorder(BorderFactory.createTitledBorder("List")); listContainer.add(listPane); topHalf.setBorder(BorderFactory.createEmptyBorder(5, 5, 0, 5)); topHalf.add(listContainer); // topHalf.add(tableContainer); topHalf.setMinimumSize(new Dimension(100, 50)); topHalf.setPreferredSize(new Dimension(100, 110)); splitPane.add(topHalf); JPanel bottomHalf = new JPanel(new BorderLayout()); bottomHalf.add(controlPane, BorderLayout.PAGE_START); bottomHalf.add(outputPane, BorderLayout.CENTER); // XXX: next line needed if bottomHalf is a scroll pane: // bottomHalf.setMinimumSize(new Dimension(400, 50)); bottomHalf.setPreferredSize(new Dimension(450, 135)); splitPane.add(bottomHalf); }
From source file:CutAndPasteDemo.java
public CutAndPasteDemo() { super("Cut And Paste Demonstration"); clipboard = getToolkit().getSystemClipboard(); GraphicsEnvironment.getLocalGraphicsEnvironment(); Font font = new Font("LucidaSans", Font.PLAIN, 15); textArea1 = new JTextArea(davidMessage + andyMessage, 5, 25); textArea2 = new JTextArea("<Paste text here>", 5, 25); textArea1.setFont(font);//from w w w . j a v a 2s .c o m textArea2.setFont(font); JPanel jPanel = new JPanel(); JMenuBar jMenuBar = new JMenuBar(); JMenuItem cutItem = new JMenuItem("Cut"); JMenuItem pasteItem = new JMenuItem("Paste"); JMenu jMenu = new JMenu("Edit"); jMenu.add(cutItem); jMenu.add(pasteItem); cutItem.addActionListener(new CutActionListener()); pasteItem.addActionListener(new PasteActionListener()); jMenuBar.add(jMenu); jPanel.add(jMenuBar); jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.Y_AXIS)); jPanel.add(textArea1); jPanel.add(Box.createRigidArea(new Dimension(0, 10))); jPanel.add(textArea2); getContentPane().add(jPanel, BorderLayout.CENTER); }