Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Rozmery komponent
- // Každý komponent má rovnakú veľkosť. Rozmery komponent závisia od veľkosti kontajnera
- // a veľkosti medzier medzi komponentmi a veľkosti okrajov. GridLayout ignoruje
- // minimálnu, preferovanú aj maximálnu veľkosť komponent pri určovaní ich rozmerov.
- // Umiestnenie komponent
- // Komponenty sú umiestňované zľava doprava a zhora dole, v poradí v ktorom sú do
- // kontajneru pridávané.
- import java.awt.*;
- import javax.swing.*;
- public class Main extends JFrame {
- public Main() {
- setTitle("Priklad na pouzitie GridLayout");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- Container pane = getContentPane();
- pane.setLayout(new GridLayout(2,2)); // 2,2
- pane.add(new JButton("prvy"));
- pane.add(new JButton("druhy"));
- pane.add(new JButton("treti je dlhy ------- dlhy "));
- pane.add(new JButton("stvrty"));
- pane.add(new JButton("piaty"));
- pane.add(new JButton("siesty"));
- pane.add(new JButton("siedmy"));
- pane.add(new JButton("osmy"));
- pack();
- }
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- Main frame = new Main();
- frame.setVisible(true);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment