List of usage examples for javax.swing BoxLayout BoxLayout
@ConstructorProperties({ "target", "axis" }) public BoxLayout(Container target, int axis)
From source file:org.cytoscape.dyn.internal.graphMetrics.GraphMetricsResultsPanel.java
/** * //from ww w . ja v a 2 s . c o m */ public void initComponents() { enlargeButton = new JButton("Enlarge Chart"); enlargeButton.addActionListener(this); enlargeButton.setToolTipText("View chart in a new window."); saveChartButton = new JButton("Save Chart"); saveChartButton.addActionListener(this); saveChartButton.setToolTipText("Save the chart as a .jpg/.png/.svg file."); saveDataButton = new JButton("Save Data"); saveDataButton.addActionListener(this); saveDataButton.setToolTipText("Save data in a file."); closeTabButton = new JButton("Close Tab"); closeTabButton.addActionListener(this); closeTabButton.setToolTipText("Close this tab."); helpButton = new JButton("Help"); helpButton.setToolTipText("Get help!"); helpButton.addActionListener(this); buttonsPanel = new JPanel(); chartPanel = new ChartPanel(this.timeSeries); buttonsPanel.add(enlargeButton); buttonsPanel.add(saveChartButton); buttonsPanel.add(saveDataButton); buttonsPanel.add(closeTabButton); buttonsPanel.add(helpButton); buttonsPanel.setLayout(new FlowLayout()); this.add(chartPanel); this.add(buttonsPanel); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.setVisible(true); }
From source file:events.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 w w . j a v a 2s.co 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:mavn.network.view.JUNGPanelAdapter.java
/** * Create an instance of a simple graph with popup controls to * create a graph./*ww w . j av a 2 s. co m*/ * */ public JUNGPanelAdapter(double[][] w2, double[][] w1, double[][] w0) { this.w2 = w2; this.w1 = w1; this.w0 = w0; this.setPreferredSize(new Dimension(600, 400)); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // create a simple graph for the demo graph = new DirectedSparseMultigraph<Number, Number>(); this.layout = new StaticLayout<Number, Number>(graph, new Dimension(600, 600)); if (w2.length > 0) { findIndicies(); createVerticies(); drawEdges(); drawVerticies(); } vv = new VisualizationViewer<Number, Number>(layout); vv.setBackground(Color.getColor("#333333")); vv.getRenderContext().setVertexLabelTransformer(MapTransformer.<Number, String>getInstance( LazyMap.<Number, String>decorate(new HashMap<Number, String>(), new ToStringLabeller<Number>()))); vv.setVertexToolTipTransformer(vv.getRenderContext().getVertexLabelTransformer()); vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line()); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); this.add(panel); final EditingModalGraphMouse<Number, Number> graphMouse = new EditingModalGraphMouse<Number, Number>( vv.getRenderContext(), vertexFactory, edgeFactory); Transformer<Number, Paint> vertexPaint = new Transformer<Number, Paint>() { @Override public Paint transform(Number i) { return Color.getHSBColor(0, 0.73f, 1); } }; vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint); // the EditingGraphMouse will pass mouse event coordinates to the // vertexLocations function to set the locations of the vertices as // they are created // graphMouse.setVertexLocations(vertexLocations); vv.setGraphMouse(graphMouse); vv.addKeyListener(graphMouse.getModeKeyListener()); graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); this.add(controls); this.setVisible(true); }
From source file:gdt.jgui.tool.JEntityEditor.java
/** * The default consturctor./* w w w. j a v a 2s . com*/ */ public JEntityEditor() { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); tabbedPane = new JTabbedPane(JTabbedPane.TOP); add(tabbedPane); }
From source file:ListDemo.java
public ListDemo() { super(new BorderLayout()); listModel = new DefaultListModel(); listModel.addElement("Debbie Scott"); listModel.addElement("Scott Hommel"); listModel.addElement("Sharon Zakhour"); // Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0);/* w w w . ja v a2 s .c o m*/ list.addListSelectionListener(this); list.setVisibleRowCount(5); JScrollPane listScrollPane = new JScrollPane(list); JButton hireButton = new JButton(hireString); HireListener hireListener = new HireListener(hireButton); hireButton.setActionCommand(hireString); hireButton.addActionListener(hireListener); hireButton.setEnabled(false); fireButton = new JButton(fireString); fireButton.setActionCommand(fireString); fireButton.addActionListener(new FireListener()); employeeName = new JTextField(10); employeeName.addActionListener(hireListener); employeeName.getDocument().addDocumentListener(hireListener); String name = listModel.getElementAt(list.getSelectedIndex()).toString(); // Create a panel that uses BoxLayout. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(fireButton); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(new JSeparator(SwingConstants.VERTICAL)); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(employeeName); buttonPane.add(hireButton); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); }
From source file:net.pandoragames.far.ui.swing.dialog.SaveFormDialog.java
private void init(SwingConfig config) { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); JPanel basePanel = new JPanel(); basePanel.setBorder(BorderFactory.createEmptyBorder(SwingConfig.PADDING * 2, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING)); basePanel.setLayout(new BorderLayout()); registerCloseWindowKeyListener(basePanel); this.add(basePanel); MessageLabel errorLabel = new MessageLabel(); basePanel.add(errorLabel, BorderLayout.NORTH); messageBox = errorLabel;/*from www . j a v a 2 s .c o m*/ JPanel centerPanel = new JPanel(); centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS)); JLabel titleLabel = new JLabel(localizer.localize("label.name")); titleLabel.setAlignmentX(0); centerPanel.add(titleLabel); textbox = new JTextField(); textbox.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH, config.getStandardComponentHight())); textbox.setAlignmentX(0); registerEnterKeyListener(textbox, saveAction); centerPanel.add(textbox); basePanel.add(centerPanel, BorderLayout.CENTER); JPanel buttonPannel = new JPanel(); buttonPannel.setLayout(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton(localizer.localize("button.save")); okButton.addActionListener(saveAction); JButton cancelButton = new JButton(localizer.localize("button.cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent eve) { SaveFormDialog.this.dispose(); } }); buttonPannel.add(okButton); buttonPannel.add(cancelButton); registerCloseWindowKeyListener(buttonPannel); this.add(buttonPannel, BorderLayout.SOUTH); }
From source file:es.emergya.ui.plugins.LayerSelectionDialog.java
public LayerSelectionDialog(CustomMapView gmv) { super();/*w w w . j av a 2 s . c om*/ self = this; this.setTitle("Otras Capas"); actualizando = new JLabel(LogicConstants.getIcon("anim_actualizando")); this.setAlwaysOnTop(true); this.mv = gmv; this.layers = new ArrayList<LayerElement>(); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getIconImage()); } catch (Throwable e1) { LOG.error("Couldn't find icon image", e1); } JPanel base = new JPanel(); base.setPreferredSize(new Dimension(240, 150)); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); base.add(new JLabel(i18n.getString("map.layers.avaliable"))); list = new JPanel(); list.setLayout(new BoxLayout(list, BoxLayout.Y_AXIS)); list.add(actualizando); list.setBackground(Color.WHITE); // list.setPreferredSize(new Dimension(100, 100)); final JScrollPane scrollPane = new JScrollPane(list); scrollPane.setBackground(Color.WHITE); base.add(scrollPane); mv.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { } }); add(base); pack(); }
From source file:be.ac.ua.comp.scarletnebula.gui.windows.ServerPropertiesWindow.java
private JPanel getBottomPanel() { final JPanel bottomPanel = new JPanel(); final JButton okButton = ButtonFactory.createOkButton(); okButton.addActionListener(new ActionListener() { @Override/*from ww w.j ava 2s .com*/ public void actionPerformed(final ActionEvent e) { ServerPropertiesWindow.this.dispose(); } }); getRootPane().setDefaultButton(okButton); bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.LINE_AXIS)); bottomPanel.add(Box.createHorizontalGlue()); bottomPanel.add(okButton); bottomPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 20, 20)); return bottomPanel; }
From source file:org.streamspinner.harmonica.application.CQGraphTerminal.java
private JPanel getJPanel1() { if (jPanel1 != null) return jPanel1; jPanel1 = new JPanel(); jPanel1.setMaximumSize(new Dimension(Short.MAX_VALUE, 150)); jPanel1.setPreferredSize(new Dimension(400, 150)); jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.LINE_AXIS)); jPanel1.add(getJPanel11());//from ww w . j a va 2s.co m jPanel1.add(getJPanel12()); return jPanel1; }
From source file:au.org.ala.delta.intkey.ui.FindInTaxaDialog.java
public FindInTaxaDialog(Intkey intkeyApp) { super(intkeyApp.getMainFrame(), false); setResizable(false);//from w w w .j a v a2 s.com ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(FindInTaxaDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(this); _intkeyApp = intkeyApp; _numMatchedTaxa = 0; _currentMatchedTaxon = -1; _findAction = actionMap.get("findTaxa"); _nextAction = actionMap.get("nextFoundTaxon"); this.setTitle(windowTitle); getContentPane().setLayout(new BorderLayout(0, 0)); _pnlMain = new JPanel(); _pnlMain.setBorder(new EmptyBorder(20, 20, 20, 20)); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(0, 0)); _pnlMainTop = new JPanel(); _pnlMain.add(_pnlMainTop, BorderLayout.NORTH); _pnlMainTop.setLayout(new BoxLayout(_pnlMainTop, BoxLayout.Y_AXIS)); _lblEnterSearchString = new JLabel(enterSearchStringCaption); _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 5, 0)); _lblEnterSearchString.setHorizontalAlignment(SwingConstants.LEFT); _lblEnterSearchString.setVerticalAlignment(SwingConstants.TOP); _lblEnterSearchString.setAlignmentY(Component.TOP_ALIGNMENT); _pnlMainTop.add(_lblEnterSearchString); _textField = new JTextField(); _textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { reset(); } @Override public void insertUpdate(DocumentEvent e) { reset(); } @Override public void changedUpdate(DocumentEvent e) { reset(); } }); _pnlMainTop.add(_textField); _textField.setColumns(10); _pnlMainMiddle = new JPanel(); _pnlMainMiddle.setBorder(new EmptyBorder(10, 0, 0, 0)); _pnlMain.add(_pnlMainMiddle, BorderLayout.CENTER); _pnlMainMiddle.setLayout(new BoxLayout(_pnlMainMiddle, BoxLayout.Y_AXIS)); _rdbtnSelectOne = new JRadioButton(selectOneCaption); _rdbtnSelectOne.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainMiddle.add(_rdbtnSelectOne); _rdbtnSelectAll = new JRadioButton(selectAllCaption); _rdbtnSelectAll.setSelected(true); _rdbtnSelectAll.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainMiddle.add(_rdbtnSelectAll); ButtonGroup radioButtonGroup = new ButtonGroup(); radioButtonGroup.add(_rdbtnSelectOne); radioButtonGroup.add(_rdbtnSelectAll); _pnlMainBottom = new JPanel(); _pnlMain.add(_pnlMainBottom, BorderLayout.SOUTH); _pnlMainBottom.setLayout(new BoxLayout(_pnlMainBottom, BoxLayout.Y_AXIS)); _chckbxSearchSynonyms = new JCheckBox(searchSynonymsCaption); _chckbxSearchSynonyms.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchSynonyms); _chckbxSearchEliminatedTaxa = new JCheckBox(searchEliminatedTaxaCaption); _chckbxSearchEliminatedTaxa.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchEliminatedTaxa); _pnlButtons = new JPanel(); _pnlButtons.setBorder(new EmptyBorder(20, 0, 0, 10)); getContentPane().add(_pnlButtons, BorderLayout.EAST); _pnlButtons.setLayout(new BorderLayout(0, 0)); _pnlInnerButtons = new JPanel(); _pnlButtons.add(_pnlInnerButtons, BorderLayout.NORTH); GridBagLayout gbl_pnlInnerButtons = new GridBagLayout(); gbl_pnlInnerButtons.columnWidths = new int[] { 0, 0 }; gbl_pnlInnerButtons.rowHeights = new int[] { 0, 0, 0, 0 }; gbl_pnlInnerButtons.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl_pnlInnerButtons.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; _pnlInnerButtons.setLayout(gbl_pnlInnerButtons); _btnFindNext = new JButton(); _btnFindNext.setAction(_findAction); GridBagConstraints gbc_btnFind = new GridBagConstraints(); gbc_btnFind.fill = GridBagConstraints.HORIZONTAL; gbc_btnFind.insets = new Insets(0, 0, 5, 0); gbc_btnFind.gridx = 0; gbc_btnFind.gridy = 0; _pnlInnerButtons.add(_btnFindNext, gbc_btnFind); _btnPrevious = new JButton(); _btnPrevious.setAction(actionMap.get("previousFoundTaxon")); _btnPrevious.setEnabled(false); GridBagConstraints gbc_btnPrevious = new GridBagConstraints(); gbc_btnPrevious.insets = new Insets(0, 0, 5, 0); gbc_btnPrevious.gridx = 0; gbc_btnPrevious.gridy = 1; _pnlInnerButtons.add(_btnPrevious, gbc_btnPrevious); _btnDone = new JButton(); _btnDone.setAction(actionMap.get("findTaxaDone")); GridBagConstraints gbc_btnDone = new GridBagConstraints(); gbc_btnDone.fill = GridBagConstraints.HORIZONTAL; gbc_btnDone.gridx = 0; gbc_btnDone.gridy = 2; _pnlInnerButtons.add(_btnDone, gbc_btnDone); this.pack(); this.setLocationRelativeTo(_intkeyApp.getMainFrame()); }