當前位置: 首頁>>代碼示例>>Java>>正文


Java JXTable類代碼示例

本文整理匯總了Java中org.jdesktop.swingx.JXTable的典型用法代碼示例。如果您正苦於以下問題:Java JXTable類的具體用法?Java JXTable怎麽用?Java JXTable使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


JXTable類屬於org.jdesktop.swingx包,在下文中一共展示了JXTable類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testIcon

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
/**
     * test if icon handling is the same for core default and
     * swingx.
     *
     */
    @Test
    public void testIcon() {
        TableModel model = createTableModelWithDefaultTypes();
        int iconColumn = 4;
        // sanity
        assertTrue(Icon.class.isAssignableFrom(model.getColumnClass(iconColumn)));
        Icon icon = (Icon) model.getValueAt(0, iconColumn);
        // default uses a different class for icon rendering
        DefaultTableCellRenderer coreIconRenderer = (DefaultTableCellRenderer) table.getDefaultRenderer(Icon.class);
        // core default can't cope with null component - can't really compare behaviour
        coreIconRenderer.getTableCellRendererComponent(table, icon, false, false, -1, -1);
        assertEquals(icon, coreIconRenderer.getIcon());
        assertEquals("", coreIconRenderer.getText());
        JXTable xTable = new JXTable();
        TableCellRenderer xIconRenderer = xTable.getDefaultRenderer(Icon.class);
        JLabel label = (JLabel) xIconRenderer.getTableCellRendererComponent(null, icon, false, false, -1, -1);
        assertEquals(icon, label.getIcon());
        assertEquals("", label.getText());
        // wrong assumption after fix of #591-swingx - default icon renderer
        // no longer tries to be clever
//        label = (JLabel) xIconRenderer.getTableCellRendererComponent(null, "dummy", false, false, -1, -1);
//        assertNull(label.getIcon());
//        assertEquals("dummy", label.getText());        
    }
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:30,代碼來源:TableRendererTest.java

示例2: LlenarTabla

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
public void LlenarTabla(JXTable tabla) throws ClassNotFoundException{
    
    DefaultTableModel modeloT = new DefaultTableModel();
    tabla.setModel(modeloT);
    
    modeloT.addColumn("Usuario");
    modeloT.addColumn("Fecha");
    modeloT.addColumn("Descripcion");
    
    Object[] columna = new Object[3];
    
    int numeroRegistros= modelo.listar().size();
    for ( int i=0; i<numeroRegistros;i++){
            columna[0]=modelo.listar().get(i).getId_usuario();
            columna[1]=modelo.listar().get(i).getFecha();
            columna[2]=modelo.listar().get(i).getDescripcion();
            modeloT.addRow(columna);
    }
    
}
 
開發者ID:gonzapala,項目名稱:CPI,代碼行數:21,代碼來源:Listar_Registros.java

示例3: LlenarTabla

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
public void LlenarTabla(JXTable tabla) throws ClassNotFoundException{
    
    DefaultTableModel modeloT = new DefaultTableModel();
    tabla.setModel(modeloT);
    
    modeloT.addColumn("Nombre");
    modeloT.addColumn("Usuario");
    modeloT.addColumn("Tipo");
    
    Object[] columna = new Object[3];
    
    int numeroRegistros= modelo.listar().size();
    //        System.out.println(numeroRegistros);
    for ( int i=0; i<numeroRegistros;i++){
            columna[0]=modelo.listar().get(i).getNombre();
            columna[1]=modelo.listar().get(i).getContraseña();
            columna[2]=modelo.listar().get(i).getId_rol();

            modeloT.addRow(columna);
    }
    
}
 
開發者ID:gonzapala,項目名稱:CPI,代碼行數:23,代碼來源:Gestionar_usuarios.java

