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

📄 jxtabledemopanel.java

📁 java实现浏览器等本地桌面的功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        highlighterMap.put("notePadBackground", Highlighter.notePadBackground);        highlighterMap.put("alternate.beige", AlternateRowHighlighter.beige);        highlighterMap.put("altenate.classicLinePrinter", AlternateRowHighlighter.classicLinePrinter);        highlighterMap.put("altenate.floralWhite", AlternateRowHighlighter.floralWhite);        highlighterMap.put("altenate.linePrinter", AlternateRowHighlighter.linePrinter);        highlighterMap.put("altenate.quickSilver", AlternateRowHighlighter.quickSilver);                highlighterKeys = new ArrayList();        highlighterKeys.addAll(highlighterMap.keySet());        Collections.sort(highlighterKeys);        highlighterKeys.add(0, null);                comparatorMap = new HashMap();        comparatorMap.put("Point/Dimension", new XYComparator());        comparatorKeys = new ArrayList();        comparatorKeys.addAll(comparatorMap.keySet());        comparatorKeys.add("Lexical (default)");        Collections.sort(comparatorKeys);        currentComparatorKey = (String) comparatorKeys.get(0);            }    private void configureComponents() {        // configure table        configureCommonTableProperties(table);        table.getTableHeader().setToolTipText("<html>" +                "<b> Sorting: </b> <p> " +                "Click to toggle sorting <br>" +                "Ctrl-Shift-Click to unsort <p>" +                "<b> Auto-Resizing: </b> <p>" +                "Double-Click in resize region" +                "</html>");        // configure treeTable        configureCommonTableProperties(treeTable);        treeTable.getTableHeader().setToolTipText("<html>" +                "<b> Sorting: </b> <p> " +                "Not supported <p>" +                "<b> Auto-Resizing: </b> <p>" +                "Double-Click in resize region" +                "</html>");        treeTable.setRootVisible(true);        treeTable.setShowsRootHandles(false);        // share highlighter pipeline        table.setHighlighters(new HighlighterPipeline());        treeTable.setHighlighters(table.getHighlighters());    }    private void configureCommonTableProperties(JXTable table) {        table.setColumnControlVisible(true);  //      table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);        table.setRolloverEnabled(true);//        table.packTable(0);        TableCellRenderer renderer = new DefaultTableCellRenderer() {            public void setValue(Object value) {                if (value instanceof Point) {                    Point p = (Point) value;                    value = createString(p.x, p.y);                } else if (value instanceof Dimension) {                    Dimension dim = (Dimension) value;                    value = createString(dim.width, dim.height);                }                super.setValue(value);            }            private Object createString(int width, int height) {                return "(" + width + ", " + height + ")";            }        };        table.setDefaultRenderer(Point.class, renderer);        table.setDefaultRenderer(Dimension.class, renderer);            }//------------------ create models        private void initDemoModels() {        treeTableModel = new ComponentTreeTableModel(null);        tableModel = new ComponentTableModel();        tableModel.updateComponentList(treeTableModel);    }    public void addNotify() {        super.addNotify();        // a quick hack to get a static snapshot of the        // container hierarchy        treeTableModel.setRoot(SwingUtilities.windowForComponent(this));        treeTable.expandAll();        tableModel.updateComponentList(treeTableModel);    }    //-------------------- init UI        /** This method is called from within the constructor to     * initialize the form.     */    private void initComponents() {        treeTable = new JXTreeTable();        table = new JXTable();        highlighterCombo = new JComboBox();        sorterGroup = new JXRadioGroup();            }        private void build() {//        COLUMN SPECS://            f:d:g, l:4dluX:n, f:d:g//            ROW SPECS:   //            c:d:n, t:3dluY:n, f:d:g, t:4dluY:n, c:d:n////            COLUMN GROUPS:  {}//            ROW GROUPS:     {}////            COMPONENT CONSTRAINTS//            ( 1,  1,  1,  1, "d=f, d=c"); javax.swing.JLabel      "table"; name=tableLabel//            ( 3,  1,  1,  1, "d=f, d=c"); javax.swing.JLabel      "treeTable"; name=treeTableLabel//            ( 1,  3,  1,  1, "d=f, d=f"); javax.swing.JScrollPane; name=table//            ( 3,  3,  1,  1, "d=f, d=f"); javax.swing.JScrollPane; name=treeTable//            ( 1,  5,  3,  1, "d=f, d=c"); javax.swing.JPanel; name=tablecontrol//                FormLayout formLayout = new FormLayout(                "f:p:g, l:4dlu:n, f:p:g", // columns                "c:d:n, t:3dlu:n, f:d:g, t:4dlu:n, c:d:n");  // rows        PanelBuilder builder = new PanelBuilder(this, formLayout);        builder.setDefaultDialogBorder();        CellConstraints cl = new CellConstraints();        CellConstraints cc = new CellConstraints();                builder.addLabel("JXTable:", cl.xywh(1, 1, 1, 1), new JScrollPane(table), cc.xywh(1,  3,  1,  1) );        builder.addLabel("JXTreeTable:", cl.xywh(3, 1, 1, 1), new JScrollPane(treeTable), cc.xywh(3,  3,  1,  1));        builder.add(buildControl(), cc.xywh(1, 5, 3, 1));    }       private JComponent buildControl() {//        COLUMN SPECS://            r:p:n, l:3dluX:n, f:max(p;50dluX):n, f:0px:g//            ROW SPECS:   //            c:d:n, t:4dluY:n, c:d:n////            COLUMN GROUPS:  {}//            ROW GROUPS:     {}////            COMPONENT CONSTRAINTS//            ( 1,  1,  1,  1, "d=f, d=c"); javax.swing.JLabel      "highlighter"; name=highlighterLabel//            ( 3,  1,  1,  1, "d=f, d=c"); javax.swing.JComboBox; name=highlighter//            ( 1,  3,  1,  1, "d=f, d=c"); javax.swing.JLabel      "sorterGroup"; name=sorterGroupLabel//            ( 3,  3,  2,  1, "d=f, d=c"); de.kleopatra.view.JTitledPlaceHolder; name=sorterGroup//        FormLayout formLayout = new FormLayout(                "r:p:n, l:3dlu:n, f:max(p;50dlu):n, f:0px:g", // columns                "c:d:n, t:4dlu:n, c:d:n"); // rows        JXPanel control = new JXPanel();        PanelBuilder builder = new PanelBuilder(control, formLayout);        builder.setBorder(Borders.BUTTON_BAR_GAP_BORDER);        CellConstraints cl = new CellConstraints();        CellConstraints cc = new CellConstraints();        highlighterLabel = builder.addLabel("", cl.xywh(1, 1, 1, 1), highlighterCombo,                 cc.xywh(3, 1, 1, 1));        sorterGroupLabel = builder.addLabel("", cl.xywh(1, 3, 1, 1), sorterGroup,                 cc.xywh(3, 3, 2, 1));        return control;    }    // --------------- super overrides    public String getHtmlDescription() {        return "<html>" +                "With the SwingX <strong>JXTable</strong> and <strong>JXTreeTable</strong> " +                "controls your users can <b>select displayed columns</b> at runtime, " +                "<b>rearrange columns</b> via drag and drop, <b>highlight rows</b> with " +                "pluggable background highlighters, <b>sort their data</b> via clickable headers " +                "and more.<br><br>" +                "In this demo, try rearranging columns by dragging the the column " +                "headers with your mouse. Select the columns shown in the table by " +                "clicking on the column control in the top right corner of the tables. " +                "Change background color highlighting using the Highlighter combobox. " +                "Sort rows by clicking on the column headers, and change the " +                "sort characteristics using the Sorter radio buttons. Note the you can " +                "also re-size table columns automatically from the column control, " +                "as well as apply horizontal scrolling. " +               // "<a href=\"" + getHowToURLString() + "\">Read More</a>" +                "</html>";    }    public String getHowToURLString() {        return "resources/howto/JXTableHowTo.html";    }        public String getInformationTitle() {         return "JXTable/JXTreeTable";    }        public String getName() {        return "Extended Tables and Trees";    }}

⌨️ 快捷键说明

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