⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jxchooserdemopanel.java

📁 java实现浏览器等本地桌面的功能
💻 JAVA
字号:
/* * JXChooserDemoPanel.java * * Created on April 21, 2005, 5:07 PM */package org.jdesktop.demo.swingx;import javax.swing.JCheckBox;import javax.swing.table.DefaultTableModel;import javax.swing.table.TableModel;import org.jdesktop.demo.DemoPanel;/** * @author Thomas Bierhance */public class JXChooserDemoPanel extends DemoPanel {        final static String htmlDescription =            "<html><b>JXComboBox Prototypes (Incubator)</b><br/>" +            "This demo shows some early prototypes of an extended combo box " +            "from the incubator (realized by Thomas Bierhance and Ricardo " +            "Lopes).<br/> " +            "The approach allows to replace the JList inside of the combo" +            "box' pop-up menu with a custom component. Here it is replaced " +            "by a JTable and a two custom control panels." +            "</html>";        /** Creates new form JXChooserDemoPanel */    public JXChooserDemoPanel() {        setName("JXComboBox (prototype)");        initComponents();        setTableModel();    }        private void setTableModel() {        String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};        Object[][] data = {            {"Mary", "Campione", "Snowboarding", new Integer(5), Boolean.FALSE},            {"Alison", "Huml", "Rowing", new Integer(3), Boolean.TRUE},            {"Kathy", "Walrath", "Knitting", new Integer(2), Boolean.FALSE},            {"Sharon", "Zakhour", "Speed reading", new Integer(20), Boolean.TRUE},            {"Philip", "Milne", "Pool", new Integer(10), Boolean.FALSE},            {"Mike", "Summers", "Tennis", new Integer(1), Boolean.TRUE},            {"Merissa", "Atwood", "Golf", new Integer(14), Boolean.FALSE},        };        // MyTableModel only overrides getColumnClass to demonstrate JCheckBox rendering        TableModel tableModel = new MyTableModel(data, columnNames);        tableComboBox.setModel(tableModel,1);    }        // JTable would not render Boolean values using JCheckBox with the DefaultTableModel    static class MyTableModel extends DefaultTableModel {        public MyTableModel(Object[][] data, Object[] columnNames) {            super(data,columnNames);        }        public Class getColumnClass(int columnIndex) {            return getValueAt(0, columnIndex).getClass();        }        public boolean isCellEditable(int row, int columnIndex) {            return false;        }    }        public String getHtmlDescription() {        return htmlDescription;    }        public String getName() {        return "Extended Comboboxes";    }            /** This method is called from within the constructor to     * initialize the form.     * WARNING: Do NOT modify this code. The content of this method is     * always regenerated by the Form Editor.     */    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents    private void initComponents() {        java.awt.GridBagConstraints gridBagConstraints;        tableLabel = new javax.swing.JLabel();        try {            tableComboBox = new org.jdesktop.jdnc.incubator.jxcombobox.JTableComboBox();        } catch (org.jdesktop.jdnc.incubator.jxcombobox.IncompatibleLookAndFeelException e1) {            e1.printStackTrace();        }        headerCheckBox = new javax.swing.JCheckBox();        gridCheckBox = new javax.swing.JCheckBox();        separator = new javax.swing.JSeparator();        colorLabel = new javax.swing.JLabel();        try {            colorComboBox = new org.jdesktop.jdnc.incubator.jxcombobox.colorcombo.ColorComboBox();        } catch (org.jdesktop.jdnc.incubator.jxcombobox.IncompatibleLookAndFeelException e1) {            e1.printStackTrace();        }        smilieLabel = new javax.swing.JLabel();        try {            smilieComboBox = new org.jdesktop.jdnc.incubator.jxcombobox.smiliescombo.SmilieComboBox();        } catch (org.jdesktop.jdnc.incubator.jxcombobox.IncompatibleLookAndFeelException e1) {            e1.printStackTrace();        }        setLayout(new java.awt.GridBagLayout());        tableLabel.setText("TableComboBox");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        add(tableLabel, gridBagConstraints);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        add(tableComboBox, gridBagConstraints);        headerCheckBox.setSelected(true);        headerCheckBox.setText("show headers");        headerCheckBox.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                headerCheckBoxActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        add(headerCheckBox, gridBagConstraints);        gridCheckBox.setSelected(true);        gridCheckBox.setText("show grid");        gridCheckBox.addActionListener(new java.awt.event.ActionListener() {            public void actionPerformed(java.awt.event.ActionEvent evt) {                gridCheckBoxActionPerformed(evt);            }        });        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridx = 1;        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        add(gridCheckBox, gridBagConstraints);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 0);        add(separator, gridBagConstraints);        colorLabel.setText("ColorComboBox");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        add(colorLabel, gridBagConstraints);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        add(colorComboBox, gridBagConstraints);        smilieLabel.setText("SmilieComboBox");        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        add(smilieLabel, gridBagConstraints);        gridBagConstraints = new java.awt.GridBagConstraints();        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;        gridBagConstraints.insets = new java.awt.Insets(3, 3, 3, 3);        add(smilieComboBox, gridBagConstraints);    }    // </editor-fold>//GEN-END:initComponents        private void gridCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gridCheckBoxActionPerformed        tableComboBox.setShowTableGrid(gridCheckBox.isSelected());    }//GEN-LAST:event_gridCheckBoxActionPerformed        private void headerCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_headerCheckBoxActionPerformed        tableComboBox.setShowTableHeaders(headerCheckBox.isSelected());    }//GEN-LAST:event_headerCheckBoxActionPerformed            // Variables declaration - do not modify//GEN-BEGIN:variables    private org.jdesktop.jdnc.incubator.jxcombobox.colorcombo.ColorComboBox colorComboBox;    private javax.swing.JLabel colorLabel;    private javax.swing.JCheckBox gridCheckBox;    private javax.swing.JCheckBox headerCheckBox;    private javax.swing.JSeparator separator;    private org.jdesktop.jdnc.incubator.jxcombobox.smiliescombo.SmilieComboBox smilieComboBox;    private javax.swing.JLabel smilieLabel;    private org.jdesktop.jdnc.incubator.jxcombobox.JTableComboBox tableComboBox;    private javax.swing.JLabel tableLabel;    // End of variables declaration//GEN-END:variables    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -