Example usage for java.awt GridLayout setColumns

List of usage examples for java.awt GridLayout setColumns

Introduction

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

Prototype

public void setColumns(int cols) 

Source Link

Document

Sets the number of columns in this layout to the specified value.

Usage

From source file:com.heliosdecompiler.bootstrapper.Bootstrapper.java

private static HeliosData loadHelios() throws IOException {
    System.out.println("Finding Helios implementation");

    HeliosData data = new HeliosData();

    boolean needsToDownload = !IMPL_FILE.exists();
    if (!needsToDownload) {
        try (JarFile jarFile = new JarFile(IMPL_FILE)) {
            ZipEntry entry = jarFile.getEntry("META-INF/MANIFEST.MF");
            if (entry == null) {
                needsToDownload = true;// w  w  w  .j  a  va  2 s  . co m
            } else {
                Manifest manifest = new Manifest(jarFile.getInputStream(entry));
                String ver = manifest.getMainAttributes().getValue("Implementation-Version");
                try {
                    data.buildNumber = Integer.parseInt(ver);
                    data.version = manifest.getMainAttributes().getValue("Version");
                    data.mainClass = manifest.getMainAttributes().getValue("Main-Class");
                } catch (NumberFormatException e) {
                    needsToDownload = true;
                }
            }
        } catch (IOException e) {
            needsToDownload = true;
        }
    }
    if (needsToDownload) {
        URL latestJar = new URL(LATEST_JAR);
        System.out.println("Downloading latest Helios implementation");

        FileOutputStream out = new FileOutputStream(IMPL_FILE);
        HttpURLConnection connection = (HttpURLConnection) latestJar.openConnection();
        if (connection.getResponseCode() == 200) {
            int contentLength = connection.getContentLength();
            if (contentLength > 0) {
                InputStream stream = connection.getInputStream();
                byte[] buffer = new byte[1024];
                int amnt;
                AtomicInteger total = new AtomicInteger();
                AtomicBoolean stop = new AtomicBoolean(false);

                Thread progressBar = new Thread() {
                    public void run() {
                        JPanel panel = new JPanel();
                        panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

                        JLabel label = new JLabel();
                        label.setText("Downloading latest Helios build");
                        panel.add(label);

                        GridLayout layout = new GridLayout();
                        layout.setColumns(1);
                        layout.setRows(3);
                        panel.setLayout(layout);
                        JProgressBar pbar = new JProgressBar();
                        pbar.setMinimum(0);
                        pbar.setMaximum(100);
                        panel.add(pbar);

                        JTextArea textArea = new JTextArea(1, 3);
                        textArea.setOpaque(false);
                        textArea.setEditable(false);
                        textArea.setText("Downloaded 00.00MB/00.00MB");
                        panel.add(textArea);

                        JFrame frame = new JFrame();
                        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                        frame.setContentPane(panel);
                        frame.pack();
                        frame.setLocationRelativeTo(null);
                        frame.setVisible(true);

                        while (!stop.get()) {
                            SwingUtilities.invokeLater(
                                    () -> pbar.setValue((int) (100.0 * total.get() / contentLength)));

                            textArea.setText("Downloaded " + bytesToMeg(total.get()) + "MB/"
                                    + bytesToMeg(contentLength) + "MB");
                            try {
                                Thread.sleep(100);
                            } catch (InterruptedException ignored) {
                            }
                        }
                        frame.dispose();
                    }
                };
                progressBar.start();

                while ((amnt = stream.read(buffer)) != -1) {
                    out.write(buffer, 0, amnt);
                    total.addAndGet(amnt);
                }
                stop.set(true);
                return loadHelios();
            } else {
                throw new IOException("Content-Length set to " + connection.getContentLength());
            }
        } else if (connection.getResponseCode() == 404) { // Most likely bootstrapper is out of date
            throw new RuntimeException("Bootstrapper out of date!");
        } else {
            throw new IOException(connection.getResponseCode() + ": " + connection.getResponseMessage());
        }
    }

    return data;
}

From source file:Main.java

public Main() {
    JButton button = new JButton("w w w.j a v a 2 s . c o m");
    add(button);//from w w w.j  a v a  2 s .c  o  m
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));

    GridLayout gridLayout = new GridLayout();

    gridLayout.setColumns(2);
    gridLayout.setRows(2);
    setLayout(gridLayout);

}

