Example usage for javax.swing BoxLayout BoxLayout

List of usage examples for javax.swing BoxLayout BoxLayout

Introduction

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

Prototype

@ConstructorProperties({ "target", "axis" })
public BoxLayout(Container target, int axis) 

Source Link

Document

Creates a layout manager that will lay out components along the given axis.

Usage

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

private JPanel getCommentBlock(UserCommentGroup lcg, UserComment lc/*, UserComment oldComment*/) {

    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.Y_AXIS));

    JPanel headerPanel = getHeaderPanel(lc);
    JPanel commentPanel = getCommentPanel(lc);

    if (lc.getOriginalComment() == null) { //root level comment.
        innerPanel.add(headerPanel);//from   w  w  w  .  j  av a2s.c  o m
        innerPanel.add(getStatusIconPanel(lcg, lc));
        innerPanel.add(commentPanel);
        innerPanel.add(getCommentSeparator());

        return innerPanel;
    } else { //status comment.
        JPanel outerPanel = new JPanel();
        outerPanel.setLayout(new BoxLayout(outerPanel, BoxLayout.X_AXIS));
        JSeparator js = new JSeparator();
        js.setPreferredSize(new Dimension(STATUS_COMMENT_INDENT_WIDTH, 1));
        outerPanel.add(js);

        innerPanel.add(headerPanel);

        //System.out.println("Constructing statusIconPanel with "+lc.isApproved()+","+lc.isIncluded()+","+lc.isPendingReview());
        JPanel statusIconPanel = new StatusIconPanel(ICON_WIDTH, ICON_HEIGHT, false, lc.isApproved(),
                lc.isIncluded(), lc.isDeleted());

        JPanel centeredLabel = new JPanel();
        centeredLabel.setLayout(new BoxLayout(centeredLabel, BoxLayout.X_AXIS));
        centeredLabel.add(Box.createHorizontalGlue());
        centeredLabel.add(new JLabel("Status Change:"));
        centeredLabel.add(Box.createHorizontalGlue());
        innerPanel.add(centeredLabel);
        oldStatusPanel = new JPanel();
        oldStatusPanel.setLayout(new BoxLayout(oldStatusPanel, BoxLayout.X_AXIS));
        oldStatusPanel.add(Box.createHorizontalGlue());
        oldStatusPanel.add(statusIconPanel);
        innerPanel.add(oldStatusPanel);
        innerPanel.add(commentPanel);
        innerPanel.add(getCommentSeparator());
        outerPanel.add(innerPanel);
        return outerPanel;
    }
}

From source file:cloud.gui.CloudGUI.java

private JPanel createCurrentInstancesPanel() {
    JPanel currentInstancesPanel = new JPanel();
    currentInstancesPanel.setBorder(BorderFactory.createTitledBorder("Current Instances"));
    currentInstancesPanel.setLayout(new BoxLayout(currentInstancesPanel, BoxLayout.Y_AXIS));
    Box layout = Box.createVerticalBox();

    createNumberOfInstancesStatus(layout);
    createTotalCost(layout);/*from www.  j av  a 2  s  .co  m*/
    createInstanceTable(layout);

    removeInstanceButton = new JButton("Remove instance");

    layout.add(removeInstanceButton);
    currentInstancesPanel.add(layout);
    return currentInstancesPanel;
}

From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java

/**
 * Helper factory method for creating a horizontal box layout {@link JPanel} that takes into account the locale.
 *
 * @return the created panel//from   ww w  .  j  av a  2  s .  c om
 */
protected JPanel createHorizontalPanel() {
    JPanel panel = new JPanel();
    panel.setComponentOrientation(ComponentOrientation.getOrientation(i18n.getLocale()));
    panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
    return panel;
}

From source file:com.clank.launcher.swing.SwingHelper.java

public static Component alignTabbedPane(Component component) {
    JPanel container = new JPanel();
    container.setLayout(new BoxLayout(container, BoxLayout.Y_AXIS));
    container.add(component);/*from   w  w w.  ja v a 2 s  .  c  o  m*/
    container.add(new Box.Filler(new Dimension(0, 0), new Dimension(0, 10000), new Dimension(0, 10000)));
    SwingHelper.removeOpaqueness(container);
    return container;
}

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

private void initSliders() {
    sliderPanel = new JPanel();

    JPanel rPanel = new JPanel();
    JPanel rPanel2 = new JPanel();
    rSliders = new FloatSlider[numStocks];
    R = new double[numStocks];
    double[] r = { 0.0064, 0.0022, 0.02117, 0.01, 0.0134 };

    JPanel matrixPanel = new JPanel();
    mSliders = new FloatSlider[15];
    CORR = new double[numStocks][numStocks];
    double[] m = { 0.0101, 0.0045, 0.0122, 0.0041, 0.0026, 0.0119, 0.0012, 0.0011, 0.0015, 0.0141, 0.0043,
            0.0022, 0.0058, 0.005, 0.0144 };

    rPanel.setLayout(new GridBagLayout());
    rPanel.add(new JLabel("Expected Return:"));
    for (int i = 0; i < numStocks; i++) {
        R[i] = r[i];/*from w  w  w.  j av a 2s.com*/
        rSliders[i] = new edu.ucla.stat.SOCR.util.FloatSlider("E(R" + (i + 1) + ")", -0.1, 0.1, r[i], false);
        rSliders[i].setPreferredSize(new Dimension(CHART_SIZE_X / 3, 80));
        rSliders[i]
                .setToolTipText("Slider for adjusting the value of expected return for stock " + (i + 1) + ".");
        newMSlider(1, i, rSliders[i], r[i], rPanel);

    }

    rPanel2.setLayout(new GridBagLayout());
    rPanel2.add(new JLabel("Covariance:"));
    for (int i = 0; i < numStocks; i++) {
        R[i] = r[i];
        mSliders[i] = new edu.ucla.stat.SOCR.util.FloatSlider("VAR(R" + (i + 1) + ")", 0, 0.5);
        mSliders[i].setPreferredSize(new Dimension(CHART_SIZE_X / 3, 80));
        mSliders[i].setToolTipText("Slider for adjusting the value of covariance " + (i + 1) + ".");
        newMSlider(1, i, mSliders[i], m[i], rPanel2);
    }

    matrixPanel.setLayout(new GridBagLayout());
    matrixPanel.add(new JLabel("Correlation Matrix:"));
    int k = 0;
    for (int i = 0; i < numStocks; i++)
        for (int j = 0; j <= i; j++) {
            CORR[i][j] = m[k];
            if (i == j) {
                mSliders[k] = new edu.ucla.stat.SOCR.util.FloatSlider("VAR(R" + (i + 1) + ")", 0, 0.5);
                //   newMSlider(i,j,mSliders[k],m[k],matrixPanel);
            } else {
                mSliders[k] = new edu.ucla.stat.SOCR.util.FloatSlider("COV" + (j + 1) + (i + 1), 0, 0.5);
                mSliders[k].setPreferredSize(new Dimension(CHART_SIZE_X * 5 / 12, 80));
                mSliders[k].setToolTipText("Slider for adjusting the value of covariance matrix (" + (j + 1)
                        + "," + (i + 1) + ").");
                newMSlider(i, j, mSliders[k], m[k], matrixPanel);
            }
            k++;
        }

    sliderPanel.setLayout(new BoxLayout(sliderPanel, BoxLayout.PAGE_AXIS));
    /*Box box = Box.createVerticalBox();
    box.add(rPanel);
    box.add(rPanel2);
    box.add(new JLabel("Correlation Matrix:"));
    box.add(matrixPanel);
    sliderPanel.add(box);*/
    rPanel.setAlignmentX(LEFT_ALIGNMENT);
    rPanel2.setAlignmentX(LEFT_ALIGNMENT);
    matrixPanel.setAlignmentX(LEFT_ALIGNMENT);
    sliderPanel.add(rPanel);
    sliderPanel.add(rPanel2);
    sliderPanel.add(Box.createRigidArea(new Dimension(0, 5)));
    sliderPanel.add(matrixPanel);
    sliderPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    //sliderPanel.setBackground(Color.white);
}

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