示例4: LlenarTabla

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
public void LlenarTabla(JXTable tabla_socios){
    DefaultTableModel modeloT = new DefaultTableModel();
    tabla_socios.setModel(modeloT);
    
    modeloT.addColumn("Legajo");
    modeloT.addColumn("Apellido");
    modeloT.addColumn("Nombre");
    modeloT.addColumn("DNI");
    modeloT.addColumn("Socio");
    
    Object[] columna = new Object[5];
    
    int numeroRegistros= modeloCRUD.listarSocios().size();
    for ( int i=0; i<numeroRegistros;i++){
        columna[0]=modeloCRUD.listarSocios().get(i).getLegajo_socio();
        columna[1]=modeloCRUD.listarSocios().get(i).getApellido();
        columna[2]=modeloCRUD.listarSocios().get(i).getNombre();
        columna[3]=modeloCRUD.listarSocios().get(i).getDni();
        columna[4]=modeloCRUD.listarSocios().get(i).getEstado();
        modeloT.addRow(columna);
    
    }
    
}
 
開發者ID:gonzapala,項目名稱:CPI,代碼行數:25,代碼來源:SocioController.java

示例5: LlenarTabla

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
public void LlenarTabla(JXTable tabla_socios){
    DefaultTableModel modeloT = new DefaultTableModel();
    tabla_socios.setModel(modeloT);
    
    modeloT.addColumn("Legajo");
    modeloT.addColumn("Apellido");
    modeloT.addColumn("Nombre");
    modeloT.addColumn("DNI");
    modeloT.addColumn("Socio");
    
    Object[] columna = new Object[5];
    
    int numeroRegistros= socio.listarSocios().size();
    for ( int i=0; i<numeroRegistros;i++){
        columna[0]=socio.listarSocios().get(i).getLegajo_socio();
        columna[1]=socio.listarSocios().get(i).getApellido();
        columna[2]=socio.listarSocios().get(i).getNombre();
        columna[3]=socio.listarSocios().get(i).getDni();
        columna[4]=socio.listarSocios().get(i).getEstado();
        modeloT.addRow(columna);
    
    }
    
}
 
開發者ID:gonzapala,項目名稱:CPI,代碼行數:25,代碼來源:PagosController.java

示例6: createCenterPane

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
private JComponent createCenterPane() {
    searchResultsTable = new JXTable( new SearchResultsTableModel() );
    searchResultsTable.setFillsViewportHeight(true);        
    JScrollPane p1 = new JScrollPane( searchResultsTable );
    
    searchProgressBar = new JProgressBar(0, 100);
    searchProgressBar.setStringPainted(true);        
    JPanel p2 = new JPanel();
    p2.setLayout( new BoxLayout(p2, BoxLayout.PAGE_AXIS) );
    p2.add( Box.createGlue() );
    p2.add( new JLabel("Searching...") );
    p2.add( Box.createRigidArea( new Dimension(0,10) ) );        
    p2.add( searchProgressBar );
    p2.add( Box.createGlue() );
    p2.setBorder( BorderFactory.createEmptyBorder(0, 100, 0, 100) );
    
    centerPane = new JPanel( new CardLayout() );
    centerPane.add( p1, "1" );
    centerPane.add( p2, "2" );
    
    return centerPane;
}
 
開發者ID:gholdys,項目名稱:nbpio,代碼行數:23,代碼來源:LibraryManagerPane.java