From source file:problema_inventario.vistas.GraphicCostos.java

private void initLayout() {
    GridLayout l = new GridLayout();
    l.setColumns(1);
    l.setRows(1);//from   ww  w .j av  a 2s.c  om
    panelGrafica.setLayout(l);
    panelGrafica.add(chart);
}

From source file:EspectroForm.java

private void initPanel() {
    GridLayout gL = new GridLayout();
    gL.setColumns(1);
    gL.setRows(1);/*from  ww w .j  a v a  2 s.com*/

    spectroPanel.setLayout(gL);
    spectroPanel.setPreferredSize(new Dimension(240, 350));
    spectroPanel.add(spectroChart);
}

From source file:gtu.xml.xstream.iisi.MQDecodeUI.java

private void initGUI() {
    try {//w w  w  .ja  va2  s  .  c o  m
        JCommonUtil.defaultLookAndFeel();
        GridLayout thisLayout = new GridLayout(3, 1);
        thisLayout.setColumns(1);
        thisLayout.setHgap(5);
        thisLayout.setVgap(5);
        thisLayout.setRows(3);
        getContentPane().setLayout(thisLayout);
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            beforeArea = new JTextArea();
            getContentPane().add(beforeArea);
        }
        {
            afterArea = new JTextArea();
            getContentPane().add(afterArea);
        }
        {
            jPanel1 = new JPanel();
            FlowLayout jPanel1Layout = new FlowLayout();
            getContentPane().add(jPanel1);
            jPanel1.setPreferredSize(new java.awt.Dimension(546, 38));
            jPanel1.setLayout(jPanel1Layout);
            {
                executeBtn = new JButton();
                jPanel1.add(executeBtn);
                executeBtn.setText("\u7522\u751f");
                executeBtn.setPreferredSize(new java.awt.Dimension(78, 22));
                executeBtn.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        try {
                            Validate.notBlank(beforeArea.getText(), "messgaeContent");
                            String msg2 = beforeArea.getText();

                            XmlParserImpl xmlParserImpl = new XmlParserImpl();
                            final String jmsMessageXML = StringCompressUtil.uncompress(msg2);
                            JmsMessageNew jmsMessageNew = (JmsMessageNew) xmlParserImpl
                                    .parseToObj(jmsMessageXML);
                            String returnMessage = jmsMessageNew.getMessageXML();
                            System.out.println(returnMessage);
                            afterArea.setText(returnMessage);
                            System.out.println("done...");
                        } catch (Exception ex) {
                            JCommonUtil.handleException(ex);
                        }
                    }
                });
            }
            {
                cleanBtn = new JButton();
                jPanel1.add(cleanBtn);
                cleanBtn.setText("\u6e05\u9664");
                cleanBtn.setPreferredSize(new java.awt.Dimension(78, 22));
                cleanBtn.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        try {
                            beforeArea.setText("");
                            afterArea.setText("");
                        } catch (Exception ex) {
                            JCommonUtil.handleException(ex);
                        }
                    }
                });
            }
        }
        pack();
        this.setSize(554, 402);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:syg_package01.PanelRysunek2.java