/**
 * This method initializes jPanel1//  ww w . ja v  a 2s. com
 *
 * @return javax.swing.JPanel
 */
private JPanel getJPanel1() {
    if (jPanel1 == null) {
        jPanel1 = new JPanel();
        jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.X_AXIS));
        jPanel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        JPanel intermediaryPanel = new JPanel();
        intermediaryPanel.setLayout(new BoxLayout(intermediaryPanel, BoxLayout.Y_AXIS));
        nodesTable = new JTable();
        nodesModel = new ClusterNodesSummaryModel();
        nodesTable.setModel(nodesModel);
        JLabel nodesTableTitle = new JLabel("Nodes status");
        nodesTableTitle.setAlignmentX(JLabel.CENTER_ALIGNMENT);
        nodesTableTitle.setFont(new Font("Dialog", Font.BOLD, 14));
        intermediaryPanel.add(Box.createVerticalStrut(5));
        intermediaryPanel.add(nodesTableTitle);
        intermediaryPanel.add(Box.createVerticalStrut(10));
        intermediaryPanel.add(nodesTable.getTableHeader());
        intermediaryPanel.add(nodesTable);
        intermediaryPanel.add(Box.createVerticalStrut(10));
        intermediaryPanel.add(new JSeparator(JSeparator.HORIZONTAL));
        jPanel1.add(Box.createHorizontalGlue());
        jPanel1.add(intermediaryPanel);
        jPanel1.add(Box.createHorizontalGlue());
        LoggingManager.log(Level.FINER, LoggingManager.RESOURCESTOOL, this.getClass().getName(), "getJPanel1",
                "Cluster nodes summary table added");
    }
    return jPanel1;
}

From source file:com.moteiv.trawler.Trawler.java

public Trawler(String[] args) {
    init(args);//from w  ww  . j av a  2 s .co  m
    // Install a different look and feel; specifically, the Windows look and feel
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); //"com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (InstantiationException e) {
    } catch (ClassNotFoundException e) {
    } catch (UnsupportedLookAndFeelException e) {
    } catch (IllegalAccessException e) {
    }
    jf = new JFrame("Trawler");
    jf.setJMenuBar(getMainMenuBar());

    g = new SparseGraph();

    layout = new FRLayout(g);
    indexer = Indexer.newIndexer(g, 0);
    //          layout.initialize(new Dimension(100, 100));
    mif = new MoteInterface(g, Trawler.GROUPID, layout);
    uartDetect = new UartDetect(mif.getMoteIF());
    Thread th = new Thread(uartDetect);
    th.start();
    pr = new myPluggableRenderer();
    vv = new VisualizationViewer(layout, pr);

    vv.init();

    vv.setPickSupport(new ShapePickSupport());
    vv.setBackground(Color.white);
    vv.setToolTipListener(new NodeTips(vv));
    myVertexShapeFunction vsf = new myVertexShapeFunction(uartDetect);
    pr.setVertexShapeFunction(vsf);
    pr.setVertexIconFunction(vsf);//new myVertexShapeFunction());
    m_vs = new VertexLabel();
    java.awt.Font f = new java.awt.Font("Arial", Font.PLAIN, 12);
    pr.setEdgeFontFunction(new ConstantEdgeFontFunction(f));
    pr.setVertexStringer(m_vs);
    m_es = new myEdgeLabel();
    pr.setEdgeStringer(m_es);
    ((AbstractEdgeShapeFunction) pr.getEdgeShapeFunction()).setControlOffsetIncrement(-50.f);
    //   pr.setVertexColorFunction(new myVertexColorFunction(Color.RED.darker().darker(), Color.RED, 500l));
    pr.setEdgeStrokeFunction(new EdgeWeightStrokeFunction());
    pr.setEdgeLabelClosenessFunction(new ConstantDirectionalEdgeValue(0.5, 0.5));
    pr.setEdgePaintFunction(new myEdgeColorFunction());

    scrollPane = new GraphZoomScrollPane(vv);
    jf.getContentPane().setLayout(new BoxLayout(jf.getContentPane(), BoxLayout.LINE_AXIS));
    JTabbedPane pane = new JTabbedPane();
    pane.addTab("Network Topology", scrollPane);
    pane.addTab("Sensor readings", createOscopePanel(mif.getMoteIF(), "ADC Readings", -33, -456, 300, 4100,
            "Time (seconds)", "ADC counts"));
    pane.addTab("Link Quality", createOscopePanel(mif.getMoteIF(), "LinkQualityPanel", -33, -15, 300, 135,
            "Time (seconds)", "Link Quality Indicator"));
    ImageIcon trawlerIcon = new ImageIcon(Trawler.class.getResource("images/trawler-icon.gif"));
    Image imageTrawler = trawlerIcon.getImage();
    jf.getContentPane().add(pane);
    controlBoxFrame = new JFrame("Vizualization Control");
    controlBoxFrame.getContentPane().add(getControls());
    controlBoxFrame.setIconImage(imageTrawler);
    controlBoxFrame.pack();
    //   jf.getContentPane().add(getControls());
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    layout.initialize(vv.getSize());
    layout.resize(vv.getSize());
    layout.update();

    loadPrefs();
    GraphIO.loadGraph(g, layout, mif, Trawler.NODEFILE);

    // need this mouse model to keep the mouse clicks 
    // aligned with the nodes
    DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
    gm.setMode(ModalGraphMouse.Mode.PICKING);
    vv.setGraphMouse(gm);
    jf.setIconImage(imageTrawler);
    jf.pack();

    jf.show();
    controlBoxFrame.setVisible(true);
    timer = new Timer();
    timer.schedule(new UpdateTask(), 500, 500);

}

