Example usage for javax.swing Box Box

List of usage examples for javax.swing Box Box

Introduction

In this page you can find the example usage for javax.swing Box Box.

Prototype

public Box(int axis) 

Source Link

Document

Creates a Box that displays its components along the specified axis.

Usage

From source file:net.ontopia.topicmaps.viz.AboutFrame.java

private Component createImagePanel() {
    Box main = new Box(BoxLayout.X_AXIS);
    Icon aboutImage = this.getAboutImage();
    JLabel imageLabel;//from w  w  w .java 2  s . c  om
    if (aboutImage == null)
        imageLabel = new JLabel("Ontopia AS - The TopicMap People");
    else
        imageLabel = new JLabel(aboutImage);
    main.add(imageLabel);
    return main;
}

From source file:RGBAColourChooser.java

/**
 * Constructs a new RGBAColourChooser/*from ww w  .j  av a 2  s.com*/
 */
public RGBAColourChooser() {
    super(BoxLayout.X_AXIS);

    Box rb = new Box(BoxLayout.X_AXIS);
    rb.add(redLabel);
    rb.add(redSlider);
    Box gb = new Box(BoxLayout.X_AXIS);
    gb.add(greenLabel);
    gb.add(greenSlider);
    Box bb = new Box(BoxLayout.X_AXIS);
    bb.add(blueLabel);
    bb.add(blueSlider);
    Box ab = new Box(BoxLayout.X_AXIS);
    ab.add(alphaLabel);
    ab.add(alphaSlider);

    redSlider.setValue(oldValue.getRed());
    greenSlider.setValue(oldValue.getGreen());
    blueSlider.setValue(oldValue.getBlue());
    alphaSlider.setValue(oldValue.getAlpha());

    redSlider.addChangeListener(this);
    greenSlider.addChangeListener(this);
    blueSlider.addChangeListener(this);
    alphaSlider.addChangeListener(this);

    redSlider.setToolTipText(String.valueOf(redSlider.getValue()));
    greenSlider.setToolTipText(String.valueOf(greenSlider.getValue()));
    blueSlider.setToolTipText(String.valueOf(blueSlider.getValue()));
    alphaSlider.setToolTipText(String.valueOf(alphaSlider.getValue()));

    sliderBox = new Box(BoxLayout.Y_AXIS);
    sliderBox.add(rb);
    sliderBox.add(gb);
    sliderBox.add(bb);
    sliderBox.add(ab);

    add(previewer);
    add(Box.createHorizontalStrut(5));
    add(sliderBox);

}

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  .ja  v a 2  s.  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:Transfer.java

public Transfer() {

    // Establish the GUI
    Container cp = new Box(BoxLayout.X_AXIS);
    setContentPane(cp);//from  w  w  w . ja va2 s.  co  m
    JPanel firstPanel = new JPanel();
    propertyComboBox = new JComboBox();
    propertyComboBox.addItem("text");
    propertyComboBox.addItem("font");
    propertyComboBox.addItem("background");
    propertyComboBox.addItem("foreground");
    firstPanel.add(propertyComboBox);
    cp.add(firstPanel);
    cp.add(Box.createGlue());

    tf = new JTextField("Hello");
    tf.setForeground(Color.RED);
    tf.setDragEnabled(true);
    cp.add(tf);

    cp.add(Box.createGlue());

    l = new JLabel("Hello");
    l.setBackground(Color.YELLOW);
    cp.add(l);

    cp.add(Box.createGlue());

    JSlider stryder = new JSlider(SwingConstants.VERTICAL);
    stryder.setMinimum(10);
    stryder.setValue(14);
    stryder.setMaximum(72);
    stryder.setMajorTickSpacing(10);
    stryder.setPaintTicks(true);

    cp.add(stryder);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(500, 300);

    // Add Listeners and Converters
    setMyTransferHandlers((String) propertyComboBox.getSelectedItem());

    // Mousing in the Label starts a Drag.
    MouseListener myDragListener = new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            JComponent c = (JComponent) e.getSource();
            TransferHandler handler = c.getTransferHandler();
            handler.exportAsDrag(c, e, TransferHandler.COPY);
        }
    };
    l.addMouseListener(myDragListener);

    // Selecting in the ComboBox makes that the property that is xfered.
    propertyComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ce) {
            JComboBox bx = (JComboBox) ce.getSource();
            String prop = (String) bx.getSelectedItem();
            setMyTransferHandlers(prop);
        }
    });

    // Typing a word and pressing enter in the TextField tries
    // to set that as the font name.
    tf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            JTextField jtf = (JTextField) evt.getSource();
            String fontName = jtf.getText();
            Font font = new Font(fontName, Font.BOLD, 18);
            tf.setFont(font);
        }
    });

    // Setting the Slider sets that font into the textfield.
    stryder.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent evt) {
            JSlider sl = (JSlider) evt.getSource();
            Font oldf = tf.getFont();
            Font newf = oldf.deriveFont((float) sl.getValue());
            tf.setFont(newf);
        }
    });

}

