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:hext.HexView.java

/**
 * Creates new form HexView// w w  w .j ava2s  . c o  m
 */
public HexView(ITab tab) {
    super(new GridLayout(1, 1));
    initComponents();
    addComponentListener(new HexResizeListener());
    splitPane.setDividerLocation(0.66);
    this.tab = tab;
}

From source file:MonthPanel.java

protected JPanel createDaysGUI() {
    JPanel dayPanel = new JPanel(true);
    dayPanel.setLayout(new GridLayout(0, dayNames.length));

    Calendar today = Calendar.getInstance();
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.DAY_OF_MONTH, 1);

    Calendar iterator = (Calendar) calendar.clone();
    iterator.add(Calendar.DAY_OF_MONTH, -(iterator.get(Calendar.DAY_OF_WEEK) - 1));

    Calendar maximum = (Calendar) calendar.clone();
    maximum.add(Calendar.MONTH, +1);

    for (int i = 0; i < dayNames.length; i++) {
        JPanel dPanel = new JPanel(true);
        dPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        JLabel dLabel = new JLabel(dayNames[i]);
        dPanel.add(dLabel);//from   w  w  w. j  a  v a  2 s  .  co  m
        dayPanel.add(dPanel);
    }

    int count = 0;
    int limit = dayNames.length * 6;

    while (iterator.getTimeInMillis() < maximum.getTimeInMillis()) {
        int lMonth = iterator.get(Calendar.MONTH);
        int lYear = iterator.get(Calendar.YEAR);

        JPanel dPanel = new JPanel(true);
        dPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
        JLabel dayLabel = new JLabel();

        if ((lMonth == month) && (lYear == year)) {
            int lDay = iterator.get(Calendar.DAY_OF_MONTH);
            dayLabel.setText(Integer.toString(lDay));
        }
        dPanel.add(dayLabel);
        dayPanel.add(dPanel);
        iterator.add(Calendar.DAY_OF_YEAR, +1);
        count++;
    }

    for (int i = count; i < limit; i++) {
        JPanel dPanel = new JPanel(true);
        dPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

        dPanel.add(new JLabel());
        dayPanel.add(dPanel);
    }
    return dayPanel;
}

From source file:de.mpicbg.knime.hcs.core.view.OverlayLegendDialog.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Open Source Project license - Sphinx-4 (cmusphinx.sourceforge.net/sphinx4/)
    scrollPane1 = new JScrollPane();
    legendContainer = new JPanel();

    //======== this ========
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== scrollPane1 ========
    {//from  w w  w . j  ava 2  s  .co m

        //======== legendContainer ========
        {
            legendContainer.setLayout(new GridLayout(0, 1));
        }
        scrollPane1.setViewportView(legendContainer);
    }
    contentPane.add(scrollPane1, BorderLayout.CENTER);
    pack();
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:Main.java

public Main() {
    super(new BorderLayout());
    populateTree(treePanel);// ww  w  .  j  a v  a  2s  . co  m
    JButton addButton = new JButton("Add");
    addButton.setActionCommand(ADD_COMMAND);
    addButton.addActionListener(this);
    JButton removeButton = new JButton("Remove");
    removeButton.setActionCommand(REMOVE_COMMAND);
    removeButton.addActionListener(this);
    JButton clearButton = new JButton("Clear");
    clearButton.setActionCommand(CLEAR_COMMAND);
    clearButton.addActionListener(this);
    treePanel.setPreferredSize(new Dimension(300, 150));
    add(treePanel, BorderLayout.CENTER);
    JPanel panel = new JPanel(new GridLayout(0, 3));
    panel.add(addButton);
    panel.add(removeButton);
    panel.add(clearButton);
    add(panel, BorderLayout.SOUTH);
}

From source file:com.streamhub.StreamHubLicenseGenerator.java

