当前位置: 首页>>代码示例>>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;未经允许,请勿转载。