From source file:biomine.bmvis2.pipeline.KMedoidsHighlight.java

@Override
public JComponent getSettingsComponent(final SettingsChangeCallback v, VisualGraph graph) {
    Box ret = new Box(BoxLayout.X_AXIS);
    ret.add(new JLabel("k:"));

    final JSpinner spin = new JSpinner(new SpinnerNumberModel(3, 1, 1000, 1));

    spin.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            setK(((Number) spin.getValue()).intValue());
            v.settingsChanged(false);// w  w w. j  a v a 2 s . c o m
        }
    });
    ret.add(spin);

    final JCheckBox showClustersBox = new JCheckBox("Color clusters");
    ret.add(showClustersBox);
    showClustersBox.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent arg0) {
            showClusters = showClustersBox.isSelected();
            v.settingsChanged(false);
        }
    });
    return ret;
}

From source file:fll.scheduler.ChooseChallengeDescriptor.java

private void initComponents() {
    getContentPane().setLayout(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1;//  ww w .j av a 2s  . c o m
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    final JTextArea instructions = new JTextArea(
            "Choose a challenge description from the drop down list OR choose a file containing your custom challenge description.",
            3, 40);
    instructions.setEditable(false);
    instructions.setWrapStyleWord(true);
    instructions.setLineWrap(true);
    getContentPane().add(instructions, gbc);

    gbc = new GridBagConstraints();
    mCombo = new JComboBox<DescriptionInfo>();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    getContentPane().add(mCombo, gbc);
    mCombo.setRenderer(new DescriptionInfoRenderer());
    mCombo.setEditable(false);
    final List<DescriptionInfo> descriptions = DescriptionInfo.getAllKnownChallengeDescriptionInfo();
    for (final DescriptionInfo info : descriptions) {
        mCombo.addItem(info);
    }

    mFileField = new JLabel();
    gbc = new GridBagConstraints();
    gbc.weightx = 1;
    getContentPane().add(mFileField, gbc);

    final JButton chooseButton = new JButton("Choose File");
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    getContentPane().add(chooseButton, gbc);
    chooseButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ae) {
            mFileField.setText(null);

            final JFileChooser fileChooser = new JFileChooser();
            final FileFilter filter = new BasicFileFilter("FLL Description (xml)", new String[] { "xml" });
            fileChooser.setFileFilter(filter);

            final int returnVal = fileChooser.showOpenDialog(ChooseChallengeDescriptor.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                final File selectedFile = fileChooser.getSelectedFile();
                mFileField.setText(selectedFile.getAbsolutePath());
            }
        }
    });

    final Box buttonPanel = new Box(BoxLayout.X_AXIS);
    gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    getContentPane().add(buttonPanel, gbc);

    buttonPanel.add(Box.createHorizontalGlue());
    final JButton ok = new JButton("Ok");
    buttonPanel.add(ok);
    ok.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ae) {

            // use the selected description if nothing is entered in the file box
            final DescriptionInfo descriptionInfo = mCombo.getItemAt(mCombo.getSelectedIndex());
            if (null != descriptionInfo) {
                mSelected = descriptionInfo.getURL();
            }

            final String text = mFileField.getText();
            if (!StringUtils.isEmpty(text)) {
                final File file = new File(text);
                if (file.exists()) {
                    try {
                        mSelected = file.toURI().toURL();
                    } catch (final MalformedURLException e) {
                        throw new FLLInternalException("Can't turn file into URL?", e);
                    }
                }
            }

            setVisible(false);
        }
    });

    final JButton cancel = new JButton("Cancel");
    buttonPanel.add(cancel);
    cancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent ae) {
            mSelected = null;
            setVisible(false);
        }
    });

    pack();
}

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);//from   ww  w.  j  a  v a2 s. c o m
    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:it.iit.genomics.cru.igb.bundles.mi.view.MIResultPanel.java

