Example usage for javax.swing BoxLayout PAGE_AXIS

List of usage examples for javax.swing BoxLayout PAGE_AXIS

Introduction

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

Prototype

int PAGE_AXIS

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

Click Source Link

Document

Specifies that components should be laid out in the direction that lines flow across a page as determined by the target container's ComponentOrientation property.

Usage

From source file:CoordinatesDemo.java

private void buildUI(Container container) {
    container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS));

    CoordinateArea coordinateArea = new CoordinateArea(this);
    container.add(coordinateArea);/*from w  ww.jav  a  2  s.c o  m*/

    label = new JLabel();
    resetLabel();
    container.add(label);

    //Align the left edges of the components.
    coordinateArea.setAlignmentX(Component.LEFT_ALIGNMENT);
    label.setAlignmentX(Component.LEFT_ALIGNMENT); //redundant
}

From source file:com.samebug.clients.idea.ui.component.WriteTip.java

public WriteTip(final Actions actions) {
    tipTitle = new TipTitle();
    tipDescription = new DescriptionLabel(SamebugBundle.message("samebug.tip.write.tip.description"));
    tipBody = new TipBody();
    lengthCounter = new LengthCounter();
    sourceTitle = new SourceTitle();
    sourceDescription = new DescriptionLabel(SamebugBundle.message("samebug.tip.write.source.description"));
    sourceLink = new SourceLink();
    errorPanel = new ErrorPanel();
    cancel = new CancelButton();
    submit = new SubmitButton();
    this.actions = actions;

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    add(new TransparentPanel() {
        {/*from  w  w  w.  ja va2  s  .  c  o m*/
            add(tipTitle);
        }
    });
    add(new TransparentPanel() {
        {
            setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
            add(tipDescription);
        }
    });
    add(new JScrollPane(tipBody));
    add(new TransparentPanel() {
        {
            setLayout(new FlowLayout(FlowLayout.RIGHT));
            add(lengthCounter);
        }
    });
    add(new TransparentPanel() {
        {
            add(sourceTitle);
        }
    });
    add(new TransparentPanel() {
        {
            setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
            add(sourceDescription);
        }
    });
    add(new TransparentPanel() {
        {
            add(sourceLink);
        }
    });
    add(new TransparentPanel() {
        {
            setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
            add(errorPanel);
        }
    });
    add(new TransparentPanel() {
        {
            setLayout(new FlowLayout(FlowLayout.RIGHT, 20, 0));
            add(cancel);
            add(submit);
        }
    });

    PromptSupport.setPrompt(SamebugBundle.message("samebug.tip.write.tip.placeholder"), tipBody);
    PromptSupport.setPrompt(SamebugBundle.message("samebug.tip.write.source.placeholder"), sourceLink);
    updateSubmitButton(true);

    ((AbstractDocument) tipBody.getDocument()).setDocumentFilter(new TipConstraints());
    tipBody.getDocument().addDocumentListener(new TipEditorListener());

    submit.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (submit.isEnabled()) {
                final String tip = tipBody.getText();
                final String rawSourceUrl = sourceLink.getText();
                beginPostTip();
                actions.onClickSubmitTip(tip, rawSourceUrl);
            }
        }
    });
}

From source file:lu.lippmann.cdb.ext.hydviga.ui.SimilarCasesFrame.java

/**
 * Constructor.//from w  w w . ja  v a 2s . co  m
 */
