Example usage for javax.swing BoxLayout Y_AXIS

List of usage examples for javax.swing BoxLayout Y_AXIS

Introduction

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

Prototype

int Y_AXIS

To view the source code for javax.swing BoxLayout Y_AXIS.

Click Source Link

Document

Specifies that components should be laid out top to bottom.

Usage

From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java

protected void initGraphPanel() {
    //System.out.println("initGraphPanel called");
    graphPanel = new JPanel();

    graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));

    JFreeChart chart = createEmptyChart("SOCR Applications", null); //create a empty graph first
    chartPanel = new ChartPanel(chart, false);
    chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y));

    graphPanel.add(chartPanel);//from   ww  w  .  ja va  2s . c o  m
    graphPanel.validate();
}

From source file:VoteDialog.java

private JPanel createPane(String description, JRadioButton[] radioButtons, JButton showButton) {
    int numChoices = radioButtons.length;
    JPanel box = new JPanel();
    JLabel label = new JLabel(description);

    box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
    box.add(label);//from  w  w  w .  j a va2 s .  co  m

    for (int i = 0; i < numChoices; i++) {
        box.add(radioButtons[i]);
    }

    JPanel pane = new JPanel();
    pane.setLayout(new BorderLayout());
    pane.add(box, BorderLayout.NORTH);
    pane.add(showButton, BorderLayout.SOUTH);
    System.out.println("returning pane");
    return pane;
}

From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java

/**
 * Creates the UI panel containing all of the fields necessary to upload
 * the current session data to the web service
 *//*from   www  .j a  va  2 s  .  c  om*/
private void createSetupPane() {
    this.setupPanel = new JPanel();
    this.setupPanel.setLayout(new BorderLayout());
    this.setupPanel.setBackground(Color.white);

    try {
        String data = IOUtils.toString(LoginDialog.class.getResourceAsStream("/export2.html"));
        data = data.replace("{LIST}", formatWitnessList());
        JLabel txt = new JLabel(data);
        this.setupPanel.add(txt, BorderLayout.NORTH);
    } catch (IOException e) {
        // dunno. not much that can be done!
    }

    // ugly layout code to follow. avert your eyes
    JPanel data = new JPanel();
    data.setLayout(new BorderLayout());
    data.setBackground(Color.white);

    JPanel names = new JPanel();
    names.setLayout(new BoxLayout(names, BoxLayout.Y_AXIS));
    names.setBackground(Color.white);
    JLabel l = new JLabel("Name:", SwingConstants.RIGHT);
    l.setPreferredSize(new Dimension(100, 20));
    l.setMaximumSize(new Dimension(100, 20));
    l.setAlignmentX(RIGHT_ALIGNMENT);
    names.add(l);
    names.add(Box.createVerticalStrut(5));

    JLabel l2 = new JLabel("Description:", SwingConstants.RIGHT);
    l2.setPreferredSize(new Dimension(100, 20));
    l2.setMaximumSize(new Dimension(100, 20));
    l2.setAlignmentX(RIGHT_ALIGNMENT);
    names.add(l2);
    data.add(names, BorderLayout.WEST);

    JPanel edits = new JPanel();
    edits.setBackground(Color.white);
    edits.setLayout(new BoxLayout(edits, BoxLayout.Y_AXIS));
    this.nameEdit = new JTextField();
    this.nameEdit.setPreferredSize(new Dimension(200, 22));
    this.nameEdit.setMaximumSize(new Dimension(200, 22));
    File saveFile = this.juxtaFrame.getSession().getSaveFile();
    if (saveFile == null) {
        this.nameEdit.setText("new_session");
    } else {
        String name = saveFile.getName();
        this.nameEdit.setText(name.substring(0, name.lastIndexOf('.')));
    }
    edits.add(this.nameEdit);

    this.descriptionEdit = new JTextArea(3, 0);
    this.descriptionEdit.setLineWrap(true);
    this.descriptionEdit.setWrapStyleWord(true);

    JScrollPane sp = new JScrollPane(this.descriptionEdit);
    sp.setPreferredSize(new Dimension(194, 60));
    sp.setMaximumSize(new Dimension(194, 300));
    edits.add(Box.createVerticalStrut(4));
    edits.add(sp);

    data.add(edits, BorderLayout.CENTER);

    this.setupPanel.add(data, BorderLayout.SOUTH);
}

From source file:instance.gui.InstanceGUI.java

