Example usage for javax.swing JPanel setSize

List of usage examples for javax.swing JPanel setSize

Introduction

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

Prototype

public void setSize(int width, int height) 

Source Link

Document

Resizes this component so that it has width width and height height .

Usage

From source file:Main.java

public static void main(String args[]) {
    String[] columnNames = { "Date", "Field", "Home Team", "Visitor Team", "Score" };
    JFrame guiFrame = new JFrame();
    guiFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    guiFrame.setSize(500, 500);/*from www .jav  a  2  s .co m*/

    JPanel panel = new JPanel();
    panel.setSize(450, 450);
    JLabel titleLabel = new JLabel("OK");
    String[][] data = new String[0][0];
    JTable scheduleTable = new JTable(data, columnNames);
    JScrollPane scrollPane = new JScrollPane(scheduleTable);
    panel.add(scrollPane);
    panel.add(titleLabel);

    guiFrame.add(panel);
    guiFrame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    JPanel panel = new JPanel();
    Container c = frame.getContentPane();
    panel.setSize(100, 100);
    panel.setLayout(new GridLayout(1000, 1));
    for (int i = 0; i < 1000; i++)
        panel.add(new JLabel("JLabel " + i));

    JScrollPane jsp = new JScrollPane(panel);
    c.add(jsp);//from   ww  w  .j a v  a2 s  . c o m
    frame.setSize(100, 100);
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    final int w = 20;
    final int side = 25;
    final int[][] grid = new int[50][w];

    JPanel panel = new JPanel() {
        public void paintComponent(Graphics g) {
            Font font = new Font("WingDings", Font.PLAIN, 14);
            g.setFont(font);/*  w  ww  . ja  va 2 s . c  o m*/
            int off = 0;
            for (int i = 0; i < 256 * 256; i++) {
                if (font.canDisplay((char) i)) {
                    off++;
                    grid[off / w][off % w] = i;
                    int x = off % w * side;
                    int y = (off / w) * side + side;
                    g.drawString("" + (char) i, x, y);
                }
            }
        }
    };
    JFrame frame = new JFrame();
    panel.setSize(300, 300);
    frame.getContentPane().add(panel);
    frame.setSize(300, 300);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    final int columnCount = 10;
    final int side = 25;
    final int[][] grid = new int[50][columnCount];

    JPanel panel = new JPanel() {
        public void paintComponent(Graphics g) {
            Font font = new Font("WingDings", Font.PLAIN, 14);
            g.setFont(font);// w ww.  j  a va 2 s  .c o m
            int off = 0;
            for (int i = 0; i < 256 * 256; i++) {
                if (font.canDisplay((char) i) == false) {
                    continue;
                }
                off++;
                grid[off / columnCount][off % columnCount] = i;
                int x = off % columnCount * side;
                int y = (off / columnCount) * side + side;
                g.drawString(Character.toString((char) i), x, y);

            }
        }
    };
    JFrame frame = new JFrame();
    panel.setSize(300, 300);
    frame.getContentPane().add(panel);
    frame.setSize(300, 300);
    frame.setVisible(true);
}

From source file:ScrollDemo.java

public void init() {
    JRadioButton form[][] = new JRadioButton[12][5];
    String counts[] = { "", "0-1", "2-5", "6-10", "11-100", "101+" };
    String categories[] = { "Household", "Office", "Extended Family", "Company (US)", "Company (World)", "Team",
            "Will", "Birthday Card List", "High School", "Country", "Continent", "Planet" };
    JPanel p = new JPanel();
    p.setSize(600, 400);
    p.setLayout(new GridLayout(13, 6, 10, 0));
    for (int row = 0; row < 13; row++) {
        ButtonGroup bg = new ButtonGroup();
        for (int col = 0; col < 6; col++) {
            if (row == 0) {
                p.add(new JLabel(counts[col]));
            } else {
                if (col == 0) {
                    p.add(new JLabel(categories[row - 1]));
                } else {
                    form[row - 1][col - 1] = new JRadioButton();
                    bg.add(form[row - 1][col - 1]);
                    p.add(form[row - 1][col - 1]);
                }//from   www .  ja v a 2s .  c  o  m
            }
        }
    }
    scrollpane = new JScrollPane(p);
    getContentPane().add(scrollpane, BorderLayout.CENTER);
}

From source file:my.jabbr.app.ftpclient.ui.install.ProductLicenseInstallationPanel.java

private JPanel createTransparentFillerPanel() {
    JPanel panel = new JPanel();
    panel.setSize(645, 50);
    panel.setOpaque(false);//  w  w w . j  a v  a  2  s  .  c  om
    panel.setBorder(null);
    return panel;
}

