当前位置: 首页>>代码示例>>Java>>正文


Java JTable.setRowSelectionAllowed方法代码示例

本文整理汇总了Java中javax.swing.JTable.setRowSelectionAllowed方法的典型用法代码示例。如果您正苦于以下问题:Java JTable.setRowSelectionAllowed方法的具体用法?Java JTable.setRowSelectionAllowed怎么用?Java JTable.setRowSelectionAllowed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTable的用法示例。


在下文中一共展示了JTable.setRowSelectionAllowed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jbInit

import javax.swing.JTable; //导入方法依赖的package包/类
void jbInit() throws Exception {
  setBorder(BorderList.etchedBorder5);
  ActionListener actionEventHandler = new ActionEventHandler();
  MouseListener mouseEventHandler = new MouseEventHandler();

  addButton = new JButton("Add");
  addButton.setActionCommand("Add");
  addButton.addActionListener(actionEventHandler);

  removeButton = new JButton("Remove");
  removeButton.setActionCommand("Remove");
  removeButton.addActionListener(actionEventHandler);

  //by lila
  JPanel p1 = new JPanel();
  p1.setLayout(new FlowLayout(FlowLayout.CENTER));
  p1.add(addButton);
  p1.add(removeButton);

  model = new MyFieldTableModel();
  fieldTable = new JTable(model);

  fieldTable.setRowSelectionAllowed(true);
  fieldTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
  fieldTable.addMouseListener(mouseEventHandler);
  fieldTable.setBorder(BorderList.bebelBorder);

  scrollpane = new JScrollPane(fieldTable);
  scrollpane.setPreferredSize(new Dimension(550,220));

  //by lila
  JPanel p2 = new JPanel();
  p2.setLayout(new BorderLayout(0,5));
  TitledBorder border = new TitledBorder(new EtchedBorder(),"Field Table");
  border.setTitleFont(FontList.regularFont);
  border.setTitleColor(Color.black);
  p2.setBorder(border);
  p2.add(p1,BorderLayout.SOUTH);
  p2.add(scrollpane,BorderLayout.CENTER);
  p2.add(new JPanel(),BorderLayout.EAST);
  p2.add(new JPanel(),BorderLayout.WEST);

  setLayout(new FlowLayout(FlowLayout.CENTER));
  add(p2);
}
 
开发者ID:FJplant,项目名称:AntIDE,代码行数:46,代码来源:FieldPanel.java

示例2: show

import javax.swing.JTable; //导入方法依赖的package包/类
public void show(int dif) {

			ArrayList<record> rec = new ArrayList<record>();

			String content = FileHelper.readFromFile("ranking.ini");
			if (content != null ) {
				if(!content.equals("")) {
					String[] sp = content.split(",");
					for (int i = 0; i < sp.length; i = i + 3) {
						if (dif == Integer.parseInt(sp[i])) {
							rec.add(new record(sp[i + 2], Integer.parseInt(sp[i + 1])));
						}
					}
				}
				Collections.sort(rec);
				rank = new Object[rec.size()][COL];
				for (int i = 0; i < rec.size(); i++) {
					record temp = rec.get(i);
					rank[i][0] = i + 1;
					rank[i][2] = temp.date;
					rank[i][1] = temp.score;
				}

				table = new JTable(rank, title);
				centerPanel.removeAll();
				centerPanel.setLayout(new BorderLayout());
				centerPanel.add(new JScrollPane(table), BorderLayout.CENTER);
				DefaultTableCellRenderer r = new DefaultTableCellRenderer();
				r.setHorizontalAlignment(JLabel.CENTER);
				table.setDefaultRenderer(Object.class, r);
				table.setRowHeight(20);
				table.setFont(new Font("微软雅黑", 0, 14));
				table.setGridColor(Color.BLUE);
				table.setSize(centerPanel.getWidth(), centerPanel.getHeight());
				table.setRowSelectionAllowed(false);

			}
			setVisible(true);
		}
 
