Example usage for java.awt GridLayout GridLayout

List of usage examples for java.awt GridLayout GridLayout

Introduction

In this page you can find the example usage for java.awt GridLayout GridLayout.

Prototype

public GridLayout(int rows, int cols) 

Source Link

Document

Creates a grid layout with the specified number of rows and columns.

Usage

From source file:TextViewer.java

/**
 * Constructor/*ww  w.ja va  2  s.  c om*/
 */
public TextViewer() {
    super(new GridLayout(1, 1));

    // create the text area
    text_area = new JTextArea();
    text_area.setEditable(false);
    text_area.setLineWrap(true);

    // create a scroll pane for the JTextArea
    JScrollPane sp = new JScrollPane();
    sp.setPreferredSize(new Dimension(300, 300));
    sp.getViewport().add(text_area);

    add(sp);
}

From source file:syg_Wykresy.PanelRysunek_Wykres.java

private void initGUI() {
    try {//  ww w  .j a v  a  2s.c om
        GridLayout thisLayout = new GridLayout(1, 1);
        thisLayout.setHgap(5);
        thisLayout.setVgap(5);
        thisLayout.setColumns(1);
        this.setLayout(thisLayout);
        setPreferredSize(new Dimension(400, 300));

        if (this.wykres) {

            XYSeries series = new XYSeries("Sygna "
                    + (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY ? "cigy" : "dyskretny"));
            double punkt;
            double ta = this.sygnalWyswietlany.gett1();

            if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY
                    || sygnalWyswietlany.getPunktyY_wykres().size() <= 0) {
                punkt = this.sygnalWyswietlany.gett1();
                while (ta <= this.sygnalWyswietlany.gett1() + this.sygnalWyswietlany.getd()) {
                    punkt = this.sygnalWyswietlany.wykres_punkty(punkt, ta);
                    this.sygnalWyswietlany.setPunktyY_wykres(punkt);
                    series.add(ta, punkt);
                    if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY) {
                        if (this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10)
                            ta = ta + this.sygnalWyswietlany.getkroczek();
                        else
                            ta = ta + this.sygnalWyswietlany.getkroczek() * 10;
                    } else {
                        if (this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10)
                            ta = ta + this.sygnalWyswietlany.getkrok();
                        else
                            ta = ta + this.sygnalWyswietlany.getkrok() * 10;
                    }
                }
            } else if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.DYSKRETNY
                    && sygnalWyswietlany.getPunktyY_wykres().size() > 0) {
                int iloscProbek = (int) (this.sygnalWyswietlany.getPunktyY_wykres().size());
                for (int i = 0; i < iloscProbek; i++) {
                    punkt = this.sygnalWyswietlany.getPunktzindexu(i);
                    series.add(ta, punkt);
                    ta = ta + this.sygnalWyswietlany.getkrok();
                }
            }

            XYSeriesCollection dataset = new XYSeriesCollection(series);
            JFreeChart chart;

            if ((this.sygnalWyswietlany.gettyp() != 9 && this.sygnalWyswietlany.gettyp() != 10)
                    && (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY)) {
                chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL,
                        true, true, true);

                final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
                renderer.setSeriesLinesVisible(0, false);
            } else {
                chart = ChartFactory.createXYLineChart(null, null, null, dataset, PlotOrientation.VERTICAL,
                        true, true, true);

                final XYPlot plot = chart.getXYPlot();
                final XYDotRenderer renderer = new XYDotRenderer();
                renderer.setDotHeight(3);
                renderer.setDotWidth(3);
                plot.setRenderer(renderer);

                final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
                rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            }

            // JOptionPane.showMessageDialog(null, "Rysowanie wykresu...",
            // "PanelRysunek_Wykres", JOptionPane.INFORMATION_MESSAGE);

            ChartPanel chartpanel = new ChartPanel(chart);
            chartpanel.setDomainZoomable(true);

            this.add(chartpanel);
        }

        Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:components.TabbedPaneDemo.java