示例7: onNextClick

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
private void onNextClick() {
    if (!(datasource instanceof CollectionDatasource.SupportsPaging)) {
        return;
    }

    CollectionDatasource.SupportsPaging ds = (CollectionDatasource.SupportsPaging) datasource;
    int firstResult = ds.getFirstResult();
    ds.setFirstResult(ds.getFirstResult() + ds.getMaxResults());
    refreshDatasource(ds);

    if (state == State.LAST && size == 0) {
        ds.setFirstResult(firstResult);
        int maxResults = ds.getMaxResults();
        ds.setMaxResults(maxResults + 1);
        refreshDatasource(ds);
        ds.setMaxResults(maxResults);
    }
    if (owner instanceof DesktopAbstractTable) {
        JXTable table = (JXTable) ((DesktopAbstractTable) owner).getComponent();
        table.scrollRowToVisible(0);
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:23,代碼來源:DesktopRowsCount.java

示例8: onLastClick

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
protected void onLastClick() {
    if (!(datasource instanceof CollectionDatasource.SupportsPaging)) {
        return;
    }

    CollectionDatasource.SupportsPaging ds = (CollectionDatasource.SupportsPaging) datasource;
    int count = ((CollectionDatasource.SupportsPaging) datasource).getCount();
    int itemsToDisplay = count % ds.getMaxResults();
    if (itemsToDisplay == 0) itemsToDisplay = ds.getMaxResults();

    ds.setFirstResult(count - itemsToDisplay);
    refreshDatasource(ds);

    if (owner instanceof DesktopAbstractTable) {
        JXTable table = (JXTable) ((DesktopAbstractTable) owner).getComponent();
        table.scrollRowToVisible(0);
    }
}
 
開發者ID:cuba-platform,項目名稱:cuba,代碼行數:19,代碼來源:DesktopRowsCount.java

示例9: interactiveEscapeStrict

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
/**
 * Issue #1293-swingx: NumberEditorExt removes Escape binding for all formatted text fields.
 * 
 * Here we assure that the fix for the issue doesn't effect the table edit - must
 * pass-through to allow correct cancel processing (strict number editor).
 */
public void interactiveEscapeStrict() {
    JXTable table = new JXTable(this.table.getModel());
    JXFrame frame = wrapWithScrollingInFrame(table, "strict: escape must cancel edit");
    addStatusMessage(frame, "edit number column, press escape, verify editingCanceled");
    final CellEditorReport report = new CellEditorReport();
    table.getDefaultEditor(Number.class).addCellEditorListener(report);
    Action verify = new AbstractAction("verify cancelled") {
        
        @Override
        public void actionPerformed(ActionEvent e) {
            int cancelledCount = report.getCanceledEventCount();
            report.clear();
            LOG.info("cancelled event count must be > 0, was: " + cancelledCount);
        }
    };
    addAction(frame, verify);
    show(frame);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:25,代碼來源:NumberEditorExtTest.java

示例10: getPreferredScrollableViewportWidth

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
/**
 * Calculates and returns the preferred scrollable viewport 
 * width of the given table. Subclasses are free to override
 * and implement a custom strategy.<p>
 * 
 * This implementation sums the pref widths of the first
 * visibleColumnCount contained visible tableColumns. If
 * the table contains less columns, the standard preferred
 * width per column is added to the result. 
 * 
 * @param table the table containing the columns
 */
public int getPreferredScrollableViewportWidth(JXTable table) {
    int w = 0;
    int count;
    if (table.getVisibleColumnCount() < 0) {
        count = table.getColumnCount();
    } else {
        count = Math.min(table.getColumnCount(), table.getVisibleColumnCount());
    }
    for (int i = 0; i < count; i++) {
        // sum up column's pref size, until maximal the
        // visibleColumnCount
        w += table.getColumn(i).getPreferredWidth();
    }
    if (count < table.getVisibleColumnCount()) {
        w += (table.getVisibleColumnCount() - count) * 75;
    }
    return w;
    
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:32,代碼來源:ColumnFactory.java

示例11: actionPerformed

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
  Optional<JXTable> maybeTable = getOtrosApplication().getSelectPaneJXTable();

  final Optional<LogDataTableModel> maybeTableModel = getOtrosApplication().getSelectedPaneLogDataTableModel();
  maybeTable.ifPresent(jxTable -> maybeTableModel.ifPresent(tableModel -> {
    int[] selectedRows = jxTable.getSelectedRows();
    if (selectedRows.length <= 0) {
      return;
    }

    LogData[] selectedLogData = new LogData[selectedRows.length];
    for (int i = 0; i < selectedRows.length; i++) {
      selectedLogData[i] = tableModel.getLogData(jxTable.convertRowIndexToModel(selectedRows[i]));
    }
    try {
      action(e, filter, selectedLogData);
      filterEnableCheckBox.setSelected(true);
      filter.setEnable(true);
    } catch (Exception e1) {
      LOGGER.error("Error occurred when focusing on events ", e1);
      JOptionPane.showMessageDialog(getOtrosApplication().getApplicationJFrame(), e1.getLocalizedMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
  }));
}
 
開發者ID:otros-systems,項目名稱:otroslogviewer,代碼行數:26,代碼來源:FocusOnThisAbstractAction.java

示例12: interactiveTestColumnControlColumnModel

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
/**
 * Issue ??: Column control on changing column model.
 * 
 */
public void interactiveTestColumnControlColumnModel() {
    final JXTable table = new JXTable(10, 5);
    table.setColumnControlVisible(true);
    Action toggleAction = new AbstractAction("Set ColumnModel") {

        @Override
        public void actionPerformed(ActionEvent e) {
            table.setColumnModel(new DefaultTableColumnModel());
            table.setModel(new AncientSwingTeam());
            setEnabled(false);
        }

    };
    JXFrame frame = wrapWithScrollingInFrame(table,
            "ColumnControl: set columnModel ext -> core default");
    addAction(frame, toggleAction);
    frame.setVisible(true);
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:23,代碼來源:ColumnControlButtonVisualCheck.java

示例13: action

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
@Override
public void action(ActionEvent e, CallHierarchyLogFilter filter, LogData... selectedLogData) throws Exception {
  Optional<JXTable> maybeTable = getOtrosApplication().getSelectPaneJXTable();
  Optional<LogDataTableModel> dataT2ableModel = getOtrosApplication().getSelectedPaneLogDataTableModel();
  maybeTable.ifPresent(jTable -> dataT2ableModel.ifPresent(dataTableModel -> {
    int selected = jTable.getSelectedRow();
    selected = jTable.convertRowIndexToModel(selected);
    ArrayList<Integer> listOfEvents2 = new ArrayList<>();
    HashSet<Integer> listEntryEvents = new HashSet<>();


    try {
      findCallHierarchyEvents(selected, dataTableModel, listEntryEvents, listOfEvents2);
    } catch (NoSuchElementException e1) {
      LOGGER.error("Log file do not have consistent Entry/Return in logs");
      getOtrosApplication().getStatusObserver().updateStatus("Log file does not have consistent Entry/Return in logs", StatusObserver.LEVEL_ERROR);
    }
    filter.setListId(listEntryEvents, listOfEvents2);
    filterEnableCheckBox.setSelected(true);
    filter.setEnable(true);
  }));
}
 
開發者ID:otros-systems,項目名稱:otroslogviewer,代碼行數:23,代碼來源:ShowCallHierarchyAction.java

示例14: interactiveTableColorBasedOnComponentValue

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
/**
 * Example of custom predicate based on the component's value, 
 * (as opposed to on the value of the adapter). 
 * 
 * 
 */
public void interactiveTableColorBasedOnComponentValue() {
    TableModel model = new AncientSwingTeam();
    JXTable table = new JXTable(model);
    table.setForeground(Color.GREEN);
    HighlightPredicate predicate = new HighlightPredicate() {

        @Override
        public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
            if (!(renderer instanceof JLabel)) return false;
            String text = ((JLabel) renderer).getText();
             return text.contains("y");
        }
        
    };
    ColorHighlighter hl = new ColorHighlighter(predicate, null, Color.RED);
    table.addHighlighter(HighlighterFactory.createSimpleStriping(HighlighterFactory.GENERIC_GRAY));
    table.addHighlighter(hl);
    showWithScrollingInFrame(table, 
            "component value-based rendering (label text contains y) ");
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:27,代碼來源:HighlighterClientVisualCheck.java

示例15: interactiveRolloverHighlight

import org.jdesktop.swingx.JXTable; //導入依賴的package包/類
/**
 * Plain RolloverHighlighter. 
 * Issue #513-swingx: no rollover effect for disabled table.
 *
 */
public void interactiveRolloverHighlight() {
    final JXTable table = new JXTable(tableModel);
    ColorHighlighter colorHighlighter = new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.YELLOW, null);
    table.addHighlighter(colorHighlighter);
    Action action = new AbstractAction("toggle table enabled") {

        @Override
        public void actionPerformed(ActionEvent e) {
            table.setEnabled(!table.isEnabled());
            
        }
        
    };
    JXFrame frame = showWithScrollingInFrame(table, "rollover highlight, enabled/disabled table");
    addAction(frame, action);
    frame.pack();
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:23,代碼來源:HighlighterClientVisualCheck.java


注:本文中的org.jdesktop.swingx.JXTable類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。