List of usage examples for javax.swing BoxLayout BoxLayout
@ConstructorProperties({ "target", "axis" }) public BoxLayout(Container target, int axis)
From source file:LayeredPaneDemo.java
public LayeredPaneDemo() { setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); // Create and load the duke icon. final ImageIcon icon = new ImageIcon("yourFile.gif"); // Create and set up the layered pane. layeredPane = new JLayeredPane(); layeredPane.setPreferredSize(new Dimension(300, 310)); layeredPane.setBorder(BorderFactory.createTitledBorder("Move the Mouse to Move Duke")); layeredPane.addMouseMotionListener(this); // This is the origin of the first label added. Point origin = new Point(10, 20); // This is the offset for computing the origin for the next label. int offset = 35; // Add several overlapping, colored labels to the layered pane // using absolute positioning/sizing. for (int i = 0; i < layerStrings.length; i++) { JLabel label = createColoredLabel(layerStrings[i], layerColors[i], origin); layeredPane.add(label, new Integer(i)); origin.x += offset;/* w ww.java 2s .c o m*/ origin.y += offset; } // Create and add the Duke label to the layered pane. dukeLabel = new JLabel(icon); if (icon != null) { dukeLabel.setBounds(15, 225, icon.getIconWidth(), icon.getIconHeight()); } else { System.err.println("Duke icon not found; using black square instead."); dukeLabel.setBounds(15, 225, 30, 30); dukeLabel.setOpaque(true); dukeLabel.setBackground(Color.BLACK); } layeredPane.add(dukeLabel, new Integer(2), 0); // Add control pane and layered pane to this JPanel. add(Box.createRigidArea(new Dimension(0, 10))); add(createControlPanel()); add(Box.createRigidArea(new Dimension(0, 10))); add(layeredPane); }
From source file:edu.ku.brc.specify.plugins.SeriesProcCatNumPlugin.java
/** * @param textFieldStart/*w w w.ja v a 2 s . co m*/ * @param textFieldEnd */ public SeriesProcCatNumPlugin(final ValFormattedTextFieldIFace textFieldStart, final ValFormattedTextFieldIFace textFieldEnd) { super(); this.textFieldStart = textFieldStart; this.textFieldEnd = textFieldEnd; this.expandBtn = UIHelper.createIconBtn("move_right", "", null); pb = new PanelBuilder(new FormLayout("p,f:p:g", "c:p"), this); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.add(textFieldStart.getValidatableUIComp()); panel.add(textFieldEnd.getValidatableUIComp()); panel.add(expandBtn); expandBtn.setEnabled(true); pb.add(panel, cc.xy(1, 1)); expandBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doToggleContract(); } }); textFieldEnd.setAutoNumberEnabled(false); textFieldEnd.getValidatableUIComp().setEnabled(true); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { isExpanded = true; expandBtn.doClick(); expandBtn.setVisible(false); } }); }
From source file:biomine.bmvis2.pipeline.TwoPhaseExtractOperation.java
@Override public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) { int tot = SimplificationUtils.countNormalEdges(graph); if (oldTot != 0) { int nt = (target * tot) / oldTot; if (nt != target) { target = Math.max(nt, target); }// w w w . j a v a 2s.c om } else { target = tot; } oldTot = tot; JPanel ret = new JPanel(); final JSlider sl = new JSlider(0, tot, Math.min(target, tot)); sl.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { if (target == sl.getValue()) return; target = sl.getValue(); v.settingsChanged(false); } }); ret.setLayout(new BoxLayout(ret, BoxLayout.Y_AXIS)); ret.add(sl); return ret; }
From source file:AnimatedPasswordField.java
public AnimatedPasswordField(String labelText, boolean useBgImage, Color defaultForeground, boolean allowAnimate) { this.setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); label.setText(labelText);// ww w.ja va 2 s . c o m textField.addFocusListener(this); label.setBackground(colors[0]); textField.setBackground(colors[0]); this.foreground = defaultForeground; this.allowAnimate = allowAnimate; label.setForeground(foreground); textField.setForeground(foreground); add(label); add(textField); if (allowAnimate) runThread.start(); if (allowFade) { fadeInThread.start(); fadeOutThread.start(); } setOpaque(false); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopPopupButton.java
public DesktopPopupButton() { popup = new JPopupMenu(); impl = new JButton(); impl.setLayout(new BoxLayout(impl, BoxLayout.X_AXIS)); captionLabel = new JLabel(); impl.add(Box.createHorizontalGlue()); impl.add(captionLabel);//from w w w . java 2s.c o m captionLabel.setAlignmentX(CENTER_ALIGNMENT); rightIcon = new JLabel(); rightIcon.setIcon(resources.getIcon(DROP_DOWN_ICON)); rightIcon.setAlignmentX(CENTER_ALIGNMENT); impl.add(rightIcon); impl.add(Box.createHorizontalGlue()); impl.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (popup.isVisible()) popup.setVisible(false); else showPopup(); } }); DesktopComponentsHelper.adjustSize(impl); }
From source file:com.hazelcast.simulator.visualiser.ui.Chart.java
public Chart(Model model, AccuracyRadioButtons accuracyRadioButtons, AutoScaleRadioButtons autoScaleRadioButtons, ProbesCheckboxes probesCheckboxes) { this.model = model; this.accuracyRadioButtons = accuracyRadioButtons; this.autoScaleRadioButtons = autoScaleRadioButtons; this.probesCheckboxes = probesCheckboxes; setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); setLayout(new BorderLayout()); initSliders();//from w w w. ja v a 2s . c om JPanel horizontalSlidersPanel = new JPanel(); horizontalSlidersPanel.setLayout(new BoxLayout(horizontalSlidersPanel, BoxLayout.Y_AXIS)); horizontalSlidersPanel.add(mainHorizontalSlider); horizontalSlidersPanel.add(fineHorizontalSlider); JFreeChart chart = ChartFactory.createHistogram("Latency Distribution", "Latency (s)", "Operations", null, PlotOrientation.VERTICAL, true, true, true); plot = chart.getXYPlot(); plot.setForegroundAlpha(ALPHA); ChartPanel chartPanel = new ChartPanel(null); chartPanel.setChart(chart); add(horizontalSlidersPanel, BorderLayout.SOUTH); add(verticalSlider, BorderLayout.EAST); add(chartPanel, BorderLayout.CENTER); initSliderChangeListener(); }
From source file:ChooseDropActionDemo.java
public ChooseDropActionDemo() { super("ChooseDropActionDemo"); for (int i = 15; i >= 0; i--) { from.add(0, "Source item " + i); }/*w w w .j a va 2 s .co m*/ for (int i = 2; i >= 0; i--) { copy.add(0, "Target item " + i); move.add(0, "Target item " + i); } JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); dragFrom = new JList(from); dragFrom.setTransferHandler(new FromTransferHandler()); dragFrom.setPrototypeCellValue("List Item WWWWWW"); dragFrom.setDragEnabled(true); dragFrom.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JLabel label = new JLabel("Drag from here:"); label.setAlignmentX(0f); p.add(label); JScrollPane sp = new JScrollPane(dragFrom); sp.setAlignmentX(0f); p.add(sp); add(p, BorderLayout.WEST); JList moveTo = new JList(move); moveTo.setTransferHandler(new ToTransferHandler(TransferHandler.COPY)); moveTo.setDropMode(DropMode.INSERT); JList copyTo = new JList(copy); copyTo.setTransferHandler(new ToTransferHandler(TransferHandler.MOVE)); copyTo.setDropMode(DropMode.INSERT); p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); label = new JLabel("Drop to COPY to here:"); ; label.setAlignmentX(0f); p.add(label); sp = new JScrollPane(moveTo); sp.setAlignmentX(0f); p.add(sp); label = new JLabel("Drop to MOVE to here:"); label.setAlignmentX(0f); p.add(label); sp = new JScrollPane(copyTo); sp.setAlignmentX(0f); p.add(sp); p.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 0)); add(p, BorderLayout.CENTER); ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); getContentPane().setPreferredSize(new Dimension(320, 315)); }
From source file:TableFilterDemo.java
public TableFilterDemo() { super();//from w ww .ja v a 2 s.c o m setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // Create a table with a sorter. MyTableModel model = new MyTableModel(); sorter = new TableRowSorter<MyTableModel>(model); table = new JTable(model); table.setRowSorter(sorter); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setFillsViewportHeight(true); // For the purposes of this example, better to have a single // selection. table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // When selection changes, provide user with row numbers for // both view and model. table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { int viewRow = table.getSelectedRow(); if (viewRow < 0) { // Selection got filtered away. statusText.setText(""); } else { int modelRow = table.convertRowIndexToModel(viewRow); statusText.setText(String.format("Selected Row in view: %d. " + "Selected Row in model: %d.", viewRow, modelRow)); } } }); // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); // Add the scroll pane to this panel. add(scrollPane); // Create a separate form for filterText and statusText JPanel form = new JPanel(new SpringLayout()); JLabel l1 = new JLabel("Filter Text:", SwingConstants.TRAILING); form.add(l1); filterText = new JTextField(); // Whenever filterText changes, invoke newFilter. filterText.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { newFilter(); } public void insertUpdate(DocumentEvent e) { newFilter(); } public void removeUpdate(DocumentEvent e) { newFilter(); } }); l1.setLabelFor(filterText); form.add(filterText); JLabel l2 = new JLabel("Status:", SwingConstants.TRAILING); form.add(l2); statusText = new JTextField(); l2.setLabelFor(statusText); form.add(statusText); SpringUtilities.makeCompactGrid(form, 2, 2, 6, 6, 6, 6); add(form); }
From source file:net.sf.mzmine.modules.visualization.ida.IDABottomPanel.java
IDABottomPanel(IDAVisualizerWindow masterFrame, RawDataFile dataFile, ParameterSet parameters) { this.dataFile = dataFile; this.masterFrame = masterFrame; setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); setBackground(Color.white);/*from w ww .j av a 2 s . co m*/ setBorder(new EmptyBorder(5, 5, 5, 0)); add(Box.createHorizontalGlue()); GUIUtils.addLabel(this, "Show: ", SwingConstants.RIGHT); thresholdCombo = new JComboBox<Object>(PeakThresholdMode.values()); thresholdCombo.setSelectedItem(PeakThresholdMode.NONE); thresholdCombo.setBackground(Color.white); thresholdCombo.setFont(smallFont); thresholdCombo.addActionListener(this); add(thresholdCombo); JPanel peakThresholdPanel = new JPanel(); peakThresholdPanel.setBackground(Color.white); peakThresholdPanel.setLayout(new BoxLayout(peakThresholdPanel, BoxLayout.X_AXIS)); GUIUtils.addLabel(peakThresholdPanel, "Value: ", SwingConstants.RIGHT); peakTextField = new JTextField(); peakTextField.setPreferredSize(new Dimension(50, 15)); peakTextField.setFont(smallFont); peakTextField.addActionListener(this); peakThresholdPanel.add(peakTextField); add(peakThresholdPanel); GUIUtils.addLabel(this, " from peak list: ", SwingConstants.RIGHT); peakListSelector = new JComboBox<PeakList>(); peakListSelector.setBackground(Color.white); peakListSelector.setFont(smallFont); peakListSelector.addActionListener(masterFrame); peakListSelector.setActionCommand("PEAKLIST_CHANGE"); add(peakListSelector); thresholdSettings = parameters.getParameter(IDAParameters.peakThresholdSettings); thresholdCombo.setSelectedItem(thresholdSettings.getMode()); add(Box.createHorizontalStrut(10)); add(Box.createHorizontalGlue()); }
From source file:net.sf.mzmine.modules.visualization.msms.MsMsBottomPanel.java
MsMsBottomPanel(MsMsVisualizerWindow masterFrame, RawDataFile dataFile, ParameterSet parameters) { this.dataFile = dataFile; this.masterFrame = masterFrame; setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); setBackground(Color.white);//from www.j a v a 2s .c o m setBorder(new EmptyBorder(5, 5, 5, 0)); add(Box.createHorizontalGlue()); GUIUtils.addLabel(this, "Show: ", SwingConstants.RIGHT); thresholdCombo = new JComboBox<Object>(PeakThresholdMode.values()); thresholdCombo.setSelectedItem(PeakThresholdMode.NONE); thresholdCombo.setBackground(Color.white); thresholdCombo.setFont(smallFont); thresholdCombo.addActionListener(this); add(thresholdCombo); JPanel peakThresholdPanel = new JPanel(); peakThresholdPanel.setBackground(Color.white); peakThresholdPanel.setLayout(new BoxLayout(peakThresholdPanel, BoxLayout.X_AXIS)); GUIUtils.addLabel(peakThresholdPanel, "Value: ", SwingConstants.RIGHT); peakTextField = new JTextField(); peakTextField.setPreferredSize(new Dimension(50, 15)); peakTextField.setFont(smallFont); peakTextField.addActionListener(this); peakThresholdPanel.add(peakTextField); add(peakThresholdPanel); GUIUtils.addLabel(this, " from peak list: ", SwingConstants.RIGHT); peakListSelector = new JComboBox<PeakList>(); peakListSelector.setBackground(Color.white); peakListSelector.setFont(smallFont); peakListSelector.addActionListener(masterFrame); peakListSelector.setActionCommand("PEAKLIST_CHANGE"); add(peakListSelector); thresholdSettings = parameters.getParameter(MsMsParameters.peakThresholdSettings); thresholdCombo.setSelectedItem(thresholdSettings.getMode()); add(Box.createHorizontalStrut(10)); add(Box.createHorizontalGlue()); }