public MIResultPanel(IgbService service, String summary, List<MIResult> results, String label, MIQuery query) {
    setLayout(new BorderLayout());

    this.label = label;

    igbLogger = IGBLogger.getInstance(label);

    colorer = TaxonColorer.getColorer(query.getTaxid());

    Box menuBox = new Box(BoxLayout.X_AXIS);

    Box buttonBox = new Box(BoxLayout.Y_AXIS);
    Box buttonBox1 = new Box(BoxLayout.X_AXIS);

    Box buttonBox3 = new Box(BoxLayout.X_AXIS);
    buttonBox.add(buttonBox1);//from www.  j a  v a  2  s . c o m

    buttonBox.add(buttonBox3);

    JTextPane querySummary = new JTextPane();
    querySummary.setContentType("text/html");
    querySummary.setEditable(false);
    querySummary.setText(summary);

    menuBox.add(querySummary);

    menuBox.add(buttonBox);

    final JFrame logFrame = new JFrame("MI Bundle Log");
    logFrame.setVisible(false);
    Dimension preferredSize = new Dimension(800, 500);

    logFrame.setPreferredSize(preferredSize);
    logFrame.setMinimumSize(preferredSize);

    logFrame.add(new LogPanel(igbLogger));

    JButton log = new JButton();

    if (igbLogger.hasError()) {
        log.setBackground(Color.red);
    }

    log.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/console.png"));

    log.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            logFrame.setVisible(true);
        }

    });

    buttonBox1.add(log);

    JButton networkButton = new JButton("");
    networkButton.setIcon(new ImageIcon(getClass().getResource("/network.jpg")));
    networkButton.addActionListener(new DisplayNetworkActionListener());

    buttonBox1.add(networkButton);

    buttonBox1.add(new JSeparator(JSeparator.VERTICAL));

    buttonBox1.add(new JLabel("Save: "));
    JButton exportButton = new JButton("text");
    exportButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png"));
    exportButton.addActionListener(new ExportActionListener());

    if (false == MICommons.testVersion) {
        buttonBox1.add(exportButton);
    }

    JButton exportXgmmlButton = new JButton("xgmml");
    exportXgmmlButton.setIcon(CommonUtils.getInstance().getIcon("16x16/actions/save.png"));
    exportXgmmlButton.addActionListener(new ExportXgmmlActionListener());
    if (false == MICommons.testVersion) {
        buttonBox1.add(exportXgmmlButton);
    }

    buttonBox1.add(new JSeparator(JSeparator.VERTICAL));

    buttonBox1.add(new JLabel("View structure: "));

    structures = new StructuresPanel(service, label);

    buttonBox1.add(structures.getJmolButton());
    buttonBox1.add(structures.getLinkButton());

    // Filters
    ButtonGroup scoreGroup = new ButtonGroup();
    JRadioButton scoreButton0 = new JRadioButton("<html>" + HTML_SCORE_0 + "</html>");
    JRadioButton scoreButton1 = new JRadioButton("<html>" + HTML_SCORE_1 + "</html>");
    JRadioButton scoreButton2 = new JRadioButton("<html>" + HTML_SCORE_2 + "</html>");
    JRadioButton scoreButton3 = new JRadioButton("<html>" + HTML_SCORE_3 + "</html>");
    scoreButton0.setSelected(true);

    ScoreListener scoreListener = new ScoreListener();
    scoreButton0.addActionListener(scoreListener);
    scoreButton1.addActionListener(scoreListener);
    scoreButton2.addActionListener(scoreListener);
    scoreButton3.addActionListener(scoreListener);

    scoreGroup.add(scoreButton0);
    scoreGroup.add(scoreButton1);
    scoreGroup.add(scoreButton2);
    scoreGroup.add(scoreButton3);

    buttonBox1.add(new JSeparator(JSeparator.VERTICAL));
    buttonBox1.add(new JLabel("Score: "));
    buttonBox1.add(scoreButton0);
    buttonBox1.add(scoreButton1);
    buttonBox1.add(scoreButton2);
    buttonBox1.add(scoreButton3);

    buttonBox3.add(new JLabel("Interaction type: "));

    JCheckBox EvidencePhysicalButton = new JCheckBox(HTML_CHECKBOX_PHYSICAL);
    JCheckBox EvidenceAssociationButton = new JCheckBox(HTML_CHECKBOX_ASSOCIATION);
    JCheckBox EvidenceEnzymaticButton = new JCheckBox(HTML_CHECKBOX_ENZYMATIC);
    JCheckBox EvidenceOtherButton = new JCheckBox(HTML_CHECKBOX_OTHER);
    JCheckBox EvidenceUnspecifiedButton = new JCheckBox(HTML_CHECKBOX_UNSPECIFIED);
    JCheckBox EvidenceStructureButton = new JCheckBox(HTML_CHECKBOX_STRUCTURE);

    EvidencePhysicalButton.setSelected(true);
    EvidenceAssociationButton.setSelected(true);
    EvidenceEnzymaticButton.setSelected(true);
    EvidenceOtherButton.setSelected(true);
    EvidenceUnspecifiedButton.setSelected(true);
    EvidenceStructureButton.setSelected(true);

    buttonBox3.add(EvidencePhysicalButton);
    buttonBox3.add(EvidenceAssociationButton);
    buttonBox3.add(EvidenceEnzymaticButton);
    buttonBox3.add(EvidenceOtherButton);
    buttonBox3.add(EvidenceUnspecifiedButton);
    buttonBox3.add(EvidenceStructureButton);

    EvidenceTypeListener evidenceListener = new EvidenceTypeListener();
    EvidencePhysicalButton.addActionListener(evidenceListener);
    EvidenceAssociationButton.addActionListener(evidenceListener);
    EvidenceEnzymaticButton.addActionListener(evidenceListener);
    EvidenceOtherButton.addActionListener(evidenceListener);
    EvidenceUnspecifiedButton.addActionListener(evidenceListener);
    EvidenceStructureButton.addActionListener(evidenceListener);

    Box tableBox = new Box(BoxLayout.Y_AXIS);

    MITableModel model = new MITableModel(results);

    miTable = new MITable(model, service, query);

    miTable.setFillsViewportHeight(true);

    miTable.setStructuresPanel(structures);

    tableBox.add(miTable.getTableHeader());
    tableBox.add(miTable);

    JScrollPane tableScroll = new JScrollPane(tableBox);

    tableScroll.setMinimumSize(new Dimension(800, 50));
    tableScroll.setPreferredSize(new Dimension(800, 50));
    tableScroll.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));

    structures.setMinimumSize(new Dimension(200, 500));
    structures.setPreferredSize(new Dimension(200, 500));
    structures.setMaximumSize(new Dimension(200, Short.MAX_VALUE));

    resultBox = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tableScroll, structures);
    resultBox.setOneTouchExpandable(true);

    add(menuBox, BorderLayout.NORTH);
    add(resultBox, BorderLayout.CENTER);

}

