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:TextComponentTest.java

public TextComponentFrame() {
    setTitle("TextComponentTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    final JTextField textField = new JTextField();
    final JPasswordField passwordField = new JPasswordField();

    JPanel northPanel = new JPanel();
    northPanel.setLayout(new GridLayout(2, 2));
    northPanel.add(new JLabel("User name: ", SwingConstants.RIGHT));
    northPanel.add(textField);/*w ww  . j  ava 2 s.c  om*/
    northPanel.add(new JLabel("Password: ", SwingConstants.RIGHT));
    northPanel.add(passwordField);

    add(northPanel, BorderLayout.NORTH);

    final JTextArea textArea = new JTextArea(8, 40);
    JScrollPane scrollPane = new JScrollPane(textArea);

    add(scrollPane, BorderLayout.CENTER);

    // add button to append text into the text area

    JPanel southPanel = new JPanel();

    JButton insertButton = new JButton("Insert");
    southPanel.add(insertButton);
    insertButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            textArea.append("User name: " + textField.getText() + " Password: "
                    + new String(passwordField.getPassword()) + "\n");
        }
    });

    add(southPanel, BorderLayout.SOUTH);

    // add a text area with scroll bars

}

From source file:components.LabelDemo.java

public LabelDemo() {
    super(new GridLayout(3, 1)); //3 rows, 1 column
    JLabel label1, label2, label3;

    ImageIcon icon = createImageIcon("images/middle.gif", "a pretty but meaningless splat");

    //Create the first label.
    label1 = new JLabel("Image and Text", icon, JLabel.CENTER);
    //Set the position of its text, relative to its icon:
    label1.setVerticalTextPosition(JLabel.BOTTOM);
    label1.setHorizontalTextPosition(JLabel.CENTER);

    //Create the other labels.
    label2 = new JLabel("Text-Only Label");
    label3 = new JLabel(icon);

    //Create tool tips, for the heck of it.
    label1.setToolTipText("A label containing both image and text");
    label2.setToolTipText("A label containing only text");
    label3.setToolTipText("A label containing only an image");

    //Add the labels.
    add(label1);/*from   w  w w.  j a va 2  s.com*/
    add(label2);
    add(label3);
}

From source file:FolderViewer.java

public FolderViewer(Folder what) {
    super(new GridLayout(1, 1));

    table = new JTable(model);
    table.setShowGrid(false);//from   w  w w . j  a v  a 2 s. c o m

    scrollpane = new JScrollPane(table);

    // setup the folder we were given
    setFolder(what);

    // find out what is pressed
    table.getSelectionModel().addListSelectionListener(new FolderPressed());
    scrollpane.setPreferredSize(new Dimension(700, 300));
    add(scrollpane);
}

From source file:components.SimpleTableDemo.java

public SimpleTableDemo() {
    super(new GridLayout(1, 0));

    String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" };

    Object[][] data = { { "Kathy", "Smith", "Snowboarding", new Integer(5), new Boolean(false) },
            { "John", "Doe", "Rowing", new Integer(3), new Boolean(true) },
            { "Sue", "Black", "Knitting", new Integer(2), new Boolean(false) },
            { "Jane", "White", "Speed reading", new Integer(20), new Boolean(true) },
            { "Joe", "Brown", "Pool", new Integer(10), new Boolean(false) } };

    final JTable table = new JTable(data, columnNames);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);// w  w w .  j a v  a2 s . c o  m

    if (DEBUG) {
        table.addMouseListener(new MouseAdapter() {
            public void mouseClicked(MouseEvent e) {
                printDebugData(table);
            }
        });
    }

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);
}

From source file:components.TableSortDemo.java

public TableSortDemo() {
    super(new GridLayout(1, 0));

    JTable table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);//ww w  .  ja  va 2s  .c  o  m
    table.setAutoCreateRowSorter(true);

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);
}

From source file:Main.java