private void createDataSection() {
    dataSection = new JPanel();
    dataSection.setBorder(BorderFactory.createTitledBorder("Data block(s)"));
    dataSection.setLayout(new BoxLayout(dataSection, BoxLayout.Y_AXIS));

    createNumberOfRequestsLabel(dataSection);
    createCurrentTransfers(dataSection);
    createRequestQueue(dataSection);/*  w w  w  . j  av  a2  s .  co  m*/
    createDataBlockTable(dataSection);

    infoTab.add(dataSection);
}

From source file:SoundPlayer.java

public SoundPlayer(File f, boolean isMidi) throws IOException, UnsupportedAudioFileException,
        LineUnavailableException, MidiUnavailableException, InvalidMidiDataException {
    if (isMidi) { // The file is a MIDI file
        midi = true;/* w  w w .j  ava  2 s. c  o  m*/
        // First, get a Sequencer to play sequences of MIDI events
        // That is, to send events to a Synthesizer at the right time.
        sequencer = MidiSystem.getSequencer(); // Used to play sequences
        sequencer.open(); // Turn it on.

        // Get a Synthesizer for the Sequencer to send notes to
        Synthesizer synth = MidiSystem.getSynthesizer();
        synth.open(); // acquire whatever resources it needs

        // The Sequencer obtained above may be connected to a Synthesizer
        // by default, or it may not. Therefore, we explicitly connect it.
        Transmitter transmitter = sequencer.getTransmitter();
        Receiver receiver = synth.getReceiver();
        transmitter.setReceiver(receiver);

        // Read the sequence from the file and tell the sequencer about it
        sequence = MidiSystem.getSequence(f);
        sequencer.setSequence(sequence);
        audioLength = (int) sequence.getTickLength(); // Get sequence length
    } else { // The file is sampled audio
        midi = false;
        // Getting a Clip object for a file of sampled audio data is kind
        // of cumbersome. The following lines do what we need.
        AudioInputStream ain = AudioSystem.getAudioInputStream(f);
        try {
            DataLine.Info info = new DataLine.Info(Clip.class, ain.getFormat());
            clip = (Clip) AudioSystem.getLine(info);
            clip.open(ain);
        } finally { // We're done with the input stream.
            ain.close();
        }
        // Get the clip length in microseconds and convert to milliseconds
        audioLength = (int) (clip.getMicrosecondLength() / 1000);
    }

    // Now create the basic GUI
    play = new JButton("Play"); // Play/stop button
    progress = new JSlider(0, audioLength, 0); // Shows position in sound
    time = new JLabel("0"); // Shows position as a #

    // When clicked, start or stop playing the sound
    play.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (playing)
                stop();
            else
                play();
        }
    });

    // Whenever the slider value changes, first update the time label.
    // Next, if we're not already at the new position, skip to it.
    progress.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            int value = progress.getValue();
            // Update the time label
            if (midi)
                time.setText(value + "");
            else
                time.setText(value / 1000 + "." + (value % 1000) / 100);
            // If we're not already there, skip there.
            if (value != audioPosition)
                skip(value);
        }
    });

    // This timer calls the tick() method 10 times a second to keep
    // our slider in sync with the music.
    timer = new javax.swing.Timer(100, new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            tick();
        }
    });

    // put those controls in a row
    Box row = Box.createHorizontalBox();
    row.add(play);
    row.add(progress);
    row.add(time);

    // And add them to this component.
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    this.add(row);

    // Now add additional controls based on the type of the sound
    if (midi)
        addMidiControls();
    else
        addSampledControls();
}

From source file:edu.ucla.stat.SOCR.chart.SuperPieChart.java