SimilarCasesFrame(final Instances ds, final int dateIdx, final StationsDataProvider gcp, String attrname,
        final int gapsize, final int position, final double x, final double y, final int year,
        final String season, final boolean isDuringRising) throws Exception {
    LogoHelper.setLogo(this);
    this.setTitle("KnowledgeDB: Suggested configurations / similar cases");

    this.inputCaseTablePanel = new JXPanel();
    this.inputCaseTablePanel.setBorder(new TitledBorder("Present case"));
    this.inputCaseChartPanel = new JXPanel();
    this.inputCaseChartPanel.setBorder(new TitledBorder("Profile of the present case"));
    this.outputCasesTablePanel = new JXPanel();
    this.outputCasesTablePanel.setBorder(new TitledBorder("Suggested cases"));
    this.outputCasesChartPanel = new JXPanel();
    this.outputCasesChartPanel.setBorder(new TitledBorder("Profile of the selected suggested case"));

    getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
    getContentPane().add(inputCaseTablePanel);
    getContentPane().add(inputCaseChartPanel);
    getContentPane().add(outputCasesTablePanel);
    getContentPane().add(outputCasesChartPanel);

    final Instances res = GapFillingKnowledgeDB.findSimilarCases(attrname, x, y, year, season, gapsize,
            position, isDuringRising, gcp.findDownstreamStation(attrname) != null,
            gcp.findUpstreamStation(attrname) != null,
            GapsUtil.measureHighMiddleLowInterval(ds, ds.attribute(attrname).index(), position - 1));

    final Instances inputCase = new Instances(res);
    while (inputCase.numInstances() > 1)
        inputCase.remove(1);
    final JXTable inputCaseTable = buidJXTable(inputCase);
    final JScrollPane inputScrollPane = new JScrollPane(inputCaseTable);
    //System.out.println(inputScrollPane.getPreferredSize());
    inputScrollPane.setPreferredSize(
            new Dimension(COMPONENT_WIDTH, (int) (50 + inputScrollPane.getPreferredSize().getHeight())));
    this.inputCaseTablePanel.add(inputScrollPane);

    final ChartPanel inputcp = GapsUIUtil.buildGapChartPanel(ds, dateIdx, ds.attribute(attrname), gapsize,
            position);
    inputcp.getChart().removeLegend();
    inputcp.setPreferredSize(CHART_DIMENSION);
    this.inputCaseChartPanel.add(inputcp);

    final Instances outputCases = new Instances(res);
    outputCases.remove(0);
    final JXTable outputCasesTable = buidJXTable(outputCases);
    final JScrollPane outputScrollPane = new JScrollPane(outputCasesTable);
    outputScrollPane.setPreferredSize(
            new Dimension(COMPONENT_WIDTH, (int) (50 + outputScrollPane.getPreferredSize().getHeight())));
    this.outputCasesTablePanel.add(outputScrollPane);

    outputCasesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    outputCasesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                final int modelRow = outputCasesTable.getSelectedRow();

                final String attrname = outputCasesTable.getModel().getValueAt(modelRow, 1).toString();
                final int gapsize = (int) Double
                        .valueOf(outputCasesTable.getModel().getValueAt(modelRow, 4).toString()).doubleValue();
                final int position = (int) Double
                        .valueOf(outputCasesTable.getModel().getValueAt(modelRow, 5).toString()).doubleValue();

                try {
                    final ChartPanel cp = GapsUIUtil.buildGapChartPanel(ds, dateIdx, ds.attribute(attrname),
                            gapsize, position);
                    cp.getChart().removeLegend();
                    cp.setPreferredSize(CHART_DIMENSION);
                    outputCasesChartPanel.removeAll();
                    outputCasesChartPanel.add(cp);
                    getContentPane().repaint();
                    pack();
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    });

    outputCasesTable.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(final MouseEvent e) {
            final InstanceTableModel instanceTableModel = (InstanceTableModel) outputCasesTable.getModel();
            final int row = outputCasesTable.rowAtPoint(e.getPoint());
            final int modelRow = outputCasesTable.convertRowIndexToModel(row);

            final String attrname = instanceTableModel.getValueAt(modelRow, 1).toString();
            final int gapsize = (int) Double.valueOf(instanceTableModel.getValueAt(modelRow, 4).toString())
                    .doubleValue();
            final int position = (int) Double.valueOf(instanceTableModel.getValueAt(modelRow, 5).toString())
                    .doubleValue();

            if (e.isPopupTrigger()) {
                final JPopupMenu jPopupMenu = new JPopupMenu("feur");

                final JMenuItem mi = new JMenuItem("Use this configuration");
                mi.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(final ActionEvent e) {
                        System.out.println("not implemented!");
                    }
                });
                jPopupMenu.add(mi);
                jPopupMenu.show(outputCasesTable, e.getX(), e.getY());
            } else {
                // nothing?
            }
        }
    });

    setPreferredSize(new Dimension(FRAME_WIDTH, 900));

    pack();
    setVisible(true);

    /* select the first row */
    outputCasesTable.setRowSelectionInterval(0, 0);
}

From source file:com.tascape.qa.th.android.tools.UiAutomatorViewer.java