From source file:org.rdv.ui.ControlPanel.java

/**
 * Setup the UI.//from  www  .j a  va2 s.c o  m
 */
private void initPanel() {
    setLayout(new BorderLayout());

    GridBagConstraints c = new GridBagConstraints();

    JPanel container = new JPanel();
    container.setLayout(new GridBagLayout());

    Box firstRowPanel = new Box(BoxLayout.LINE_AXIS);

    beginButton = new JButton();
    beginButton.setName("beginButton");
    beginButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setLocationBegin();
        }
    });
    firstRowPanel.add(beginButton);

    rtButton = new JButton();
    rtButton.setName("rtButton");
    rtButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (rtButton.isSelected()) {
                rbnbController.pause();
            } else {
                rbnbController.monitor();
            }
        }
    });
    firstRowPanel.add(rtButton);

    playButton = new JButton();
    playButton.setName("playButton");
    playButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (playButton.isSelected()) {
                rbnbController.pause();
            } else {
                rbnbController.play();
            }
        }
    });
    firstRowPanel.add(playButton);

    endButton = new JButton();
    endButton.setName("endButton");
    endButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setLocationEnd();
        }
    });
    firstRowPanel.add(endButton);

    firstRowPanel.add(Box.createHorizontalStrut(8));

    SpinnerListModel playbackRateModel = new SpinnerListModel(playbackRates);
    playbackRateSpinner = new JSpinner(playbackRateModel);
    playbackRateSpinner.setName("playbackRateSpinner");
    JSpinner.ListEditor playbackRateEditor = new JSpinner.ListEditor(playbackRateSpinner);
    playbackRateEditor.getTextField().setEditable(false);
    playbackRateSpinner.setEditor(playbackRateEditor);
    playbackRateSpinner.setPreferredSize(new Dimension(80, playbackRateSpinner.getPreferredSize().height));
    playbackRateSpinner.setMinimumSize(playbackRateSpinner.getPreferredSize());
    playbackRateSpinner.setMaximumSize(playbackRateSpinner.getPreferredSize());
    playbackRateSpinner.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            playbackRateChanged();
        }
    });
    firstRowPanel.add(playbackRateSpinner);

    firstRowPanel.add(Box.createHorizontalStrut(8));

    timeScaleComboBox = new JComboBox();
    timeScaleComboBox.setName("timeScaleComboBox");
    timeScaleComboBox.setEditable(true);
    timeScaleComboBox.setPreferredSize(new Dimension(96, timeScaleComboBox.getPreferredSize().height));
    timeScaleComboBox.setMinimumSize(timeScaleComboBox.getPreferredSize());
    timeScaleComboBox.setMaximumSize(timeScaleComboBox.getPreferredSize());
    for (int i = 0; i < timeScales.length; i++) {
        timeScaleComboBox.addItem(DataViewer.formatSeconds(timeScales[i]));
    }
    timeScaleComboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            timeScaleChange();
        }
    });
    firstRowPanel.add(timeScaleComboBox);

    firstRowPanel.add(Box.createHorizontalGlue());

    locationButton = new JButton();
    locationButton.setName("locationButton");
    locationButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            TimeRange timeRange = RBNBHelper.getChannelsTimeRange();
            double time = DateTimeDialog.showDialog(ControlPanel.this, rbnbController.getLocation(),
                    timeRange.start, timeRange.end);
            if (time >= 0) {
                rbnbController.setLocation(time);
            }
        }
    });
    firstRowPanel.add(locationButton);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;
    c.insets = new java.awt.Insets(8, 8, 8, 8);
    c.anchor = GridBagConstraints.NORTHWEST;
    container.add(firstRowPanel, c);

    zoomTimeSlider = new TimeSlider();
    zoomTimeSlider.setRangeChangeable(false);
    zoomTimeSlider.addTimeAdjustmentListener(this);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;
    c.insets = new java.awt.Insets(0, 8, 0, 8);
    c.anchor = GridBagConstraints.NORTHWEST;
    container.add(zoomTimeSlider, c);

    JPanel zoomTimePanel = new JPanel();
    zoomTimePanel.setLayout(new BorderLayout());

    zoomMinimumLabel = new JLabel();
    zoomMinimumLabel.setName("zoomMinimumLabel");
    zoomTimePanel.add(zoomMinimumLabel, BorderLayout.WEST);

    zoomRangeLabel = new JLabel();
    zoomRangeLabel.setName("zoomRangeLabel");
    zoomRangeLabel.setHorizontalAlignment(JLabel.CENTER);
    zoomTimePanel.add(zoomRangeLabel, BorderLayout.CENTER);

    zoomMaximumLabel = new JLabel();
    zoomMaximumLabel.setName("zoomMaximumLabel");
    zoomTimePanel.add(zoomMaximumLabel, BorderLayout.EAST);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;
    c.insets = new java.awt.Insets(8, 8, 0, 8);
    c.anchor = GridBagConstraints.NORTHWEST;
    container.add(zoomTimePanel, c);

    globalTimeSlider = new TimeSlider();
    globalTimeSlider.setValueChangeable(false);
    globalTimeSlider.addTimeAdjustmentListener(this);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.weighty = 1;
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.ipadx = 0;
    c.ipady = 0;
    c.insets = new java.awt.Insets(8, 8, 8, 8);
    c.anchor = GridBagConstraints.NORTHWEST;
    container.add(globalTimeSlider, c);

    add(container, BorderLayout.CENTER);

    log.info("Initialized control panel.");
}

