Package org.onemind.swingweb.component.layout

Examples of org.onemind.swingweb.component.layout.TableLayout


    }

    public Container getDemoArea()
    {
        JPanel pnl = new JPanel();
        TableLayout layout = new TableLayout(pnl);
        pnl.setLayout(layout);
        layout.getConstraint().fill = GridBagConstraints.BOTH;
        layout.getConstraint().insets = new Insets(5, 5, 5, 5);
        Icon icon = new ImageIcon(getClass().getResource("/org/onemind/swingweb/widgetdemo/icecream.jpg"));

        /** labels **/
        //just a label
        JLabel lbl = new JLabel("This is a yellow JLabel");
        lbl.setForeground(Color.YELLOW);
        layout.addNextRow(lbl);
       
        //label with colors
        lbl = new JLabel("<html>This is a <font color=\"blue\"><i>html</i></font> JLabel</html>");
        layout.addNextRow(lbl);
       
        //label with icon
        lbl = new JLabel("JLabel with icon");
        lbl.setIcon(icon);
        layout.addNextRow(lbl);

        //disabled label
        lbl = new JLabel("Disabled JLabel");
        layout.addNextRow(lbl);
       
        /** buttons **/
        //button
        JButton btn = new JButton("Button1");
        btn.setBackground(Color.YELLOW);
        layout.addNextRow(btn);
        layout.addNextCell(new JLabel("Just a JButton with yellow background"));
       
        //button with listener
        btn = new JButton("Button2");
        btn.addActionListener(this);
        layout.addNextRow(btn);
        layout.addNextCell(new JLabel("JButton with listener. Push will submit"));
       
        //button with no border
        btn = new JButton("Button3");
        btn.setBorder(null);
        layout.addNextRow(btn);
        layout.addNextCell(new JLabel("JButton with no border"));
       
        //button with icon
        btn = new JButton("Button4");
        btn.setIcon(icon);
        layout.addNextRow(btn);
        layout.addNextCell(new JLabel("JButton with icon"));
       
        /** checkboxes **/
        //button
        JCheckBox checkbox = new JCheckBox("Checkbox1");
        checkbox.setBackground(Color.YELLOW);
        layout.addNextRow(checkbox);
        layout.addNextCell(new JLabel("Just a JCheckbox with yellow background"));
       
        //button with listener
        checkbox = new JCheckBox("Checkbox2");
        checkbox.addChangeListener(this);
        layout.addNextRow(checkbox);
        layout.addNextCell(new JLabel("JCheckBox with change listener. Push will submit"));
       
        //button in a group
        JPanel subPanel = new JPanel();
        subPanel.setLayout(new GridLayout(1, 2));
        ButtonGroup group = new ButtonGroup();
        checkbox = new JCheckBox("Checkbox3");
        group.add(checkbox);
        subPanel.add(checkbox);
        checkbox = new JCheckBox("Checkbox4");
        group.add(checkbox);
        subPanel.add(checkbox);
        layout.addNextRow(subPanel);
        layout.addNextCell(new JLabel("JCheckBox in button group. Push always submit"));
       
        /** radio buttons **/
//      button in a group
        subPanel = new JPanel();
        subPanel.setLayout(new GridLayout(1, 2));
        group = new ButtonGroup();
        JRadioButton rbtn = new JRadioButton("RadioButton1");
        group.add(rbtn);
        subPanel.add(rbtn);
        rbtn = new JRadioButton("RadioButton2");
        group.add(rbtn);
        subPanel.add(rbtn);
        layout.addNextRow(subPanel);       
        layout.addNextCell(new JLabel("RadioButtons in button group"));
       
        //button in a group with listener
        subPanel = new JPanel();
        subPanel.setLayout(new GridLayout(1, 2));
        group = new ButtonGroup();
        rbtn = new JRadioButton("RadioButton1");
        group.add(rbtn);
        rbtn.addChangeListener(this);
        subPanel.add(rbtn);
        rbtn = new JRadioButton("RadioButton2");
        group.add(rbtn);
        rbtn.addActionListener(this);
        subPanel.add(rbtn);
        layout.addNextRow(subPanel);       
        layout.addNextCell(new JLabel("RadioButtons with change/action listener in button group. Push will submit"));
       
        /** text demo **/
        //Text field
        JTextField fld = new JTextField();
        fld.setColumns(10);
        fld.setText("Test");
        layout.addNextRow(fld);
        layout.addNextCell(new JLabel("Just a text field"));
       
        //Text field with TextListner
        fld = new JTextField();
        fld.setColumns(10);
        fld.setText("Test");
        layout.addNextRow(fld);
        layout.addNextCell(new JLabel("Texd field with text listener"));
       
        //Password field
        fld = new JPasswordField();
        fld.setColumns(10);
        layout.addNextRow(fld);
        layout.addNextCell(new JLabel("A password field"));
       
        //Text area
        JTextArea tfld = new JTextArea();
        tfld.setColumns(10);
        tfld.setRows(4);
        layout.addNextRow(tfld);
        layout.addNextCell(new JLabel("A text area"));
        return pnl;
    }
View Full Code Here


    }

    public Container getDemoArea()
    {
        JPanel pnl = new JPanel();
        TableLayout layout = new TableLayout(pnl);
        layout.getConstraint().insets = new Insets(5, 5, 5, 5);
        pnl.setLayout(layout);
       
        //Simple table with table listener
        JTable t = getExampleTable();
        layout.addNextRow(new JLabel("Simple table with TableListener (will submit on change)"));
        layout.addNextRow(t);
       
        //Simple table without table listener
        t = getExampleTable();
        layout.addNextRow(new JLabel("Simple table without TableListener"));
        layout.addNextRow(t);
       
        //Simple table without table listener, with validation renderer
        t = getExampleTable();
        layout.addNextRow(new JLabel("Simple table without TableListener, with int field formater"));
        //t.setCellEditor(anEditor);
        layout.addNextRow(t);
       
       
        addListeners(t);
        t = getExampleTable();
        t.setEnabled(false);
        layout.addNextRow(new JLabel("Disabled table"));
        layout.addNextRow(t);
        return pnl;
    }
View Full Code Here

TOP

Related Classes of org.onemind.swingweb.component.layout.TableLayout

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.