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:com.vrane.metaGlacier.gui.SNSTopicDialog.java

SNSTopicDialog() {
    super(Main.frame, true);
    JPanel mainPanel = new JPanel(new GridLayout(4, 2));
    final JTextField topicNameJT = new JTextField(10);
    final JTextField emailJT = new JTextField(10);
    final JButton subscribeButton = new JButton("subscribe");

    mainPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));

    mainPanel.add(new JLabel("topic name"));
    mainPanel.add(topicNameJT);//  w  w w . ja va 2  s .  c  om

    mainPanel.add(new JLabel("email"));
    mainPanel.add(emailJT);

    final String metadata_account_email = Main.frame.getMPCUser();
    if (metadata_account_email != null) {
        emailJT.setText(metadata_account_email);
    }

    mainPanel.add(new JLabel());
    mainPanel.add(subscribeButton);
    subscribeButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent ae) {
            final String email = emailJT.getText();
            final String name = topicNameJT.getText();
            boolean success = false;

            if (!EmailValidator.getInstance().isValid(email)) {
                JOptionPane.showMessageDialog(null, "Invalid email address");
                return;
            }
            try {
                success = new SNSTopic().createTopic(name, email);
            } catch (Exception ex) {
                LGR.log(Level.SEVERE, null, ex);
            }
            if (success) {
                JOptionPane.showMessageDialog(null, "Please check your email to confirm");
                dispose();
                return;
            }
            JOptionPane.showMessageDialog(null, "Error subscribing");
        }
    });
    add(mainPanel);
    pack();
    setLocationRelativeTo(Main.frame);
    setVisible(true);
}

From source file:ColorConvertDemo.java

public ColorConvertDemo() {
    super();//from  w  w  w.j a  v a  2  s.  com
    Container container = getContentPane();

    displayPanel = new ColorPanel();
    container.add(displayPanel);

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 2));
    panel.setBorder(new TitledBorder("Click the Gray Scale Button to Create Gray Scale Image..."));

    grayButton = new JButton("Gray Scale");
    grayButton.addActionListener(new ButtonListener());
    resetButton = new JButton("Reset");
    resetButton.addActionListener(new ButtonListener());

    panel.add(grayButton);
    panel.add(resetButton);

    container.add(BorderLayout.SOUTH, panel);

    addWindowListener(new WindowEventHandler());

    setSize(displayPanel.getWidth(), displayPanel.getHeight() + 15);
    setVisible(true);
}

From source file:PrinterSettingUpDialogPrint.java

public PrinterSettingUpDialogPrint() {
    getContentPane().add(canvas);/*from  ww  w. j av a 2s.  c  om*/

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(1, 3));

    setUpButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent a) {
            setup();
        }
    });
    panel.add(setUpButton);
    printButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent a) {
            print();
        }
    });
    panel.add(printButton);
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent a) {
            cancel();
        }
    });
    panel.add(cancelButton);
    getContentPane().add(BorderLayout.SOUTH, panel);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 275);
    setVisible(true);
}

From source file:FileChooserTest.java

public FileChooserTest() {
    JPanel p = new JPanel();
    open.addActionListener(new OpenL());
    p.add(open);/*www.  j  a  va 2s .c o m*/
    save.addActionListener(new SaveL());
    p.add(save);
    Container cp = getContentPane();
    cp.add(p, BorderLayout.SOUTH);
    dir.setEditable(false);
    filename.setEditable(false);
    p = new JPanel();
    p.setLayout(new GridLayout(2, 1));
    p.add(filename);
    p.add(dir);
    cp.add(p, BorderLayout.NORTH);
}

From source file:Main.java

public Main() {
    Image grass = createImage(Color.green);
    Image water = createImage(Color.blue);
    grassIcon = new ImageIcon(grass);
    waterIcon = new ImageIcon(water);

    setLayout(new GridLayout(labelGrid.length, labelGrid[0].length));
    for (int row = 0; row < labelGrid.length; row++) {
        for (int col = 0; col < labelGrid[row].length; col++) {
            ImageIcon icon = MAP_1_ST[row].charAt(col) == '0' ? grassIcon : waterIcon;
            labelGrid[row][col] = new JLabel(icon);
            add(labelGrid[row][col]);//from w  w  w .  ja  va  2 s . c  o  m
        }
    }
}

From source file:ConvolveApp.java

public ConvolveApp() {
    super();//from   w  w w  .  j  a  v a 2s . c om
    Container container = getContentPane();

    displayPanel = new CPanel();
    container.add(displayPanel);

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2, 2));
    panel.setBorder(new TitledBorder("Click a Button to Perform the Associated Operation and Reset..."));

    sharpenButton = new JButton("Sharpen");
    sharpenButton.addActionListener(new ButtonListener());
    blurringButton = new JButton("Blur");
    blurringButton.addActionListener(new ButtonListener());
    edButton = new JButton("Edge Detect");
    edButton.addActionListener(new ButtonListener());
    resetButton = new JButton("Reset");
    resetButton.addActionListener(new ButtonListener());

    panel.add(sharpenButton);
    panel.add(blurringButton);
    panel.add(edButton);
    panel.add(resetButton);

    container.add(BorderLayout.SOUTH, panel);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    setSize(displayPanel.getWidth(), displayPanel.getHeight() + 10);
    setVisible(true);
}

