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:net.ontopia.topicmaps.viz.AboutFrame.java

public AboutFrame(Frame parent) {
    super(parent, Messages.getString("Viz.About", "Ontopia Vizigator"), true);

    JPanel mainPanel = new JPanel();
    mainPanel.setBackground(Color.white);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(createImagePanel());//from  www  .  j av a2  s .  c o m
    mainPanel.add(createAboutTextPanel());

    this.getContentPane().add(mainPanel);
    this.pack();
    this.setResizable(false);
    //    Center the dialog box above its parent
    this.setLocation((parent.getX() + (parent.getWidth() - this.getWidth()) / 2),
            parent.getY() + (parent.getHeight() - this.getHeight()) / 2);
}

From source file:PlotsBuilding.PlotPanel.java

public PlotPanel(ArrayList<PlotsData> plotscollection, Plotcr frame) {
    pointsPanel = new JPanel();
    pointsPanel.setLayout(new BoxLayout(pointsPanel, BoxLayout.X_AXIS));
    cursorInfo = new JTextArea(2, 10);
    cursorInfo.setVisible(true);/*w  w w. j av a 2s. c  o m*/
    chartPanel = new ChartPanel(fillCollection(plotscollection));
    chartPanel.addChartMouseListener(new MyChartMouseListener());
    chartPanel.setPreferredSize(new Dimension(800, 450));
    pointsPanel.setMaximumSize(new Dimension(chartPanel.getWidth(), 70));
    pointsPanel.add(cursorInfo);
    chartPanel.setBackground(Color.WHITE);
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(chartPanel);
    add(pointsPanel);
}

From source file:CommonLayouts.java

public CommonLayouts() {
    super("Common Layout Managers");
    setSize(500, 380);/*from w ww .j a va2s .c o  m*/

    JPanel desktop = new JPanel();
    getContentPane().add(desktop);

    JPanel fr1 = new JPanel();
    fr1.setBorder(new TitledBorder("FlowLayout"));
    fr1.setLayout(new FlowLayout());
    fr1.add(new JButton("1"));
    fr1.add(new JButton("2"));
    fr1.add(new JButton("3"));
    fr1.add(new JButton("4"));
    desktop.add(fr1, 0);

    JPanel fr2 = new JPanel();
    fr2.setBorder(new TitledBorder("GridLayout"));
    fr2.setLayout(new GridLayout(2, 2));
    fr2.add(new JButton("1"));
    fr2.add(new JButton("2"));
    fr2.add(new JButton("3"));
    fr2.add(new JButton("4"));
    desktop.add(fr2, 0);

    JPanel fr3 = new JPanel();
    fr3.setBorder(new TitledBorder("BorderLayout"));
    fr3.add(new JButton("1"), BorderLayout.NORTH);
    fr3.add(new JButton("2"), BorderLayout.EAST);
    fr3.add(new JButton("3"), BorderLayout.SOUTH);
    fr3.add(new JButton("4"), BorderLayout.WEST);
    desktop.add(fr3, 0);

    JPanel fr4 = new JPanel();
    fr4.setBorder(new TitledBorder("BoxLayout - X"));
    fr4.setLayout(new BoxLayout(fr4, BoxLayout.X_AXIS));
    fr4.add(new JButton("1"));
    fr4.add(Box.createHorizontalStrut(12));
    fr4.add(new JButton("2"));
    fr4.add(Box.createGlue());
    fr4.add(new JButton("3"));
    fr4.add(Box.createHorizontalGlue());
    fr4.add(new JButton("4"));
    desktop.add(fr4, 0);

    JPanel fr5 = new JPanel();
    fr5.setBorder(new TitledBorder("BoxLayout - Y"));
    fr5.setLayout(new BoxLayout(fr5, BoxLayout.Y_AXIS));
    fr5.add(new JButton("1"));
    fr5.add(Box.createVerticalStrut(10));
    fr5.add(new JButton("2"));
    fr5.add(Box.createGlue());
    fr5.add(new JButton("3"));
    fr5.add(Box.createVerticalGlue());
    fr5.add(new JButton("4"));
    desktop.add(fr5, 0);

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);
    setVisible(true);
}

From source file:net.chunkyhosting.Roe.computer.CHGManager.gui.dialogs.DownloadNotice.java