开发者ID:zhangjikai,项目名称:LinkGame,代码行数:40,代码来源:Ranking.java

示例3: setupBasicTableProperties

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * setting up the table.
 *
 * @param table JTable to store this.correlationTableModel
 */
private void setupBasicTableProperties(JTable table) {

	table.clearSelection();

	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);


	TableRenderer cellRenderer = new TableRenderer(new JTextField());

	table.setRowSelectionAllowed(true);
	table.setColumnSelectionAllowed(false);
	table.setVisible(true);
	table.setModel(this.variationPerParameterTableModel);

	initColumnSizes(table);
	for (int i = 0; i < table.getColumnCount(); i++) {
		TableColumn column = table.getColumnModel().getColumn(i);
		column.setCellRenderer(cellRenderer);
	}

	TableColumn columnName = table.getColumnModel().getColumn(VariationPerParameterTableModel.COLUMN_NAME);
	columnName.setCellEditor(new TextCellEditor());
	TableColumn columnBasicValue = table.getColumnModel().getColumn(VariationPerParameterTableModel.COLUMN_BASIC_VALUE);
	columnBasicValue.setCellEditor(new TextCellEditor());

   	setupVariationFunctionComboBoxColumn();

   	this.variationPerParameterTableModel.fireTableDataChanged();

	table.setColumnSelectionAllowed(false);
	table.setRowSelectionAllowed(true);

	//select first row.
	table.getSelectionModel().setSelectionInterval(0, 0);
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:41,代码来源:VariationPerParameterTableController.java

示例4: GraphicTable

import javax.swing.JTable; //导入方法依赖的package包/类
public GraphicTable() {
	graphicTable = new JTable();
	
	graphicTable.setEnabled(false);
	graphicTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	graphicTable.setMinimumSize(graphicTable.getPreferredScrollableViewportSize());
	graphicTable.setPreferredScrollableViewportSize(graphicTable.getPreferredSize());
	graphicTable.setFillsViewportHeight(true);
	graphicTable.getTableHeader().setReorderingAllowed(false);
	graphicTable.setColumnSelectionAllowed(true);
	graphicTable.setRowSelectionAllowed(true);
	graphicTable.setRowSelectionAllowed(true);
	//(ListSelectionModel.SINGLE_SELECTION);
}
 
开发者ID:tteguayco,项目名称:JITRAX,代码行数:15,代码来源:GraphicTable.java

示例5: ResultsPane

import javax.swing.JTable; //导入方法依赖的package包/类
public ResultsPane(ResultsModel inModel)
{
	setLayout(new BorderLayout());

	mdl = inModel;

	ColorTimeRenderer large  = new ColorTimeRenderer(3);
	ColorTimeRenderer medium = new ColorTimeRenderer(2);
	//ColorTimeRenderer small  = new ColorTimeRenderer(1);
	DifferenceRenderer diff  = new DifferenceRenderer();

	tbl = new JTable(inModel) { public void tableChanged(TableModelEvent e) { super.tableChanged(e); scrollTable(); } };
	tbl.setDefaultRenderer(ColorTime.class, new ColorTimeRenderer(1));
	tbl.setRowHeight(140);
	tbl.setRowSelectionAllowed(false);
	//tbl.setIntercellSpacing(new Dimension(8, 8));

	TableColumnModel tcm = tbl.getColumnModel();
	columnStyle(tcm, 0, 50,  70,  200, medium);
	columnStyle(tcm, 1, 50,  70,  200, medium);
	columnStyle(tcm, 2, 80,  110, 280, large);

	columnStyle(tcm, 3, 180, 230, 700, diff);

	columnStyle(tcm, 4, 50,  70,  200, medium);
	columnStyle(tcm, 5, 50,  70,  200, medium);
	columnStyle(tcm, 6, 80,  110, 280, large);

	JScrollPane scroll = new JScrollPane(tbl, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	add(scroll);
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:32,代码来源:ResultsPane.java


注:本文中的javax.swing.JTable.setRowSelectionAllowed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。