From source file:SystemFontDisplayer.java

public SystemFontDisplayer() {
    Container container = getContentPane();
    displayPanel = new DisplayPanel();
    container.add(displayPanel);// www .ja v  a 2  s .co m
    JPanel controlPanel = new JPanel();
    controlPanel.setLayout(new GridLayout(1, 3));

    fontsBox = new JComboBox(displayPanel.fontFamilyNames);
    fontsBox.setSelectedItem("Arial");
    fontsBox.addActionListener(new ComboBoxListener());

    fontStylesBox.addActionListener(new ComboBoxListener());

    fontSizesBox.setSelectedItem("36");
    fontSizesBox.addActionListener(new ComboBoxListener());
    controlPanel.add(fontsBox);
    controlPanel.add(fontStylesBox);
    controlPanel.add(fontSizesBox);
    container.add(BorderLayout.SOUTH, controlPanel);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    pack();
    setSize(400, 250);
    setVisible(true);
}

From source file:SimpleBufferedImageDemo.java

public SimpleBufferedImageDemo() {
    super();/*from  w w w  .  j  av a  2  s  .c  o m*/
    Container container = getContentPane();

    canvas = new DisplayCanvas();
    container.add(canvas);

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2, 2));
    panel.setBorder(new TitledBorder("Select an Option and Display Image..."));

    buffButton = new JRadioButton("Buffered");
    buffButton.addActionListener(new ButtonListener());
    nonBuffButton = new JRadioButton("Non-Buffered", true);
    nonBuffButton.addActionListener(new ButtonListener());
    ButtonGroup group = new ButtonGroup();
    group.add(buffButton);
    group.add(nonBuffButton);

    displayButton = new JButton("Display");
    displayButton.addActionListener(new ButtonListener());
    clearButton = new JButton("Clear");
    clearButton.addActionListener(new ButtonListener());

    panel.add(nonBuffButton);
    panel.add(buffButton);
    panel.add(displayButton);
    panel.add(clearButton);

    container.add(BorderLayout.SOUTH, panel);

    addWindowListener(new WindowEventHandler());
    pack();
    setVisible(true);
}

From source file:Main.java

public void build() {
    setSize(600, 600);//from w ww  .  j  a  v  a 2 s.  c o m
    JTextPane textPane = new JTextPane();

    JScrollPane scrollPane = new JScrollPane(textPane);
    scrollPane.setPreferredSize(new Dimension(300, 300));

    JTextArea changeLog = new JTextArea(5, 30);
    changeLog.setEditable(false);
    JScrollPane scrollPaneForLog = new JScrollPane(changeLog);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, scrollPane, scrollPaneForLog);
    splitPane.setOneTouchExpandable(true);

    JPanel statusPane = new JPanel(new GridLayout(1, 1));
    JLabel caretListenerLabel = new JLabel("Caret Status");
    statusPane.add(caretListenerLabel);

    JToolBar toolBar = new JToolBar();
    toolBar.add(new JButton("Btn1"));
    toolBar.add(new JButton("Btn2"));
    toolBar.add(new JButton("Btn3"));
    toolBar.add(new JButton("Btn4"));

    getContentPane().add(toolBar, BorderLayout.PAGE_START);
    getContentPane().add(splitPane, BorderLayout.CENTER);
    getContentPane().add(statusPane, BorderLayout.PAGE_END);

    JMenu editMenu = new JMenu("test");
    JMenu styleMenu = new JMenu("test");
    JMenuBar mb = new JMenuBar();
    mb.add(editMenu);
    mb.add(styleMenu);
    setJMenuBar(mb);

}

From source file:Main.java

public Main() {
    super("Focus Example");
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    MyPanel mypanel = new MyPanel();

    JButton button1 = new JButton("One");
    JButton button2 = new JButton("Two");
    JButton button3 = new JButton("Three");
    JButton button4 = new JButton("Four");
    JButton button5 = new MyButton("Five*");
    JButton button6 = new MyButton("Six*");
    JButton button7 = new JButton("Seven");

    mypanel.add(button2);/*from   www . j ava2s.c o  m*/
    mypanel.add(button3);

    JInternalFrame frame1 = new JInternalFrame("Internal Frame 1", true, true, true, true);

    frame1.setBackground(Color.lightGray);
    frame1.getContentPane().setLayout(new GridLayout(2, 3));
    frame1.setSize(300, 200);

    frame1.getContentPane().add(button1);
    frame1.getContentPane().add(mypanel);
    frame1.getContentPane().add(button4);
    frame1.getContentPane().add(button5);
    frame1.getContentPane().add(button6);
    frame1.getContentPane().add(button7);

    JDesktopPane desktop = new JDesktopPane();
    desktop.add(frame1, new Integer(1));
    desktop.setOpaque(true);

    // Now set up the user interface window.
    Container contentPane = getContentPane();
    contentPane.add(desktop, BorderLayout.CENTER);
    setSize(new Dimension(400, 300));
    frame1.setVisible(true);
    setVisible(true);
}