Package charvax.swing

Examples of charvax.swing.JPanel


    public void keyReleased(KeyEvent e_) {
    }

    private JPanel makeNorthPanel() {
        JPanel northpan = new JPanel();
        northpan.setBorder(new TitledBorder("Select a flavor"));
        northpan.setLayout(new BoxLayout(northpan, BoxLayout.Y_AXIS));

        northpan.add(_strawberry);
        northpan.add(_chocolate);
        northpan.add(_vanilla);
        northpan.add(_pistachio);
        northpan.add(_lime);

        _strawberry.addItemListener(this);
        _strawberry.setActionCommand("Strawberry");
        _chocolate.addItemListener(this);
        _chocolate.setActionCommand("Chocolate");
        _vanilla.addItemListener(this);
        _vanilla.setActionCommand("Vanilla");
        _pistachio.addItemListener(this);
        _pistachio.setActionCommand("Pistachio");
        _lime.addItemListener(this);
        _lime.setActionCommand("Lime");

        JPanel panel = new JPanel();
        panel.add(new JLabel("Selected flavor: "));
        panel.add(_selectedFlavor);
        _selectedFlavor.setEnabled(false);
        panel.setBorder(new EmptyBorder(1, 1, 1, 1));
        northpan.add(panel);

        _buttons.add(_strawberry);
        _strawberry.setSelected(true); // select one button in the group
        _buttons.add(_chocolate);
View Full Code Here


        return northpan;
    }

    private JPanel makeCenterPanel() {
        JPanel centerpan = new JPanel();
        centerpan.setBorder(new TitledBorder("Select one or more toppings"));
        centerpan.add(_nutTopping);
        centerpan.add(_syrupTopping);
        centerpan.add(_candyTopping);
        centerpan.add(_waferTopping);

        return centerpan;
    }
View Full Code Here

    JTableTest(Frame owner_) {
        super(owner_, "JTable in a JScrollPane");
        _insets = new Insets(3, 3, 3, 3);
        Container contentPane = getContentPane();

        JPanel northpan = new JPanel();
        northpan.setBorder(new EmptyBorder(1, 1, 1, 1));
        northpan.add(new JLabel("Press ENTER to select/deselect columns/rows"));
        contentPane.add(northpan, BorderLayout.NORTH);

        contentPane.add(makeCenterPanel(), BorderLayout.CENTER);

        contentPane.add(makeEastPanel(), BorderLayout.EAST);
View Full Code Here

                _table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        }
    }

    private JPanel makeCenterPanel() {
        JPanel centerpan = new JPanel();
        centerpan.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 1));
        String[] headings = { "Name", "Color", "Composition", "Mass", "Radius",
                "Orbit"};
        String[][] data = {
                { "Mars", "Red", "Dust", "1.5e10", "2.7e6", "Elliptical"},
                { "Pluto", "Blue", "Rock", "2.3e11", "2.9e7", "Circular"},
                { "Luna", "Green", "Cheese", "1.3e5", "2.3e12", "Square"},
                { "Venus", "White", "Gas", "4.3e5", "2.3e12",
                        "A funny irregular shape whose name is longer than the table width"},
                { "Jupiter", "Black", "Marshmallow", "4.3e6", "2.3e12",
                        "Zigzag"},
                { "Neptune", "Purple", "Gas", "1.2e6", "2.4e2", "Elliptical"},
                { "Saturn", "Yellow", "Gas", "1.1e7", "1.4e6", "Circular"}};

        /*
         * The following inner class overrides the processKeyEvent() method of
         * JTable, so that we can display the selected rows and columns.
         */
        _table = new JTable(data, headings) {

            /*
             * Gets called when the user presses a key in the JTable.
             */
            public void processKeyEvent(KeyEvent e_) {
                super.processKeyEvent(e_);
                if (e_.getKeyCode() != KeyEvent.VK_ENTER) return;

                int[] rows = getSelectedRows();
                StringBuffer buf = new StringBuffer();
                for (int i = 0; i < rows.length; i++) {
                    buf.append(rows[ i]);
                    buf.append(' ');
                }
                _selectedRows.setText(buf.toString());

                int[] columns = getSelectedColumns();
                buf = new StringBuffer();
                for (int i = 0; i < columns.length; i++) {
                    buf.append(columns[ i]);
                    buf.append(' ');
                }
                _selectedColumns.setText(buf.toString());
            }
        };
        _table.setPreferredScrollableViewportSize(new Dimension(30, 5));
        //_table.setValueAt("Yellow", 5, 2);
        //_table.setValueAt("Red", 7, 4);
        //_table.setValueAt("Magenta", 1, 5);
        JScrollPane scrollPane = new JScrollPane(_table);
        TitledBorder border = new TitledBorder(new LineBorder(Color.cyan));
        border.setTitle("The Heavenly Bodies");
        scrollPane.setViewportBorder(border);
        //  scrollPane.setSize(25, 6);
        centerpan.add(scrollPane);

        return centerpan;
    }