From source file:edu.gmu.cs.sim.util.media.chart.SeriesAttributes.java

/** Builds a SeriesAttributes with the provided generator, name for the series, and index for the series.  Calls
 buildAttributes to construct custom elements in the LabelledList, then finally calls rebuildGraphicsDefinitions()
 to update the series. *//*from ww  w.  ja  v a2 s .c  o  m*/
public SeriesAttributes(ChartGenerator generator, String name, int index, SeriesChangeListener stoppable) {
    super(name);
    setStoppable(stoppable);
    this.generator = generator;
    seriesIndex = index;
    final JCheckBox check = new JCheckBox();
    check.setSelected(true);
    check.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setPlotVisible(check.isSelected());
        }
    });

    manipulators = new Box(BoxLayout.X_AXIS);
    buildManipulators();
    JLabel spacer = new JLabel("");
    spacer.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
    Box b = new Box(BoxLayout.X_AXIS);
    b.add(check);
    b.add(spacer);
    b.add(manipulators);
    b.add(Box.createGlue());
    addLabelled("Show", b);

    final PropertyField nameF = new PropertyField(name) {
        public String newValue(String newValue) {
            SeriesAttributes.this.setSeriesName(newValue);
            rebuildGraphicsDefinitions();
            return newValue;
        }
    };
    addLabelled("Series", nameF);

    buildAttributes();
    rebuildGraphicsDefinitions();
}