private void initGUI() {
    try {//from w  w  w. j av  a2s  . c  o  m
        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) {
            double punkt = this.sygnalWyswietlany.gett1();
            HistogramDataset histogramDataset = new HistogramDataset();
            histogramDataset.setType(HistogramType.FREQUENCY);
            ArrayList<Double> punkty = new ArrayList<Double>();

            double ta = this.sygnalWyswietlany.gett1();

            if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.CIAGLY
                    || sygnalWyswietlany.getPunktyY().size() <= 0) {
                while (ta <= this.sygnalWyswietlany.gett1() + this.sygnalWyswietlany.getd()) {
                    punkt = this.sygnalWyswietlany.wykres_punkty(punkt, ta);
                    // this.sygnalWyswietlany.setPunktyY (punkt);
                    punkty.add(punkt);
                    ta = ta + this.sygnalWyswietlany.getkroczek();
                }
            } else if (this.sygnalWyswietlany.getrodzaj() == rodzaj_sygnalu.DYSKRETNY) {
                int iloscProbek = (int) (this.sygnalWyswietlany.getT()
                        / (Double) this.sygnalWyswietlany.getkroczek());
                for (int i = 0; i < iloscProbek; i++) {
                    punkt = this.sygnalWyswietlany.getPunktzindexu(i);
                    punkty.add(punkt);
                    ta = ta + this.sygnalWyswietlany.getkroczek();
                }
            }

            JFreeChart chartHist;
            if (this.iloscPrzedzialowHistogramu > 0) {
                double[] tablicaHistogramu = new double[punkty.size()];
                for (int licznik = 0; licznik < punkty.size(); ++licznik)
                    tablicaHistogramu[licznik] = punkty.get(licznik);

                histogramDataset.addSeries("Histogram (" + iloscPrzedzialowHistogramu + ")", tablicaHistogramu,
                        this.iloscPrzedzialowHistogramu);

                chartHist = ChartFactory.createHistogram("Histogram", null, null, histogramDataset,
                        PlotOrientation.VERTICAL, true, false, false);

                final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
                renderer.setSeriesLinesVisible(0, false);

                ChartPanel chartpanel1 = new ChartPanel(chartHist);
                chartpanel1.setDomainZoomable(true);

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

From source file:syg_package01.PanelRysunek_Wykres.java

private void initGUI() {
    try {//from   ww w  . jav  a  2s  . co  m
        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("Wykres");
            double punkt;
            double ta = this.sygnalWyswietlany.gett1();

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

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

            if ((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());
            }

            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:syg_Wykresy.PanelRysunek_Wykres.java

private void initGUI() {
    try {//from w w  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:syg_package01.PanelRysunek.java

private void initGUI() {
    try {//from   w ww  .j a va  2 s  . c  o m
        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) {
            double punkt = this.sygnalWyswietlany.gett1();
            double punktZapisu = this.sygnalWyswietlany.gett1();
            XYSeries series = new XYSeries("Wykres");

            double krok;
            int typ = this.sygnalWyswietlany.gettyp();
            double f = 1.0 / this.sygnalWyswietlany.getT();
            double t = this.sygnalWyswietlany.gett1();

            // if (this.sygnalWyswietlany.gettyp()==1){
            /*
             * for (double i = this.sygnalWyswietlany.gett1(); i <
             * this.sygnalWyswietlany.t1+this.sygnalWyswietlany.getts();
             * i++){ punkt= this.sygnalWyswietlany.wykres_punkty(punkt, i);
             * series.add(i, punkt)} ;
             */

            double ta = this.sygnalWyswietlany.gett1();

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

            // this.sygnalWyswietlany.ustawPunkty();
            /*
             * int liczba= this.sygnalWyswietlany.punktyY.size(); int
             * liczba2= 0;
             * 
             * while (liczba2<liczba) { ta= ta+
             * this.sygnalWyswietlany.getkroczek();
             * series.add(ta,this.sygnalWyswietlany
             * .getPunktzindexu(liczba2));
             * 
             * }
             */

            XYSeriesCollection dataset = new XYSeriesCollection(series);

            // JFreeChart chart = ChartFactory.createHistogram("Histogram",
            // "x", "y", dataset, PlotOrientation.VERTICAL, false, false,
            // false);

            JFreeChart chart;

            /*
             * JFreeChart chart = ChartFactory.createScatterPlot("Wykres",
             * "t[s]", "Warto", dataset, PlotOrientation.VERTICAL, false,
             * false, false);
             */
            if ((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();
                // plot.setBackgroundPaint(Color.lightGray);
                // plot.setDomainGridlinePaint(Color.white);
                // plot.setRangeGridlinePaint(Color.white);

                // final XYLineAndShapeRenderer renderer = new
                // XYLineAndShapeRenderer();
                final XYDotRenderer renderer = new XYDotRenderer();
                renderer.setDotHeight(3);
                renderer.setDotWidth(3);
                plot.setRenderer(renderer);

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

            // ChartPanel chartpanel = new ChartPanel(wykres2);
            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:ResultScreen.java

private void initPanels() {
    GridLayout gL = new GridLayout();
    gL.setColumns(1);
    gL.setRows(1);//from w  w  w  .  j  a  va  2 s. c  om

    demoduladaPanel.setLayout(gL);
    demoduladaPanel.setPreferredSize(new Dimension(150, 200));
    demoduladaPanel.add(demoduladaChart);
    moduladaPanel.setLayout(gL);
    moduladaPanel.setPreferredSize(new Dimension(150, 200));
    moduladaPanel.add(moduladaChart);
}