public void setChart() {
    // update graph
    //   System.out.println("setChart called");

    graphPanel.removeAll();//from  w w  w  .j ava 2 s  . c o m
    graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));

    //chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y));

    if (legendPanelOn) {
        JFreeChart chart2 = createLegendChart(createLegend(dataset));
        legendPanel = new ChartPanel(chart2, false);
        //legendPanel.setPreferredSize(new Dimension(CHART_SIZE_X,CHART_SIZE_Y*2/3));
    }

    graphPanel.add(chartPanel);
    JScrollPane legendPane = new JScrollPane(legendPanel);
    if (legendPanelOn) {
        legendPane.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 5));
        graphPanel.add(legendPane);
    }

    graphPanel.validate();

    // get the GRAPH panel to the front
    if (tabbedPanelContainer.getTitleAt(tabbedPanelContainer.getSelectedIndex()) != ALL) {
        tabbedPanelContainer.setSelectedIndex(tabbedPanelContainer.indexOfComponent(graphPanel));
        graphPanel.removeAll();
        graphPanel.setLayout(new BoxLayout(graphPanel, BoxLayout.Y_AXIS));

        graphPanel.add(chartPanel);

        if (legendPanelOn) {
            legendPane = new JScrollPane(legendPanel);
            legendPane.setPreferredSize(new Dimension(CHART_SIZE_X, CHART_SIZE_Y / 5));
            graphPanel.add(legendPane);
        }
        graphPanel.validate();
    } else {
        graphPanel2.removeAll();
        chartPanel.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 3));
        //legendPanel.setPreferredSize(new Dimension(CHART_SIZE_X*2/3,CHART_SIZE_Y*2/5));
        graphPanel2.add(chartPanel);
        if (legendPanelOn) {
            legendPane = new JScrollPane(legendPanel);
            legendPane.setPreferredSize(new Dimension(CHART_SIZE_X * 2 / 3, CHART_SIZE_Y * 2 / 5));
            graphPanel2.add(legendPane);
        }
        graphPanel2.validate();
        summaryPanel.validate();
    }
}

From source file:diet.gridr.g5k.gui.ClusterInfoPanel.java

