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


Java JTable類代碼示例

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


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

示例1: maybeShowPopup

import javax.swing.JTable; //導入依賴的package包/類
private void maybeShowPopup(MouseEvent e) {
            if (e.isPopupTrigger()) {
                JTable source = (JTable)(e.getSource());

                if ( ! source.isEnabled () ) return;

                _inputTablePopupRow = 
                        source.rowAtPoint(new Point (e.getX(), e.getY()));
                _inputTablePopupColumn = 
                        source.columnAtPoint(new Point (e.getX(), e.getY()));
                // Make sure the row where click occurred is selected.
                if (_inputTablePopupRow != -1) {
                    source.setRowSelectionInterval (_inputTablePopupRow,
                                                    _inputTablePopupRow);
                }
//                 if  ( _inputTablePopupColumn != Criteria_COLUMN )
//                 {
//                     // return without showing popup
//                     return;
//                 }

                _inputTablePopup.show(e.getComponent(), e.getX(), e.getY());
            }
        }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:QueryBuilderInputTable.java

示例2: update

import javax.swing.JTable; //導入依賴的package包/類
void update(MapRule rule,JTable table,int row){
	this.rule=rule;
	int rowHeight=50;
	int h=table.getRowHeight(row);
	if(h!=rowHeight){
		table.setRowHeight(row, rowHeight);
	}
	String name=rule.getName();
	if(name==null){
		name="無";
	}else if(name.trim().equals("")){
		name="無";
	}
	label_wan_address.setText("名稱: "+rule.name+"  加速端口: "+rule.dst_port);
	label2.setText("本地端口: "+rule.getListen_port());

}
 
開發者ID:jonasxiao,項目名稱:FinalSpeed,代碼行數:18,代碼來源:MapRuleRender.java

示例3: actionPerformed

import javax.swing.JTable; //導入依賴的package包/類
@Override
public void actionPerformed(ActionEvent e) {
    String action = e.getActionCommand();
    if (action.equals(Vars.PROP_NEW)) {
        EstadosCadastro estadosCadastro = new EstadosCadastro(estados);
        if (VerificaFrame.verificaFrame(estados.getPainel(), estadosCadastro)) {
            VerificaFrame.exibirFrame(estados.getPainel(), estadosCadastro);
            estados.addChild(estadosCadastro);
        }
    } else if (action.equals(Vars.PROP_REMOVE)) {
        JTable tabela = estados.getTable();
        String sigla = tabela.getValueAt(tabela.getSelectedRow(), 1).toString();
        br.com.secharpe.dao.EstadoDAO estDAO = new br.com.secharpe.dao.EstadoDAO();
        estDAO.delete(sigla);
        estados.refreshTable();
    } else if (action.equals(Vars.PROP_CLOSE)) {
        estados.dispose();
    }
}
 
開發者ID:luandr,項目名稱:ProjetoERP,代碼行數:20,代碼來源:EstadosViewActionListener.java

示例4: getTableCellEditorComponent