public TabbedPaneDemo() {
    super(new GridLayout(1, 1));

    JTabbedPane tabbedPane = new JTabbedPane();
    ImageIcon icon = createImageIcon("images/middle.gif");

    JComponent panel1 = makeTextPanel("Panel #1");
    tabbedPane.addTab("Tab 1", icon, panel1, "Does nothing");
    tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);

    JComponent panel2 = makeTextPanel("Panel #2");
    tabbedPane.addTab("Tab 2", icon, panel2, "Does twice as much nothing");
    tabbedPane.setMnemonicAt(1, KeyEvent.VK_2);

    JComponent panel3 = makeTextPanel("Panel #3");
    tabbedPane.addTab("Tab 3", icon, panel3, "Still does nothing");
    tabbedPane.setMnemonicAt(2, KeyEvent.VK_3);

    JComponent panel4 = makeTextPanel("Panel #4 (has a preferred size of 410 x 50).");
    panel4.setPreferredSize(new Dimension(410, 50));
    tabbedPane.addTab("Tab 4", icon, panel4, "Does nothing at all");
    tabbedPane.setMnemonicAt(3, KeyEvent.VK_4);

    //Add the tabbed pane to this panel.
    add(tabbedPane);//from ww w .ja v  a  2 s. c o m

    //The following line enables to use scrolling tabs.
    tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}

From source file:SwingLabelDemo.java

public SwingLabelDemo() {
    super(new GridLayout(3, 1)); //3 rows, 1 column
    JLabel label1, label2, label3;

    ImageIcon icon = createImageIcon("images/middle.gif", "a pretty but meaningless splat");

    //Create the first label.
    label1 = new JLabel("Image and Text", icon, JLabel.CENTER);
    //Set the position of its text, relative to its icon:
    label1.setVerticalTextPosition(JLabel.BOTTOM);
    label1.setHorizontalTextPosition(JLabel.CENTER);

    //Create the other labels.
    label2 = new JLabel("Text-Only Label");
    label3 = new JLabel(icon);

    //Create tool tips, for the heck of it.
    label1.setToolTipText("A label containing both image and text");
    label2.setToolTipText("A label containing only text");
    label3.setToolTipText("A label containing only an image");

    //Add the labels.
    add(label1);/*from  w  w w  .  j a va  2s. c o m*/
    add(label2);
    add(label3);
}

From source file:com.jcraft.weirdx.XRexec.java

public XRexec(String myName, int num) {
    try {//from ww  w. j  a  v  a  2s.  c o  m
        InetAddress local = null;
        if (myName != null && myName.length() > 0) {
            local = InetAddress.getByName(myName);
        } else {
            local = InetAddress.getLocalHost();
        }
        display = local.getHostName() + ":" + num + ".0";
    } catch (Exception e) {
        display = "localhost:" + num + ".0";
        LOG.error(e);
    }

    JFrame jframe = new JFrame();
    Container cpane = jframe.getContentPane();
    cpane.setLayout(new GridLayout(0, 1));

    JPanel jpanel = null;

    jpanel = new JPanel();
    jpanel.setBorder(BorderFactory.createTitledBorder("Host"));
    jpanel.setLayout(new BorderLayout());
    host.setText("");
    host.setMinimumSize(new Dimension(50, 25));
    host.setEditable(true);
    jpanel.add(host, "Center");
    cpane.add(jpanel);

    jpanel = new JPanel();
    jpanel.setBorder(BorderFactory.createTitledBorder("User"));
    jpanel.setLayout(new BorderLayout());
    name.setText("");
    name.setMinimumSize(new Dimension(50, 25));
    name.setEditable(true);
    jpanel.add(name, "Center");
    cpane.add(jpanel);

    jpanel = new JPanel();
    jpanel.setBorder(BorderFactory.createTitledBorder("Password"));
    jpanel.setLayout(new BorderLayout());
    passwd.setMinimumSize(new Dimension(50, 25));
    passwd.setEditable(true);
    jpanel.add(passwd, "Center");
    cpane.add(jpanel);

    jpanel = new JPanel();
    jpanel.setBorder(BorderFactory.createTitledBorder("Command with Absolute Path"));
    jpanel.setLayout(new BorderLayout());
    command.setText("");
    command.setMinimumSize(new Dimension(50, 25));
    command.setEditable(true);
    jpanel.add(command, "Center");
    command.addActionListener(this);
    cpane.add(jpanel);

    jpanel = new JPanel();
    jpanel.add(rexec, "Center");
    rexec.addActionListener(this);
    cpane.add(jpanel);

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

From source file:TableRenderDemo.java

public TableRenderDemo() {
    super(new GridLayout(1, 0));

    JTable table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    // Set up column sizes.
    initColumnSizes(table);/*from   www .  ja va  2s .co  m*/

    // Fiddle with the Sport column's cell editors/renderers.
    setUpSportColumn(table, table.getColumnModel().getColumn(2));

    // Add the scroll pane to this panel.
    add(scrollPane);
}

From source file:components.TableFTFEditDemo.java

public TableFTFEditDemo() {
    super(new GridLayout(1, 0));

    JTable table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);//from  w  ww .  j  av  a2  s. c  o  m

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Set up stricter input validation for the integer column.
    table.setDefaultEditor(Integer.class, new IntegerEditor(0, 100));

    //If we didn't want this editor to be used for other
    //Integer columns, we'd do this:
    //table.getColumnModel().getColumn(3).setCellEditor(
    //   new IntegerEditor(0, 100));

    //Add the scroll pane to this panel.
    add(scrollPane);
}