/**
 * This method initializes jPanel//from   w  w w .j  a va 2s . c  o  m
 *
 * @return javax.swing.JPanel
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        jPanel = new JPanel();
        jPanel.setLayout(new BoxLayout(jPanel, BoxLayout.Y_AXIS));
        jPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        jPanel.add(getSelectionChartPanel());
        jPanel.add(Box.createVerticalStrut(10));
        jPanel.add(getCardPanel());
        jPanel.add(new JSeparator(JSeparator.HORIZONTAL));
    }
    return jPanel;
}

From source file:edu.ucla.stat.SOCR.applications.demo.PortfolioApplication2.java

protected void initMixPanel() {
    sliderPanel2 = new JPanel();
    sliderPanel2.setLayout(new BoxLayout(sliderPanel2, BoxLayout.Y_AXIS));

    graphPanel2 = new JPanel();
    //      graphPanel2.setLayout(new BoxLayout(graphPanel2, BoxLayout.Y_AXIS));

    mixPanel = new JPanel(new BorderLayout());
    //      resetChart();

    setMixPanel();//from w  ww .  j  a  v a2s .c  o m
}

From source file:cimat.tesis.sna.visualization.ClusteringDemo.java

private void setUpView(BufferedReader br) throws IOException {

    Factory<Number> vertexFactory = new Factory<Number>() {
        int n = 0;

        public Number create() {
            return n++;
        }/*from  w  w  w. ja v a  2 s .c om*/
    };
    Factory<Number> edgeFactory = new Factory<Number>() {
        int n = 0;

        public Number create() {
            return n++;
        }
    };

    PajekNetReader<Graph<Number, Number>, Number, Number> pnr = new PajekNetReader<Graph<Number, Number>, Number, Number>(
            vertexFactory, edgeFactory);

    final Graph<Number, Number> graph = new SparseMultigraph<Number, Number>();

    pnr.load(br, graph);

    //Create a simple layout frame
    //specify the Fruchterman-Rheingold layout algorithm
    final AggregateLayout<Number, Number> layout = new AggregateLayout<Number, Number>(
            new FRLayout<Number, Number>(graph));

    vv = new VisualizationViewer<Number, Number>(layout);
    vv.setBackground(Color.white);
    //Tell the renderer to use our own customized color rendering
    vv.getRenderContext()
            .setVertexFillPaintTransformer(MapTransformer.<Number, Paint>getInstance(vertexPaints));
    vv.getRenderContext().setVertexDrawPaintTransformer(new Transformer<Number, Paint>() {
        public Paint transform(Number v) {
            if (vv.getPickedVertexState().isPicked(v)) {
                return Color.cyan;
            } else {
                return Color.BLACK;
            }
        }
    });

    vv.getRenderContext().setEdgeDrawPaintTransformer(MapTransformer.<Number, Paint>getInstance(edgePaints));

    vv.getRenderContext().setEdgeStrokeTransformer(new Transformer<Number, Stroke>() {
        protected final Stroke THIN = new BasicStroke(1);
        protected final Stroke THICK = new BasicStroke(2);

        public Stroke transform(Number e) {
            Paint c = edgePaints.get(e);
            if (c == Color.LIGHT_GRAY)
                return THIN;
            else
                return THICK;
        }
    });

    //add restart button
    JButton scramble = new JButton("Restart");
    scramble.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            Layout layout = vv.getGraphLayout();
            layout.initialize();
            Relaxer relaxer = vv.getModel().getRelaxer();
            if (relaxer != null) {
                relaxer.stop();
                relaxer.prerelax();
                relaxer.relax();
            }
        }

    });

    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);

    final JToggleButton groupVertices = new JToggleButton("Group Clusters");

    //Create slider to adjust the number of edges to remove when clustering
    final JSlider edgeBetweennessSlider = new JSlider(JSlider.HORIZONTAL);
    edgeBetweennessSlider.setBackground(Color.WHITE);
    edgeBetweennessSlider.setPreferredSize(new Dimension(210, 50));
    edgeBetweennessSlider.setPaintTicks(true);
    edgeBetweennessSlider.setMaximum(graph.getEdgeCount());
    edgeBetweennessSlider.setMinimum(0);
    edgeBetweennessSlider.setValue(0);
    edgeBetweennessSlider.setMajorTickSpacing(10);
    edgeBetweennessSlider.setPaintLabels(true);
    edgeBetweennessSlider.setPaintTicks(true);

    //      edgeBetweennessSlider.setBorder(BorderFactory.createLineBorder(Color.black));
    //TO DO: edgeBetweennessSlider.add(new JLabel("Node Size (PageRank With Priors):"));
    //I also want the slider value to appear
    final JPanel eastControls = new JPanel();
    eastControls.setOpaque(true);
    eastControls.setLayout(new BoxLayout(eastControls, BoxLayout.Y_AXIS));
    eastControls.add(Box.createVerticalGlue());
    eastControls.add(edgeBetweennessSlider);

    final String COMMANDSTRING = "Edges removed for clusters: ";
    final String eastSize = COMMANDSTRING + edgeBetweennessSlider.getValue();

    final TitledBorder sliderBorder = BorderFactory.createTitledBorder(eastSize);
    eastControls.setBorder(sliderBorder);
    //eastControls.add(eastSize);
    eastControls.add(Box.createVerticalGlue());

    groupVertices.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            clusterAndRecolor(layout, edgeBetweennessSlider.getValue(), similarColors,
                    e.getStateChange() == ItemEvent.SELECTED);
            vv.repaint();
        }
    });

    clusterAndRecolor(layout, 0, similarColors, groupVertices.isSelected());

    edgeBetweennessSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            JSlider source = (JSlider) e.getSource();
            if (!source.getValueIsAdjusting()) {
                int numEdgesToRemove = source.getValue();
                clusterAndRecolor(layout, numEdgesToRemove, similarColors, groupVertices.isSelected());
                sliderBorder.setTitle(COMMANDSTRING + edgeBetweennessSlider.getValue());
                eastControls.repaint();
                vv.validate();
                vv.repaint();
            }
        }
    });

    Container content = getContentPane();
    content.add(new GraphZoomScrollPane(vv));
    JPanel south = new JPanel();
    JPanel grid = new JPanel(new GridLayout(2, 1));
    grid.add(scramble);
    grid.add(groupVertices);
    south.add(grid);
    south.add(eastControls);
    JPanel p = new JPanel();
    p.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    p.add(gm.getModeComboBox());
    south.add(p);
    content.add(south, BorderLayout.SOUTH);
}

From source file:medsavant.uhn.cancer.UserCommentApp.java

private JPanel getHeaderPanel(UserComment lc) {
    JPanel headerPanel = new JPanel();
    headerPanel.setLayout(new BoxLayout(headerPanel, BoxLayout.Y_AXIS));
    JPanel leftJustPanel = new JPanel();
    leftJustPanel.setLayout(new BoxLayout(leftJustPanel, BoxLayout.X_AXIS));
    leftJustPanel.add(new JLabel("Posted " + lc.getModificationDate().toString() + " by: "));
    leftJustPanel.add(Box.createHorizontalGlue());
    headerPanel.add(leftJustPanel);/*from  ww  w .  j a va  2 s  .c  o  m*/

    leftJustPanel = new JPanel();
    leftJustPanel.setLayout(new BoxLayout(leftJustPanel, BoxLayout.X_AXIS));
    leftJustPanel.add(new JLabel(lc.getUser()));
    leftJustPanel.add(Box.createHorizontalGlue());
    headerPanel.add(leftJustPanel);
    headerPanel.add(Box.createHorizontalGlue());
    return headerPanel;
}