public DownloadNotice(HashMap<JSONObject, URL> downloads) {

    this.setDownloads(downloads);
    JPanel basic = new JPanel();
    basic.setLayout(new BoxLayout(basic, BoxLayout.Y_AXIS));
    add(basic);//from  w  ww  .  j a  v a2s  .co m

    JPanel topPanel = new JPanel(new BorderLayout(0, 0));
    topPanel.setMaximumSize(new Dimension(450, 0));
    JLabel hint = new JLabel("CHGManager Download Manager");
    hint.setBorder(BorderFactory.createEmptyBorder(0, 25, 0, 0));
    topPanel.add(hint);

    JSeparator separator = new JSeparator();
    separator.setForeground(Color.gray);

    topPanel.add(separator, BorderLayout.SOUTH);

    basic.add(topPanel);

    JPanel textPanel = new JPanel(new BorderLayout());
    textPanel.setBorder(BorderFactory.createEmptyBorder(15, 25, 15, 25));
    this.setTextPanel(new JTextPane());

    this.getTextPanel().setContentType("text/html");
    String text = "<p><b>Some files are missing from your CHGManager install. Don't worry. We're trying to download them. Please don't close this panel!</b></p>";
    this.getText().add(text);
    this.getTextPanel().setText(text);
    this.getTextPanel().setEditable(false);
    JScrollPane sp = new JScrollPane();
    sp.setSize(this.getTextPanel().getSize());
    basic.add(sp);

    //basic.add(textPanel);

    JPanel boxPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 0));
    basic.add(boxPanel);

    JPanel bottom = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton close = new JButton("Close");

    bottom.add(close);
    basic.add(bottom);

    bottom.setMaximumSize(new Dimension(450, 0));

    this.setTitle("CHGManager Download Manager");
    this.setResizable(false);
    this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    this.setLocationRelativeTo(null);
    this.setVisible(true);
    try {

        Thread.sleep(2000);

    } catch (InterruptedException e) {

    }

    this.startDownload();

}

From source file:SimpleFTF.java

public SimpleFTF() {
    JFormattedTextField ftf[] = new JFormattedTextField[7];
    String des[] = new String[ftf.length]; // description of each field

    des[0] = "Date";
    ftf[0] = new JFormattedTextField(new java.util.Date());

    des[1] = "Integer";
    ftf[1] = new JFormattedTextField(new Integer(90032221));

    des[2] = "Float";
    ftf[2] = new JFormattedTextField(new Float(3.14));

    des[3] = "Float work-around"; // manually specify a NumberFormat
    ftf[3] = new JFormattedTextField(java.text.NumberFormat.getInstance());
    ftf[3].setValue(new Float(3.14));

    des[4] = "currency";
    ftf[4] = new JFormattedTextField(java.text.NumberFormat.getCurrencyInstance());
    ftf[4].setValue(new Float(5.99));

    des[5] = "percent";
    ftf[5] = new JFormattedTextField(java.text.NumberFormat.getPercentInstance());
    ftf[5].setValue(new Float(0.33));

    des[6] = "java.net.URL"; // works via 1-arg String constructor and
    // toString()
    java.net.URL u = null;// www.java2 s . c om
    try {
        u = new java.net.URL("http://www.ora.com/");
    } catch (java.net.MalformedURLException ignored) {
    }
    ftf[6] = new JFormattedTextField(u);
    ftf[6].setColumns(24);

    // add each ftf[] to a BoxLayout
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    for (int j = 0; j < ftf.length; j += 1) {
        JPanel borderPanel = new JPanel(new java.awt.BorderLayout());
        borderPanel.setBorder(new javax.swing.border.TitledBorder(des[j]));
        borderPanel.add(ftf[j], java.awt.BorderLayout.CENTER);
        add(borderPanel);
    }
}

From source file:net.chunkyhosting.Roe.computer.CHGManager.gui.panels.ServerList.java

public ServerList(Servers serversUI) {

    this.serversUI = serversUI;
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

}

From source file:com.archivas.clienttools.arcmover.gui.panels.CopyOptionsPanel.java

private void layoutGuiComponents() {

    ///*from   ww w.java  2 s .co  m*/
    // top level panel
    //
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(new EmptyBorder(24, 24, 24, 24));
    add(ignoreConflictsCheckbox);
    add(Box.createVerticalGlue());

}

From source file:Main.java

/**
 * Creates a labeled panel containing a slider and considering
 * a particular width/*w  w  w.  j ava 2s .  co  m*/
 * 
 * @param slider
 * @param label
 * @return a panel for the slider
 */
public static JPanel createSliderPanel(final JSlider slider, String label, int width) {
    final JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.setBorder(new TitledBorder(label));
    p.setPreferredSize(new Dimension(width, 60));
    p.add(slider);
    return p;
}

From source file:com.opendoorlogistics.components.reports.ReporterPanel.java

public ReporterPanel(final ComponentConfigurationEditorAPI api, final ReporterConfig config) {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // setAlignmentX(LEFT_ALIGNMENT);

    // add config panel
    ReporterConfigPanel configPanel = new ReporterConfigPanel(config);
    configPanel.setBorder(createBorder("Export and processing options"));
    add(configPanel);/*w ww  .jav a2  s.co m*/

    // add gap
    add(Box.createRigidArea(new Dimension(1, 10)));

    // add tools panel
    JPanel toolContainer = new JPanel();
    toolContainer.setLayout(new BorderLayout());
    toolContainer.setBorder(createBorder("Tools"));

    add(toolContainer);

    JPanel tools = new JPanel();
    toolContainer.add(tools, BorderLayout.NORTH);
    toolContainer.setMaximumSize(new Dimension(Integer.MAX_VALUE, api.isInstruction() ? 120 : 80));
    // tools.setLayout(new BoxLayout(tools, BoxLayout.X_AXIS));
    tools.setLayout(new GridLayout(api == null || api.isInstruction() ? 2 : 1, 3));
    JButton compileButton = new JButton("Compile .jrxml file");
    compileButton.setToolTipText("Compile a JasperReports .jrxml file");
    compileButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            File file = ReporterTools.chooseJRXMLFile(api.getComponentPreferences(), LAST_JRXML_TO_COMPILE,
                    ReporterPanel.this);
            if (file == null) {
                return;
            }

            final ExecutionReport report = api.getApi().uiFactory().createExecutionReport();
            try {
                JasperDesign design = JRXmlLoader.load(file);
                if (design == null) {
                    throw new RuntimeException("File to load jrxml: " + file.getAbsolutePath());
                }

                String filename = FilenameUtils.removeExtension(file.getAbsolutePath()) + ".jasper";
                JasperCompileManager.compileReportToFile(design, filename);
            } catch (Throwable e2) {
                report.setFailed(e2);
                report.setFailed("Failed to compile file " + file.getAbsolutePath());
            } finally {
                if (report.isFailed()) {
                    Window window = SwingUtilities.getWindowAncestor(ReporterPanel.this);
                    api.getApi().uiFactory()
                            .createExecutionReportDialog(
                                    JFrame.class.isInstance(window) ? (JFrame) window : null,
                                    "Compiling jrxml file", report, true)
                            .setVisible(true);
                } else {
                    JOptionPane.showMessageDialog(ReporterPanel.this,
                            "Compiled jxrml successfully: " + file.getAbsolutePath());
                }
            }
        }
    });
    tools.add(compileButton);

    for (final OrientationEnum orientation : new OrientationEnum[] { OrientationEnum.LANDSCAPE,
            OrientationEnum.PORTRAIT }) {
        // create export button
        JButton button = new JButton("Export " + orientation.getName().toLowerCase() + " template");
        button.setToolTipText(
                "Export template (editable .jrxml and compiled .jasper) based on the input tables ("
                        + orientation.getName().toLowerCase() + ")");
        button.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                ReporterTools.exportReportTemplate(api, config, orientation, ReporterPanel.this);
            }
        });
        tools.add(button);

        // create view button
        if (api.isInstruction()) {
            final String title = "View basic " + orientation.getName().toLowerCase() + " report";
            button = new JButton(title);
            button.setToolTipText("View basic report based on the input tables ("
                    + orientation.getName().toLowerCase() + ")");
            button.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    if (api != null) {
                        api.executeInPlace(title,
                                orientation == OrientationEnum.LANDSCAPE
                                        ? ReporterComponent.VIEW_BASIC_LANDSCAPE
                                        : ReporterComponent.VIEW_BASIC_PORTRAIT);
                    }
                }
            });
            tools.add(button);
        }
    }

}

From source file:MultiLineLabel.java

/**
 ** Constructor - make a multiline label
 **//*from   w ww.  ja  v  a2  s.  c o  m*/
public MultiLineLabel(String text, float alignment) {
    this.alignment = alignment;
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    if (text != null)
        setText(text);
}