private void start() throws Exception {
    SwingUtilities.invokeLater(() -> {
        jd = new ViewerParameterDialog("Launch Android App");

        JPanel jpParameters = new JPanel();
        jpParameters.setLayout(new BoxLayout(jpParameters, BoxLayout.PAGE_AXIS));
        jd.setParameterPanel(jpParameters);
        {//  w w w . ja  v a2  s  .c  o m
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("Devices"));
            jp.add(jcbDevices);
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("App Package Name"));
            jp.add(jtfApp);
            if (StringUtils.isNotEmpty(appPackageName)) {
                jtfApp.setText(appPackageName);
            }

            jtfApp.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                        jbLaunch.doClick();
                    }
                }
            });
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(new JLabel("Interaction time (minute)"));
            jsDebugMinutes.getEditor().setEnabled(false);
            jp.add(jsDebugMinutes);
        }
        {
            JPanel jp = new JPanel();
            jpParameters.add(jp);
            jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS));
            jp.add(Box.createRigidArea(new Dimension(518, 2)));
        }

        JPanel jpAction = new JPanel();
        jd.setActionPanel(jpAction);
        jpAction.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
        jpAction.setLayout(new BoxLayout(jpAction, BoxLayout.LINE_AXIS));
        jbLaunch.setFont(jbLaunch.getFont().deriveFont(Font.BOLD));
        jbLaunch.setBorder(BorderFactory.createEtchedBorder());
        jbLaunch.setEnabled(false);
        jpAction.add(jbLaunch);
        jbLaunch.addActionListener(event -> {
            new Thread() {
                @Override
                public void run() {
                    launchApp();
                }
            }.start();
        });

        jd.showDialog();

        new Thread() {
            @Override
            public void run() {
                try {
                    detectDevices();
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            }
        }.start();
    });
}

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;//from w w w.  j av a  2  s.  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:signalviewer.SignalViewer.java

public SignalViewer() throws InterruptedException {
    C = new BufferClientClock();

    connect();/*from w  w  w .j a va2s  . c  o m*/
    setNullFields();
    nEvents = header.nEvents;
    nSamples = header.nSamples;
    getPlot();

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
    for (int i = 0; i < max_plots; i++) {
        this.getContentPane().add(panels[i]);
    }
    this.pack();
    this.setVisible(true);

    while (true) {
        //            for (int i = 0; i < max_plots; i++) {
        //                this.getContentPane().remove(panels[i]);
        //            }
        getPlot();
        for (int i = 0; i < max_plots; i++) {
            panels[i].setMaximumDrawHeight(400);
        }
        //            this.pack();
        this.revalidate();
        this.repaint();
        //            Thread.sleep(50);
    }
}

From source file:TextInputDemo.java

public TextInputDemo() {
    setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));

    JPanel leftHalf = new JPanel() {
        //Don't allow us to stretch vertically.
        public Dimension getMaximumSize() {
            Dimension pref = getPreferredSize();
            return new Dimension(Integer.MAX_VALUE, pref.height);
        }/*w w w.j  a va 2 s .c om*/
    };
    leftHalf.setLayout(new BoxLayout(leftHalf, BoxLayout.PAGE_AXIS));
    leftHalf.add(createEntryFields());
    leftHalf.add(createButtons());

    add(leftHalf);
    add(createAddressDisplay());
}

From source file:fungus.MycoNodeFrame.java