From source file:probe.com.model.util.vaadintoimageutil.HeatmapSwingComponent.java

private JPanel initCell(String color, int x, int y) {
    JPanel cell = new JPanel();
    cell.setSize(50, 50);
    cell.setBackground(Color.decode(color));
    cell.setOpaque(true);/*  ww w .  j av  a2 s  .  co m*/
    cell.setLocation(x, y);
    cell.setBorder(new LineBorder(Color.WHITE));
    return cell;

}

From source file:ScrollDemo2.java

public void init() {
    JRadioButton form[][] = new JRadioButton[12][5];
    String counts[] = { "", "0-1", "2-5", "6-10", "11-100", "101+" };
    String categories[] = { "Household", "Office", "Extended Family", "Company (US)", "Company (World)", "Team",
            "Will", "Birthday Card List", "High School", "Country", "Continent", "Planet" };
    JPanel p = new JPanel();
    p.setSize(600, 400);
    p.setLayout(new GridLayout(13, 6, 10, 0));
    for (int row = 0; row < 13; row++) {
        ButtonGroup bg = new ButtonGroup();
        for (int col = 0; col < 6; col++) {
            if (row == 0) {
                p.add(new JLabel(counts[col]));
            } else {
                if (col == 0) {
                    p.add(new JLabel(categories[row - 1]));
                } else {
                    form[row - 1][col - 1] = new JRadioButton();
                    bg.add(form[row - 1][col - 1]);
                    p.add(form[row - 1][col - 1]);
                }// w ww  .  j av  a 2 s .co  m
            }
        }
    }
    scrollpane = new JScrollPane(p);

    // Add in some JViewports for the column and row headers
    JViewport jv1 = new JViewport();
    jv1.setView(new JLabel(new ImageIcon("columnlabel.gif")));
    scrollpane.setColumnHeader(jv1);
    JViewport jv2 = new JViewport();
    jv2.setView(new JLabel(new ImageIcon("rowlabel.gif")));
    scrollpane.setRowHeader(jv2);

    // And throw in an information button
    JButton jb1 = new JButton(new ImageIcon("question.gif"));
    jb1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            JOptionPane.showMessageDialog(null, "This is an Active Corner!", "Information",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    });
    scrollpane.setCorner(ScrollPaneConstants.UPPER_LEFT_CORNER, jb1);
    getContentPane().add(scrollpane, BorderLayout.CENTER);
}

From source file:probe.com.view.body.quantdatasetsoverview.diseasegroupsfilters.heatmap.HeatMapImgGenerator.java

private JPanel initCell(String color, int x, int y) {
    JPanel cell = new JPanel();
    cell.setSize(50, 50);
    Color c;//from   ww w. j  a va2s.  c o  m
    if (color.contains("#")) {
        c = Color.decode(color);
    } else if (color.toLowerCase().contains("rgb")) {
        String rgb = color.toLowerCase().replace("rgb", "").replace("(", "").replace(")", "").replace(" ", "");
        String[] stringRGBArr = rgb.split(",");
        c = new Color(Integer.valueOf(stringRGBArr[0]), Integer.valueOf(stringRGBArr[1]),
                Integer.valueOf(stringRGBArr[2]));
    } else {
        c = Color.RED;
    }

    cell.setBackground(c);
    cell.setOpaque(true);
    cell.setLocation(x, y);
    cell.setBorder(new LineBorder(Color.WHITE));
    return cell;

}

From source file:ANNFileDetect.GraphingClass.java

public void drawchartFromInt(Integer[] values) throws IOException {
    DefaultCategoryDataset ds = new DefaultCategoryDataset();
    for (int i = 0; i < values.length; i++) {
        //double a = (double) i;
        ds.addValue(i, String.valueOf(i), String.valueOf(values[i]));
        //ds.addValue((double)i, "Times", values[i]);
    }/*  www .j  a  va  2s  .  c o  m*/
    JFreeChart chart = ChartFactory.createBarChart("chart", "quantity", "value", ds, PlotOrientation.VERTICAL,
            true, true, false);
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setSize(1200, 700);
    JPanel jf = new JPanel();
    jf.setSize(1300, 800);
    chartPanel.setVisible(true);
    chartPanel.setZoomAroundAnchor(true);
    chartPanel.setDomainZoomable(true);
    jf.add(chartPanel);
    JLabel jl = new JLabel("hello!");
    jf.add(jl);
    jf.setVisible(true);
    jf.repaint();
    //jf.setAlwaysOnTop(true);
}