import javax.swing.JTable; //導入依賴的package包/類
public Component getTableCellEditorComponent(JTable table,
                                             Object value,
                                             boolean isSelected,
                                             int row,
                                             int column) {
    String className;
    if (table instanceof XTable) {
        XTable mytable = (XTable) table;
        className = mytable.getClassName(row);
    } else {
        className = String.class.getName();
    }
    try {
        init(value,Utils.getClass(className));
    }
    catch(Exception e) {}

    return this;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:XTextFieldEditor.java

示例5: getTableCellRendererComponent

import javax.swing.JTable; //導入依賴的package包/類
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {
	if (value == null) {
		return null;
	}

	FileTableLabel label = (FileTableLabel) value;
	label.setOpaque(false);
	label.setSelected(isSelected);
	if (isSelected) {
		label.setForeground(UIManager.getColor("textHighlightText"));
	} else {
		label.setForeground(UIManager.getColor("textText"));
	}
	return label;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:18,代碼來源:FileTable.java

示例6: getEncryptAction

import javax.swing.JTable; //導入依賴的package包/類
private static AbstractAction getEncryptAction(final JTable table) {
    return new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent me) {
            try {
                int col = table.getSelectedColumn();
                int row = table.getSelectedRow();
                if (col > -1 && row > -1) {
                    String data = table.getValueAt(row, col).toString();
                    table.setValueAt(TMIntegration.encrypt(data), row, col);
                }
            } catch (HeadlessException ex) {
                Logger.getLogger(TMSettingsControl.class.getName())
                        .log(Level.SEVERE, ex.getMessage(), ex);
            }

        }
    };
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:20,代碼來源:TMSettingsControl.java

示例7: assertTableModels

import javax.swing.JTable; //導入依賴的package包/類
/**
 * Dumps the un-staged and stage models and asserts their content.
 * 
 * @param unstagedExpected Expected for the un-staged model.
 * @param indexExpected Expected for the staged model.
 */
protected void assertTableModels(String unstagedExpected, String indexExpected) {
  ChangesPanel unstagedChangesPanel = stagingPanel.getUnstagedChangesPanel();
  JTable filesTable = unstagedChangesPanel.getFilesTable();
  StagingResourcesTableModel uModel = (StagingResourcesTableModel) filesTable.getModel();
  // The newly created file is present in the model.
  
  ChangesPanel stagedChangesPanel = stagingPanel.getStagedChangesPanel();
  JTable stFilesTable = stagedChangesPanel.getFilesTable();
  StagingResourcesTableModel stModel = (StagingResourcesTableModel) stFilesTable.getModel();
  // The newly created file is present in the model.
  
  String ex = "--UNSTAGED--\n" + unstagedExpected + "\n\n--INDEX--\n" + indexExpected;
  String ac = "--UNSTAGED--\n" + getFlatModelDump(uModel) + "\n\n--INDEX--\n" + getFlatModelDump(stModel);

  assertEquals(ex, ac);
}
 
開發者ID:oxygenxml,項目名稱:oxygen-git-plugin,代碼行數:23,代碼來源:FlatViewTestBase.java

示例8: TableExample2

import javax.swing.JTable; //導入依賴的package包/類
public TableExample2(String URL, String driver, String user,
        String passwd, String query) {
    JFrame frame = new JFrame("Table");
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    JDBCAdapter dt = new JDBCAdapter(URL, driver, user, passwd);
    dt.executeQuery(query);

    // Create the table
    JTable tableView = new JTable(dt);

    JScrollPane scrollpane = new JScrollPane(tableView);
    scrollpane.setPreferredSize(new Dimension(700, 300));

    frame.getContentPane().add(scrollpane);
    frame.pack();
    frame.setVisible(true);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:24,代碼來源:TableExample2.java

示例9: getTableCellEditorComponent

import javax.swing.JTable; //導入依賴的package包/類
@Override
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
	final Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
	final JButton button = new JButton("?");
	button.setMargin(new Insets(0, 0, 0, 0));
	button.setToolTipText(Column.WHO_IS.getLabel());
	button.setPreferredSize(new Dimension(Column.WHO_IS.getWidth(), c.getHeight()));
	button.setMaximumSize(button.getPreferredSize());
	if (Env.INSTANCE.getOs() == OS.win) {
		button.setBorder(null);
	}
	button.setEnabled(!_searching);
	button.addActionListener(e -> {
		final RoutePoint point = _route.getRoute().get(_table.convertRowIndexToModel(row));
		WhoIsPanel.showWhoIsDialog(RouteTablePanel.this, _services, point);
		if (table.isEditing()) {
			table.getCellEditor().stopCellEditing();
		}
		_whois.clear();
	});
	return button;
}
 
開發者ID:leolewis,項目名稱:openvisualtraceroute,代碼行數:23,代碼來源:RouteTablePanel.java

示例10: mouseClicked

import javax.swing.JTable; //導入依賴的package包/類
@Override
public void mouseClicked(MouseEvent e) {
    if (e.getModifiers() == InputEvent.BUTTON3_MASK) {
        if (!(e.getSource() instanceof JTable)) {
            return;
        }

        tableComponent = (JTable) e.getSource();
        tableComponent.requestFocus();

        int nx = e.getX();

        if (nx > 500) {
            nx = nx - popup.getSize().width;
        }
        popup.show(e.getComponent(), nx, e.getY() - popup.getSize().height);
    }
}
 
開發者ID:RipMeApp,項目名稱:ripme,代碼行數:19,代碼來源:HistoryMenuMouseListener.java

示例11: deletecols

import javax.swing.JTable; //導入依賴的package包/類
/**
 * deletes all selected columns if it is not present in the <code>exp</code>
 * List
 *
 * @param table the table to DELETE columns
 * @param exp columns to avoid deleting
 * @see #deletecol(javax.swing.JTable, int)
 */
static void deletecols(JTable table, int[] exp) {
    Integer[] selcols;
    try {
        TableColumnModel tcm = table.getColumnModel();
        selcols = ArrayUtils.toObject(table.getSelectedColumns());
        Arrays.sort(selcols, Collections.reverseOrder());
        List<Integer> explist = Ints.asList(exp);
        for (int i : selcols) {
            if (!explist.contains(i)) {
                tcm.removeColumn(tcm.getColumn(i));
            }
        }

    } catch (Exception e) {
        Logger.getLogger(JtableUtils.class.getName()).log(Level.SEVERE, null, e);
    }

}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:27,代碼來源:JtableUtils.java

示例12: canImport

import javax.swing.JTable; //導入依賴的package包/類
@Override
public boolean canImport(TransferHandler.TransferSupport support) {
    if (!support.isDrop()) {
        return false;
    }
    JTable.DropLocation dl = (JTable.DropLocation) support.getDropLocation();
    if (dl.getColumn() < 1) {
        return false;
    }
    try {
        if (support.isDataFlavorSupported(ProjectDnD.TESTCASE_FLAVOR)) {
            dropObject = support.getTransferable().getTransferData(ProjectDnD.TESTCASE_FLAVOR);
            return true;
        } else {
            return false;
        }
    } catch (UnsupportedFlavorException | IOException ex) {
        Logger.getLogger(ScenarioDnD.class.getName()).log(Level.SEVERE, null, ex);
        return false;
    }
}
 
開發者ID:CognizantQAHub,項目名稱:Cognizant-Intelligent-Test-Scripter,代碼行數:22,代碼來源:ScenarioDnD.java

示例13: addMouseListenerToHeaderInTable

import javax.swing.JTable; //導入依賴的package包/類
public void addMouseListenerToHeaderInTable(JTable table) { 
    final TableSorter sorter = this; 
    final JTable tableView = table; 
    tableView.setColumnSelectionAllowed(false); 
    MouseAdapter listMouseListener = new MouseAdapter() {
        boolean ascending = false;
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX()); 
            int column = tableView.convertColumnIndexToModel(viewColumn); 
            if (e.getClickCount() == 1 && column != -1) {
                //System.out.println("Sorting ..."); 
                //int shiftPressed = e.getModifiers()&InputEvent.SHIFT_MASK; 
                //boolean ascending = (shiftPressed == 0);
                if (column == sortBy)                    
                    ascending = !ascending;
                else
                    ascending = true; 
                sorter.sortByColumn(column, ascending);   
                tableView.getTableHeader().updateUI();                  
            }
        }
    };
    JTableHeader th = tableView.getTableHeader(); 
    th.addMouseListener(listMouseListener); 
}
 