public Main() {
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    JPanel buttonPanel = new JPanel();
    okButton = new JButton("Ok");
    buttonPanel.add(okButton);/*from  ww  w.  j av  a  2s . c o  m*/
    add(buttonPanel, BorderLayout.SOUTH);

    mainPanel = new JPanel();
    mainPanel.setLayout(new GridLayout(0, 3));
    add(mainPanel, BorderLayout.CENTER);

    JSpinner defaultSpinner = new JSpinner();
    addRow("Default", defaultSpinner);

    JSpinner boundedSpinner = new JSpinner(new SpinnerNumberModel(5, 0, 10, 0.5));
    addRow("Bounded", boundedSpinner);

    String[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();

    JSpinner listSpinner = new JSpinner(new SpinnerListModel(fonts));
    addRow("List", listSpinner);

    JSpinner reverseListSpinner = new JSpinner(new SpinnerListModel(fonts) {
        public Object getNextValue() {
            return super.getPreviousValue();
        }

        public Object getPreviousValue() {
            return super.getNextValue();
        }
    });
    addRow("Reverse List", reverseListSpinner);

    JSpinner dateSpinner = new JSpinner(new SpinnerDateModel());
    addRow("Date", dateSpinner);

    JSpinner betterDateSpinner = new JSpinner(new SpinnerDateModel());
    String pattern = ((SimpleDateFormat) DateFormat.getDateInstance()).toPattern();
    betterDateSpinner.setEditor(new JSpinner.DateEditor(betterDateSpinner, pattern));
    addRow("Better Date", betterDateSpinner);

    JSpinner timeSpinner = new JSpinner(new SpinnerDateModel());
    pattern = ((SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.SHORT)).toPattern();
    timeSpinner.setEditor(new JSpinner.DateEditor(timeSpinner, pattern));
    addRow("Time", timeSpinner);

    JSpinner permSpinner = new JSpinner(new PermutationSpinnerModel("meat"));
    addRow("Word permutations", permSpinner);
}

From source file:com.bsoft.baseframe.baseframe_utils.beanUtils.Classgenerator.java

/**
 * ???/*from w  ww  . ja v  a2s. c  o  m*/
 */
public Classgenerator() {
    setTitle("?");
    setSize(WIDTH, HEIGHT);
    setLocationRelativeTo(null);

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

    JPanel _beanPanel = new JPanel();
    _beanPanel.setBorder(BorderFactory.createTitledBorder("?"));

    JPanel _otherPanel = new JPanel();
    _otherPanel.setBorder(BorderFactory.createTitledBorder("?"));

    JLabel _tbLabel = new JLabel("??*");
    _tb = new JTextField(25);
    _beanPanel.add(_tbLabel);
    _beanPanel.add(_tb);

    JLabel _stbbLabel = new JLabel("??*");
    _stb = new JTextField(25);
    _beanPanel.add(_stbbLabel);
    _beanPanel.add(_stb);

    JLabel _ibatisLabel = new JLabel("IBTS*");
    _ibatis = new JTextField(25);
    _beanPanel.add(_ibatisLabel);
    _beanPanel.add(_ibatis);

    JLabel _svLabel = new JLabel("SERVICE");
    _sv = new JTextField(23);
    _otherPanel.add(_svLabel);
    _otherPanel.add(_sv);

    //      JLabel _sviLabel = new JLabel("??*");
    //      _zwmc = new JTextField("?",25);
    //      _zwmc.setEditable(false);
    //      _otherPanel.add(_sviLabel);
    //      _otherPanel.add(_zwmc);

    JLabel _detail = new JLabel("(?ServiceService??,");
    JLabel _detail2 = new JLabel("??Service???.impl)");
    _detail.setFont(new Font("", Font.ITALIC, 12));
    _detail2.setFont(new Font("", Font.ITALIC, 12));
    _otherPanel.add(_detail);
    _otherPanel.add(_detail2);
    panel.add(_beanPanel);
    panel.add(_otherPanel);

    add(panel, BorderLayout.CENTER);

    JPanel btnPanel = new JPanel();
    JButton _saveBtn = new JButton("?");

    _saveBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            int msg_code = clickSaveBtn(e);
            showMsg(msg_code);
        }
    });

    JButton _restBtn = new JButton("?");

    //?
    _restBtn.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            _tb.setText(null);
            _stb.setText(null);
            _ibatis.setText(null);
            _sv.setText(null);
            //            _svi.setText(null);
        }
    });
    btnPanel.add(_saveBtn);
    btnPanel.add(_restBtn);
    add(btnPanel, BorderLayout.SOUTH);
}