From source file:com.sshtools.common.ui.OptionsPanel.java

/**
 * Creates a new OptionsPanel object. //from   w  ww . j  a  va2s . c o  m
 *
 * @param tabs to show
 */
public OptionsPanel(OptionsTab[] optionalTabs) {
    super();
    tabber = new Tabber();

    if (optionalTabs != null) {
        for (int i = 0; i < optionalTabs.length; i++) {
            optionalTabs[i].reset();
            addTab(optionalTabs[i]);
        }
    }

    //  Build this panel
    setLayout(new GridLayout(1, 1));
    add(tabber);
}

From source file:org.jfree.chart.demo.PieChartDemo7.java

/**
 * Creates a new demo instance.//from   w w w.  j a v a2s .  c o m
 * 
 * @param title  the frame title.
 */
public PieChartDemo7(String title) {

    super(title);
    JPanel panel = new JPanel(new GridLayout(2, 2));
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Section 1", 23.3);
    dataset.setValue("Section 2", 56.5);
    dataset.setValue("Section 3", 43.3);
    dataset.setValue("Section 4", 11.1);

    JFreeChart chart1 = ChartFactory.createPieChart("Chart 1", dataset, false, false, false);
    JFreeChart chart2 = ChartFactory.createPieChart("Chart 2", dataset, false, false, false);
    PiePlot plot2 = (PiePlot) chart2.getPlot();
    plot2.setCircular(false);
    JFreeChart chart3 = ChartFactory.createPieChart3D("Chart 3", dataset, false, false, false);
    PiePlot3D plot3 = (PiePlot3D) chart3.getPlot();
    plot3.setForegroundAlpha(0.6f);
    plot3.setCircular(true);
    JFreeChart chart4 = ChartFactory.createPieChart3D("Chart 4", dataset, false, false, false);
    PiePlot3D plot4 = (PiePlot3D) chart4.getPlot();
    plot4.setForegroundAlpha(0.6f);

    panel.add(new ChartPanel(chart1));
    panel.add(new ChartPanel(chart2));
    panel.add(new ChartPanel(chart3));
    panel.add(new ChartPanel(chart4));

    panel.setPreferredSize(new Dimension(800, 600));
    setContentPane(panel);

}

From source file:components.TableSorterDemo.java

public TableSorterDemo() {
    super(new GridLayout(1, 0));

    TableSorter sorter = new TableSorter(new MyTableModel()); //ADDED THIS
    //JTable table = new JTable(new MyTableModel());         //OLD
    JTable table = new JTable(sorter); //NEW
    sorter.setTableHeader(table.getTableHeader()); //ADDED THIS
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));

    //Set up tool tips for column headers.
    table.getTableHeader()/*from   w  w w .  ja v a 2 s.  c om*/
            .setToolTipText("Click to specify sorting; Control-Click to specify secondary sorting");

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);
}