public StreamHubLicenseGenerator() {
    super("StreamHub License Generator");
    this.setLayout(new GridLayout(0, 1));
    for (int i = 0; i < ROWS; i++) {
        JPanel row = createMacAddressRow();
        macAddressPanels.add(row);//from  www .  ja  va  2s  .  c  o  m
        this.add(row);
    }
    JPanel actionsRow = createActionsRow();
    this.add(actionsRow);
    this.setSize(new Dimension(900, 500));
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:Main.java

public Main() {
    setSize(500, 340);// w ww. ja va  2s  .  c  o m

    Date currentDate = new Date();
    calendar.setTime(currentDate);

    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(4, 1));

    JPanel p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Selected Date"));
    dateLabel = new JLabel(dateFormat.format(currentDate) + "     ");
    dateLabel.setFont(new Font("Arial", Font.BOLD, 24));
    p.add(dateLabel);
    p1.add(p);

    yearSlider.setPaintLabels(true);
    yearSlider.setMajorTickSpacing(5);
    yearSlider.setMinorTickSpacing(1);
    yearSlider.setPaintTicks(true);
    DateListener lst = new DateListener();
    yearSlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Year"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(yearSlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    String[] months = (new DateFormatSymbols()).getShortMonths();
    hashTable = new Hashtable(12);
    for (int i = 0; i < 12; i++)
        hashTable.put(new Integer(i + 1), new JLabel(months[i], JLabel.CENTER));
    monthSlider.setLabelTable(hashTable);
    monthSlider.setPaintLabels(true);
    monthSlider.setMajorTickSpacing(1);
    monthSlider.setPaintTicks(true);
    monthSlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Month"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(monthSlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    daySlider = new JSlider(JSlider.HORIZONTAL, 1, maxDays, calendar.get(Calendar.DAY_OF_MONTH));
    daySlider.setPaintLabels(true);
    daySlider.setMajorTickSpacing(5);
    daySlider.setMinorTickSpacing(1);
    daySlider.setPaintTicks(true);
    daySlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Day"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(daySlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    getContentPane().add(p1, BorderLayout.CENTER);

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

    enableEvents(ComponentEvent.COMPONENT_RESIZED);
    setVisible(true);
}

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

public ChartDialog(Frame parent, JFreeChart moodChart, JFreeChart sentimentChart) {
    super(parent, true);

    this.parent = parent;

    this.setLayout(new BorderLayout(5, 5));

    setTitle("Chart");
    setSize(350, 225);/*from w w w . j  a  va  2 s .c  o  m*/
    setResizable(false);
    setVisible(false);

    JPanel chartPanel = new JPanel(new GridLayout(1, 2));

    chartPanel.add(new ChartPanel(moodChart));
    chartPanel.add(new ChartPanel(sentimentChart));

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 15));
    panel.add(okButton);

    this.add(chartPanel, BorderLayout.CENTER);
    this.add(panel, BorderLayout.SOUTH);

    UserActionListener userActionListener = new UserActionListener();
    okButton.addActionListener(userActionListener);
}

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