開發者ID:ser316asu,項目名稱:SER316-Munich,代碼行數:27,代碼來源:TableSorter.java

示例14: addMouseListenerToHeaderInTable

import javax.swing.JTable; //導入依賴的package包/類
public void addMouseListenerToHeaderInTable(JTable table) {
    final TableSorter sorter = this;
    final JTable tableView = table;
    tableView.setColumnSelectionAllowed(false);
    MouseAdapter listMouseListener = new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            TableColumnModel columnModel = tableView.getColumnModel();
            int viewColumn = columnModel.getColumnIndexAtX(e.getX());
            int column = tableView.convertColumnIndexToModel(viewColumn);
            if (e.getClickCount() == 1 && column != -1) {
                System.out.println("Sorting ...");
                int shiftPressed = e.getModifiers() & InputEvent.SHIFT_MASK;
                boolean ascending = (shiftPressed == 0);
                sorter.sortByColumn(column, ascending);
            }
        }
    };
    JTableHeader th = tableView.getTableHeader();
    th.addMouseListener(listMouseListener);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:TableSorter.java

示例15: printWithoutPrintDialog

import javax.swing.JTable; //導入依賴的package包/類
private static void printWithoutPrintDialog() {

        final JTable table = createAuthorTable(50);
        PrintRequestAttributeSet pras
                = new HashPrintRequestAttributeSet();
        pras.add(new Copies(1));

        try {

            boolean printAccepted = table.print(JTable.PrintMode.FIT_WIDTH,
                    new MessageFormat("Author Table"),
                    new MessageFormat("Page - {0}"),
                    false, pras, false);

            closeFrame();
            if (!printAccepted) {
                throw new RuntimeException("User cancels the printer job!");
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:24,代碼來源:ImageableAreaTest.java


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