View Full Code Here

        return centerpan;
    }

    private JPanel makeEastPanel() {
        JPanel eastpan = new JPanel();
        eastpan.setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();

        gbc.anchor = GridBagConstraints.WEST;
        gbc.gridwidth = 2;
        eastpan.add(_checkBoxAllowRowSelection, gbc);
        _checkBoxAllowRowSelection.addItemListener(this);
        _checkBoxAllowRowSelection.setSelected(true);

        gbc.gridy = 1;
        eastpan.add(_checkBoxAllowColumnSelection, gbc);
        _checkBoxAllowColumnSelection.addItemListener(this);
        _checkBoxAllowColumnSelection.setSelected(true);

        gbc.gridy = 2;
        eastpan.add(_checkBoxAllowMultipleSelection, gbc);
        _checkBoxAllowMultipleSelection.addItemListener(this);
        _checkBoxAllowMultipleSelection.setSelected(false);

        gbc.gridy = 3;
        gbc.gridwidth = 1;
        eastpan.add(new JLabel(""), gbc);

        gbc.anchor = GridBagConstraints.EAST;
        gbc.gridy = 4;
        eastpan.add(new JLabel("selected columns: "), gbc);

        gbc.gridy = 5;
        eastpan.add(new JLabel("selected rows: "), gbc);

        gbc.gridx = 1;
        gbc.gridy = 4;
        gbc.anchor = GridBagConstraints.WEST;
        _selectedColumns.setEnabled(false);
        eastpan.add(_selectedColumns, gbc);

        gbc.gridy = 5;
        _selectedRows.setEnabled(false);
        eastpan.add(_selectedRows, gbc);

        return eastpan;
    }
View Full Code Here

        contentPane.add(makeNorthPanel(), BorderLayout.NORTH);

        contentPane.add(makeCenterPanel(), BorderLayout.CENTER);

        JPanel southpan = new JPanel();
        JButton okButton = new JButton("OK");
        okButton.addActionListener(this);
        southpan.add(okButton);

        contentPane.add(southpan, BorderLayout.SOUTH);

        pack();
    }
View Full Code Here

    public void keyReleased(KeyEvent e_) {
    }

    private JPanel makeNorthPanel() {
        JPanel northpan = new JPanel();
        northpan.setBorder(new TitledBorder("A set of JCheckBoxes"));
        northpan.setLayout(new GridBagLayout());

        GridBagConstraints gbc = new GridBagConstraints();

        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.gridwidth = 3;
        gbc.insets = new Insets(1, 1, 1, 1);
        JLabel label = new JLabel(
                "Press CURSOR-DOWN to move to the text-field below");
        northpan.add(label, gbc);

        gbc.gridy = 1;
        gbc.gridwidth = 1;
        northpan.add(_checkBox1, gbc);
        _checkBox1.addKeyListener(this);

        gbc.gridx = 1;
        northpan.add(_checkBox2, gbc);
        _checkBox2.addKeyListener(this);

        gbc.gridx = 2;
        northpan.add(_checkBox3, gbc);
        _checkBox3.addKeyListener(this);

        return northpan;
    }
View Full Code Here

        return northpan;
    }

    private JPanel makeCenterPanel() {
        JPanel centerpan = new JPanel();
        centerpan.setBorder(new TitledBorder(
                "A Text Field that converts to uppercase"));
        centerpan.setLayout(new BorderLayout());

        JLabel label1 = new JLabel(
                "The CapsTextField is a subclass of JTextField");
        label1.setBorder(new EmptyBorder(1, 1, 0, 1));
        centerpan.add(label1, BorderLayout.NORTH);

        JLabel label2 = new JLabel(
                "that overrides the processKeyEvent() method");
        label2.setBorder(new EmptyBorder(0, 1, 1, 1));
        centerpan.add(label2, BorderLayout.CENTER);

        JPanel southpan = new JPanel();
        southpan.add(new JLabel("CapsTextField: "));
        _capsField = new CapsTextField(
                "THIS FIELD AUTOMATICALLY CONVERTS TO UPPERCASE");
        southpan.add(_capsField);
        centerpan.add(southpan, BorderLayout.SOUTH);

        return centerpan;
    }
View Full Code Here

        contentPane.add(makeNorthPanel(), BorderLayout.NORTH);

        contentPane.add(makeCenterPanel(), BorderLayout.CENTER);

        JPanel southpan = new JPanel();
        _okButton.addActionListener(this);
        _okButton.addFocusListener(this);
        southpan.add(_okButton);
        contentPane.add(southpan, BorderLayout.SOUTH);

        pack();
    }
View Full Code Here

            _focusLostBy.setText("_okButton");
        }
    }

    private JPanel makeNorthPanel() {
        JPanel northpan = new JPanel();
        northpan.setBorder(new TitledBorder("A floating-point input field"));
        northpan.setLayout(new BorderLayout());

        JLabel label1 = new JLabel("Enter a non-numeric value, and then");
        label1.setBorder(new EmptyBorder(1, 1, 0, 1));
        northpan.add(label1, BorderLayout.NORTH);

        JLabel label2 = new JLabel("try pressing TAB");
        label2.setBorder(new EmptyBorder(0, 1, 1, 1));
        northpan.add(label2, BorderLayout.CENTER);

        northpan.add(_floatField, BorderLayout.SOUTH);
        _floatField.addFocusListener(this);

        return northpan;
    }
View Full Code Here

TOP

Related Classes of charvax.swing.JPanel

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.