public static JPanel createDemoPanel() {
    JPanel jpanel = new JPanel(new GridLayout(2, 2));
    jpanel.setPreferredSize(new Dimension(800, 600));
    IntervalXYDataset intervalxydataset = createDataset();
    JFreeChart jfreechart = createChart("Vertical", intervalxydataset);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setDrawBarOutline(false);
    xybarrenderer.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    xybarrenderer.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    xybarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    jpanel.add(chartpanel);//from   w ww .j  a  v  a 2 s .  c o m
    JFreeChart jfreechart1 = createChart("Vertical / Inverted Axis", intervalxydataset);
    XYPlot xyplot1 = (XYPlot) jfreechart1.getPlot();
    XYBarRenderer xybarrenderer1 = (XYBarRenderer) xyplot1.getRenderer();
    xybarrenderer1.setDrawBarOutline(false);
    xybarrenderer1.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    xybarrenderer1.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    xybarrenderer1.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));
    xyplot1.getDomainAxis().setInverted(true);
    ChartPanel chartpanel1 = new ChartPanel(jfreechart1);
    jpanel.add(chartpanel1);
    JFreeChart jfreechart2 = createChart("Horizontal", intervalxydataset);
    XYPlot xyplot2 = (XYPlot) jfreechart2.getPlot();
    xyplot2.setOrientation(PlotOrientation.HORIZONTAL);
    XYBarRenderer xybarrenderer2 = (XYBarRenderer) xyplot2.getRenderer();
    xybarrenderer2.setDrawBarOutline(false);
    xybarrenderer2.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    xybarrenderer2.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    xybarrenderer2.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL));
    ChartPanel chartpanel2 = new ChartPanel(jfreechart2);
    jpanel.add(chartpanel2);
    JFreeChart jfreechart3 = createChart("Horizontal / Inverted Axis", intervalxydataset);
    XYPlot xyplot3 = (XYPlot) jfreechart3.getPlot();
    xyplot3.setOrientation(PlotOrientation.HORIZONTAL);
    XYBarRenderer xybarrenderer3 = (XYBarRenderer) xyplot3.getRenderer();
    xybarrenderer3.setDrawBarOutline(false);
    xybarrenderer3.setSeriesPaint(0, new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, Color.yellow));
    xybarrenderer3.setSeriesPaint(1, new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, Color.green));
    xybarrenderer3.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    xyplot3.getDomainAxis().setInverted(true);
    ChartPanel chartpanel3 = new ChartPanel(jfreechart3);
    jpanel.add(chartpanel3);
    return jpanel;
}

From source file:table.FrequencyTablePanel.java

public FrequencyTablePanel(String[] datas, String[] values) {
    super(new GridLayout(1, 0));
    super.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    data = new ArrayList<>();
    tableModel = new MyTableModel(data);
    table = new JTable(tableModel);
    table.setRowHeight(40);//w ww  .  j a  va 2s. c o m
    // table.getColumnModel().getColumn(0).setResizable(false);
    // table.getColumnModel().getColumn(0).setMaxWidth(120);
    // table.getColumnModel().getColumn(1).setResizable(false);
    // table.getColumnModel().getColumn(1).setMaxWidth(120);
    table.setDefaultRenderer(Object.class, new MyTableCellRenderer2());
    for (int i = 0; i < tableModel.getColumnCount(); i++) {
        table.getTableHeader().getColumnModel().getColumn(i)
                .setHeaderRenderer(new HeaderRenderer(table, alignments[1]));
        // table.getColumnModel().getColumn(i).setCellRenderer(new
        // MyTableCellRenderer());
    }
    table.getTableHeader().setReorderingAllowed(false);
    table.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
    // table.setPreferredScrollableViewportSize(new Dimension(10000, 200));

    // Create the scroll pane and add the table to it.
    for (int i = 0; i < datas.length; i++) {
        String[] a = new String[2];
        a[0] = datas[i];
        a[1] = values[i];
        this.tableModel.addRow(a);
    }
    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.setPreferredSize(new Dimension(7000, 20));
    // scrollPane.setHorizontalScrollBar(new
    // JScrollBar(JScrollBar.HORIZONTAL));
    // Add the scroll pane to this panel.
    add(scrollPane);
}

From source file:compecon.dashboard.panel.AgentsPanel.java

public AgentsPanel() {

    this.setLayout(new BorderLayout());

    JTabbedPane jTabbedPane = new JTabbedPane();

    for (Currency currency : Currency.values()) {
        JPanel panelForCurrency = new JPanel();
        panelForCurrency.setLayout(new GridLayout(0, 2));
        jTabbedPane.addTab(currency.getIso4217Code(), panelForCurrency);

        panelForCurrency.setBackground(Color.lightGray);

        for (Class<? extends Agent> agentType : ApplicationContext.getInstance().getAgentFactory()
                .getAgentTypes()) {//w w  w  .  j  a v  a2  s  . c o  m
            panelForCurrency.add(createAgentNumberPanel(currency, agentType));
        }
    }

    add(jTabbedPane, BorderLayout.CENTER);
}