public MycoNodeFrame(MycoNode node) {
    this.node = node;
    this.setTitle("Node " + node.getID());

    graph = JungGraphObserver.getGraph();

    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    JPanel labelPane = new JPanel();
    labelPane.setLayout(new GridLayout(7, 2));
    JPanel neighborPane = new JPanel();
    neighborPane.setLayout(new BoxLayout(neighborPane, BoxLayout.PAGE_AXIS));
    JPanel logPane = new JPanel();
    logPane.setLayout(new BoxLayout(logPane, BoxLayout.PAGE_AXIS));
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));

    loggingTextArea = new JTextArea("", 25, 100);
    loggingTextArea.setLineWrap(true);//from w ww .j a va2s . c  om
    loggingTextArea.setEditable(false);
    handler = new MycoNodeLogHandler(node, loggingTextArea);
    handler.addChangeListener(this);
    JScrollPane logScrollPane = new JScrollPane(loggingTextArea);
    logScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    logPane.add(logScrollPane);

    contentPane.add(labelPane);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(neighborPane);
    //contentPane.add(Box.createRigidArea(new Dimension(0,5)));
    contentPane.add(logPane);
    contentPane.add(buttonPane);

    data = node.getHyphaData();
    link = node.getHyphaLink();
    mycocast = node.getMycoCast();

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    stateLabel = new JLabel();
    typeLabel = new JLabel();
    queueLengthLabel = new JLabel();
    sameLabel = new JLabel();
    differentLabel = new JLabel();
    maxCapacityLabel = new JLabel();
    idealImmobileLabel = new JLabel();
    idealHyphaeLabel = new JLabel();
    idealBiomassLabel = new JLabel();
    degreeLabel = new JLabel();
    hyphaDegreeLabel = new JLabel();
    biomassDegreeLabel = new JLabel();
    hyphaUtilizationLabel = new JLabel();
    biomassUtilizationLabel = new JLabel();
    capacityUtilizationLabel = new JLabel();

    labelPane.add(new JLabel("state"));
    labelPane.add(stateLabel);
    labelPane.add(new JLabel("type"));
    labelPane.add(typeLabel);
    labelPane.add(new JLabel("queue"));
    labelPane.add(queueLengthLabel);
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel("same"));
    labelPane.add(sameLabel);
    labelPane.add(new JLabel("different"));
    labelPane.add(differentLabel);
    //labelPane.add(new JLabel("immobile"));
    //labelPane.add(idealImmobileLabel);
    labelPane.add(new JLabel(""));
    labelPane.add(new JLabel("actual"));
    labelPane.add(new JLabel("ideal"));
    labelPane.add(new JLabel("utilization"));
    labelPane.add(new JLabel("hyphae"));
    labelPane.add(hyphaDegreeLabel);
    labelPane.add(idealHyphaeLabel);
    labelPane.add(hyphaUtilizationLabel);
    labelPane.add(new JLabel("biomass"));
    labelPane.add(biomassDegreeLabel);
    labelPane.add(idealBiomassLabel);
    labelPane.add(biomassUtilizationLabel);
    labelPane.add(new JLabel("capacity"));
    labelPane.add(degreeLabel);
    labelPane.add(maxCapacityLabel);
    labelPane.add(capacityUtilizationLabel);

    neighborListControl = new JList();
    neighborListControl.setLayoutOrientation(JList.VERTICAL_WRAP);
    neighborListControl.setVisibleRowCount(-1);

    neighborListScroller = new JScrollPane(neighborListControl);
    neighborListScroller.setPreferredSize(new Dimension(250, 150));
    neighborListScroller.setMinimumSize(new Dimension(250, 150));

    neighborPane.add(neighborListScroller);

    JButton updateButton = new JButton("Refresh");
    ActionListener updater = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            refreshData();
        }
    };
    updateButton.addActionListener(updater);

    JButton closeButton = new JButton("Close");
    ActionListener closer = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            closeFrame();
        }
    };
    closeButton.addActionListener(closer);

    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(updateButton);
    buttonPane.add(Box.createRigidArea(new Dimension(5, 0)));
    buttonPane.add(closeButton);

    refreshData();

    JungGraphObserver.addChangeListener(this);

    this.pack();
    this.setVisible(true);
}

From source file:com.jdom.util.patterns.mvp.swing.RadioButtonGroupDialog.java

private RadioButtonGroupDialog(Frame frame, Component locationComp, String labelText, String title,
        Collection<String> data, String initialValue, String longValue) {
    super(frame, title, true);

    final JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);

    final JButton setButton = new JButton("OK");
    setButton.setActionCommand("OK");
    setButton.addActionListener(this);
    getRootPane().setDefaultButton(setButton);

    ButtonGroup radioButtonGroup = new ButtonGroup();
    for (String option : data) {
        JRadioButton button = new JRadioButton(option);
        if (option.equals(initialValue)) {
            button.setSelected(true);//from www  .j av  a  2 s.  co m
        }
        radioButtonGroup.add(button);
        panel.add(button);
    }

    JScrollPane listScroller = new JScrollPane(panel);
    listScroller.setPreferredSize(new Dimension(250, 80));
    listScroller.setAlignmentX(LEFT_ALIGNMENT);

    JPanel listPane = new JPanel();
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));

    if (!StringUtils.isEmpty(labelText)) {
        JLabel label = new JLabel(labelText);
        label.setText(labelText);
        listPane.add(label);
    }
    listPane.add(Box.createRigidArea(new Dimension(0, 5)));
    listPane.add(listScroller);
    listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(cancelButton);
    buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPane.add(setButton);

    Container contentPane = getContentPane();
    contentPane.add(listPane, BorderLayout.CENTER);
    contentPane.add(buttonPane, BorderLayout.PAGE_END);

    pack();
    setLocationRelativeTo(locationComp);
}

From source file:org.onesun.sdi.swing.app.views.DataServicesView.java

public DataServicesView() {
    this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    createControls();

    addControlsToPanel();
}