From source file:DropDemo.java

public DropDemo() {
    super(new GridLayout(2, 1));
    add(createArea());
    add(createList());
}

From source file:st.jigasoft.dbutil.view.DUReport.java

/**
 * Creates new form PReportGeral/*from  w w  w  .java2  s  .c o  m*/
 */
public DUReport() {
    initComponents();
    this.panelGraficoTop.setLayout(new GridLayout(1, 1));
    this.panelGraficoButton.setLayout(new GridLayout(1, 1));

    this.choseGroupData.addOption("DAY", "Diario");
    this.choseGroupData.addOption("MONTH", "Mensal");
    this.choseGroupData.addOption("YEAR", "Anual");

    this.choseExport.addOption("PDF", "PDF");
    this.choseExport.addOption("XLS", "XLS");
    this.choseExport.addOption("XML", "XML");
    this.choseExport.addOption("CSV", "CSV");

    this.choseGrafico.addOption("BARA", "Bara");
    this.choseGrafico.addOption("CIRCULO", "Circulo");

    choseGroupData.getIten("DAY").setValue("FORMAT", "dd-MM-yyyy");
    choseGroupData.getIten("MONTH").setValue("FORMAT", "MMMMM yyyy");
    choseGroupData.getIten("YEAR").setValue("FORMAT", "YYYY");

    choseGroupData.getIten("DAY").setObject(DUReport.GROUP, ModoAgrupamento.DAILY);
    choseGroupData.getIten("MONTH").setObject(DUReport.GROUP, ModoAgrupamento.MONTHLY);
    choseGroupData.getIten("YEAR").setObject(DUReport.GROUP, ModoAgrupamento.YEARLY);

    this.choseGroupData.setOnValueChange((oldVall, newVall) -> {
        this.onChangeGroupDate((oldVall != null) ? (ModoAgrupamento) oldVall.getObject("GROUP") : null,
                (newVall != null) ? (ModoAgrupamento) newVall.getObject("GROUP") : null);
    });

    this.choseGroupData.setOnItemStateChange((item, oldState, newState) -> {
        if (newState)
            this.setFormatDate(item);
    });

    this.choseGrafico.setOnValueChange((oldVall, newVall) -> {
        this.onChangeGrafico((oldVall != null) ? oldVall.getKey() : null,
                (newVall != null) ? newVall.getKey() : null);
    });

    this.choseTopOptions.setOnValueChange((oldVall, newVall) -> {
        this.onChangeModoDate(oldVall, newVall);
    });

    this.dividerTableGraficosParcente = 75;
    this.dividerTableGraficos = 50;
    this.dividerTableFutter = 90;

    this.setFormatDate(choseGroupData.getIten("DAY"));
    this.verItem(false);
    this.verTipoGrafico(false);
    this.verTopOptions(false);
    this.verFutter(false);
    this.verGraficos(false);
    this.verDateEnd(true);
    this.verDateStart(true);
    this.verGrupoDate(true);
    this.onCreate();
}

From source file:components.TableDemo.java

public TableDemo() {
    super(new GridLayout(1, 0));

    JTable table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);//from   w ww . j  av a  2s  .  c  o  m

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);
}