From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java

/**
 * Helper factory method for creating a vertical box layout {@link JPanel}.
 *
 * @return the created panel//  w ww.j a va 2s  . co m
 */
protected JPanel createVerticalPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    return panel;
}

From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java

private JComponent makeCheckboxesXsd() {
    xsdPanel.setLayout(new BoxLayout(xsdPanel, BoxLayout.PAGE_AXIS));
    xsdPanel.add(schemaLabel);//from ww w .j a v  a 2  s  .c om
    JRadioButton radioButton;
    for (Xsd_enum xsdEnum : Xsd_enum.values()) {
        radioButton = new JRadioButton(xsdEnum.getReadableName());
        if (xsdEnum.getReadableName().equals(retrieveFromDb.retrieveDefaultXsd()))
            radioButton.setSelected(true);
        radioButton.addActionListener(new XsdSelectorListener(dataPreparationToolGUI));
        dataPreparationToolGUI.getGroupXsd().add(radioButton);
        xsdPanel.add(radioButton);
        xsdPanel.add(Box.createRigidArea(new Dimension(0, 10)));
    }
    for (XsdObject additionalXsd : retrieveFromDb.retrieveAdditionalXsds()) {
        radioButton = new JRadioButton(additionalXsd.getName());
        radioButton.addActionListener(new XsdSelectorListener(dataPreparationToolGUI));
        dataPreparationToolGUI.getGroupXsd().add(radioButton);
        xsdPanel.add(radioButton);
        xsdPanel.add(Box.createRigidArea(new Dimension(0, 10)));
    }
    return xsdPanel;
}

From source file:com.haulmont.cuba.desktop.gui.components.DesktopComponentsHelper.java

/**
 * Determines real size of HTML label with text on screen.
 *
 * @param html text with html markup/*from w  w  w  .  j a  v  a  2  s .  c om*/
 * @return size of label
 */
public static Dimension measureHtmlText(String html) {
    JFrame testFrame = new JFrame();
    testFrame.setLayout(new BoxLayout(testFrame.getContentPane(), BoxLayout.PAGE_AXIS));
    JLabel testLabel = new JLabel(html);
    testFrame.add(testLabel);
    testFrame.pack();

    Dimension size = testLabel.getSize();

    testFrame.dispose();

    return new Dimension(size);
}