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


Java JTable.setSelectionMode方法代码示例

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


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

示例1: init

import javax.swing.JTable; //导入方法依赖的package包/类
private void init() {
        this.setLayout(new BorderLayout());
        tableListTable = new JTable(this.tableModel);
        tableListTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        tableListTable.setFillsViewportHeight(false);
        tableListTable.setDragEnabled(false);
        tableListTable.setColumnSelectionAllowed(false);
        tableListTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        
//        //
//        // Set the column widths
//        //
//        tableListTable.getColumnModel().getColumn(0).setPreferredWidth(40);
//        tableListTable.getColumnModel().getColumn(1).setPreferredWidth(20);
//        tableListTable.getColumnModel().getColumn(3).setPreferredWidth(40);
        
        JScrollPane scrollPane = new JScrollPane(tableListTable);
        //scrollPane.setPreferredSize(new Dimension(DesignerVisualization.WINDOW_WIDTH, 175));
        //scrollPane.setMaximumSize(this.columnSetTable.getPreferredScrollableViewportSize());
        this.add(scrollPane, BorderLayout.CENTER);
    }
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:22,代码来源:TableListPanel.java

示例2: CourseListPanel

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Create the panel.
 */
public CourseListPanel(String user,ProfessorFrame pf) throws Exception{
	setLayout(new BorderLayout(0, 0));
       TableCellRenderer buttonRenderer = new ButtonRenderer();
	dao = new ProfessorDAO();
	model=new tableModelTeach(dao.getAllCourses(user),user,pf);
	table = new JTable();
	table.setRowHeight(30);
	
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.setDefaultRenderer(JButton.class,buttonRenderer);
	table.addMouseListener(new JTableButtonMouseListener(table));
	table.setModel(model);
	JScrollPane scrollPane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	//resizeColumnWidth(table);
	table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	TableColumnModel tcm = table.getColumnModel();
	tcm.getColumn(0).setPreferredWidth(800);    
	tcm.getColumn(1).setPreferredWidth(200);    
	
	scrollPane.setBounds(10, 57, 1320, 450);
	add(scrollPane, BorderLayout.CENTER);
}
 
开发者ID:jtatia,项目名称:Course-Management-System,代码行数:26,代码来源:CourseListPanel.java

示例3: buildTablePanel

import javax.swing.JTable; //导入方法依赖的package包/类
private JScrollPane buildTablePanel() {
      table = new JTable(new AddressBookTableModel(),new DefaultTableColumnModel());
      TableColumn nameColumn = new TableColumn(0);
      TableColumn addressColumn = new TableColumn(1);
      table.addColumn(nameColumn);
      table.addColumn(addressColumn);
      table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // one at a time
      table.getSelectionModel().addListSelectionListener(new AddressListSelectionListener());
      table.addMouseListener(new AddressMouseListener());
      
      // TODO: isolate in utility
TableCellRenderer renderer = table.getCellRenderer(0, 0);
Component comp = renderer.getTableCellRendererComponent(table, "123", false, false, 0, 0);
table.setRowHeight(new Double(comp.getPreferredSize().getHeight()).intValue() + 2);
      
      JScrollPane scrollPane = new JScrollPane(table);
      return scrollPane;
  }
 
开发者ID:ZencashOfficial,项目名称:zencash-swing-wallet-ui,代码行数:19,代码来源:AddressBookPanel.java

示例4: construtorTabelaModel

import javax.swing.JTable; //导入方法依赖的package包/类
private void construtorTabelaModel(){
		
		Object[] colunas = new String[]{"Numero","Date Emissão","CNPJ/CPF","Razão Social/Nome","Quantidade de Itens","Valor Total"};

		Object[][] dados = new Object[][]{
//		       {"100", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"200", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"300", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"400", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"500", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"}
		};

		model = new DefaultTableModel(dados , colunas ){
			public boolean isCellEditable(int row, int col){
				return false;
			}
		};
		tabela = new JTable();
		tabela.setModel(model);
		tabela.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		painelTabela = new JScrollPane();
		painelTabela.setViewportView(tabela);
		
//		busca e inserção de notas fiscais do banco na tabela
		this.buscaNf();
		
	}
 
开发者ID:matheusPeresDeAraujo,项目名称:20170612-NotaFIscalEletronica,代码行数:28,代码来源:FrameInicial.java

示例5: construtorPanelIndicador

import javax.swing.JTable; //导入方法依赖的package包/类
private void construtorPanelIndicador(){

		Object[] colunas = new String[]{"Pesquisa","Resultado"};

		Object[][] dados = new Object[][]{
		};

		model = new DefaultTableModel(dados , colunas ){
			public boolean isCellEditable(int row, int col){
				return false;
			}
		};
		tabela = new JTable();
		tabela.setModel(model);
		tabela.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		painelTabela = new JScrollPane();
		painelTabela.setViewportView(tabela);
		
		// busca e inserção dos resultados na tabela
		this.consultaIndicadores();
		
	}
 
开发者ID:matheusPeresDeAraujo,项目名称:20170612-NotaFIscalEletronica,代码行数:23,代码来源:FrameIndicadores.java

示例6: getClustDetTable

import javax.swing.JTable; //导入方法依赖的package包/类
private JTable getClustDetTable() {
	tableClusters = new JTable(new clustDetModel(info.numElem, info.percent)) {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		{
			setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
			getColumnModel().getColumn(0).setPreferredWidth(170);
			getColumnModel().getColumn(1).setPreferredWidth(110);
			getColumnModel().getColumn(2).setPreferredWidth(110);
			getColumnModel().getColumn(3).setPreferredWidth(55);
		}

		@Override
		public TableCellRenderer getCellRenderer(int row, int column) {
			if (column == 3) {
				return new ColorRenderer();
			}
			return getDefaultRenderer(String.class);
		}
	};
	tableClusters.setSelectionBackground(new Color(83, 126, 126));
	tableClusters.setSelectionForeground(Color.BLACK);
	tableClusters.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	tableClusters.setFont(new Font(tableClusters.getFont().getName(), tableClusters.getFont().getStyle(), tableClusters.getFont().getSize() + 1));
	tableClusters.setRowSelectionInterval(0, 0);
	return tableClusters;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:30,代码来源:KMeansInfoClustering.java

示例7: getVarsDetTable

import javax.swing.JTable; //导入方法依赖的package包/类
private JTable getVarsDetTable() {
	double[] p = new double[numClust];
	for (int i = 0; i < numClust; i++) {
		p[i] = info.infoCluster[i].percVar[listVars.getSelectedIndex()];
	}
	tableVars = new JTable(new varsDetModel(p)) {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		{
			setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
			getColumnModel().getColumn(0).setPreferredWidth(170);
			getColumnModel().getColumn(1).setPreferredWidth(100);
			getColumnModel().getColumn(2).setPreferredWidth(55);
		}

		@Override
		public TableCellRenderer getCellRenderer(int row, int column) {
			if (column == 2) {
				return new ColorRenderer();
			}
			return getDefaultRenderer(String.class);
		}
	};
	tableVars.setSelectionBackground(new Color(83, 126, 126));
	tableVars.setSelectionForeground(Color.BLACK);
	tableVars.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	tableVars.setFont(new Font(tableVars.getFont().getName(), tableVars.getFont().getStyle(), tableVars.getFont().getSize() + 1));
	tableVars.setRowSelectionInterval(0, 0);
	return tableVars;
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:33,代码来源:KMeansInfoClustering.java

示例8: getUpperTable

import javax.swing.JTable; //导入方法依赖的package包/类
private JScrollPane getUpperTable() {
	clusteringFinalTable = new JTable(new clustDetModel(infos.numElem, infos.percent));
	clusteringFinalTable.setSelectionBackground(new Color(83, 126, 126));
	clusteringFinalTable.setSelectionForeground(Color.BLACK);
	clusteringFinalTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	return new JScrollPane(clusteringFinalTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
			ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:9,代码来源:FuzzyInfoClustering.java

示例9: 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

示例10: iniciaJTable

import javax.swing.JTable; //导入方法依赖的package包/类
/**
* Método responsável por inicializar JTable
*
*/
private void iniciaJTable() {
	tableTransacoes = new JTable();
	tableTransacoes.setModel(new DefaultTableModel(new Object[][] {},
	retornaNomeColunas()));
	tableTransacoes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	tableTransacoes.setBounds(703, 24, -690, 140);
	tableTransacoes.getTableHeader().setReorderingAllowed(false);
	panelTransacoes.setLayout(null);
	JScrollPane scrollPane = new JScrollPane(tableTransacoes);
	scrollPane.setViewportView(tableTransacoes);
	scrollPane.setBounds(10, 21, 691, 154);
	panelTransacoes.add(scrollPane);
}
 
开发者ID:alexferreiradev,项目名称:3way_laboratorios,代码行数:18,代码来源:OperacoesBanco.java

示例11: createMapping

import javax.swing.JTable; //导入方法依赖的package包/类
private JComponent createMapping()
{
	attributeModel = new AttributeTableModel();
	attributeTable = new JTable(attributeModel);

	attributeTable.setModel(attributeModel);
	attributeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	attributeTable.changeSelection(0, 0, false, true);

	return new JScrollPane(attributeTable);
}
 
开发者ID:equella,项目名称:Equella,代码行数:12,代码来源:LDAPMappingPanel.java

示例12: buildTablePanel

import javax.swing.JTable; //导入方法依赖的package包/类
private JScrollPane buildTablePanel() {
    table = new JTable(new AddressBookTableModel(),new DefaultTableColumnModel());
    TableColumn nameColumn = new TableColumn(0);
    TableColumn addressColumn = new TableColumn(1);
    table.addColumn(nameColumn);
    table.addColumn(addressColumn);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // one at a time
    table.getSelectionModel().addListSelectionListener(new AddressListSelectionListener());
    table.addMouseListener(new AddressMouseListener());
    JScrollPane scrollPane = new JScrollPane(table);
    return scrollPane;
}
 
开发者ID:ca333,项目名称:komodoGUI,代码行数:13,代码来源:AddressBookPanel.java

示例13: BracketingList

import javax.swing.JTable; //导入方法依赖的package包/类
public BracketingList(String cname, int size)
{
	super(new MigLayout("fill"), false);

	model = new BracketingListModel();
	required = size;
	
	spinner = new JSpinner(new SpinnerNumberModel(size, size/2+1, size, 1));
	spinner.addChangeListener(this);
	
	ladiesCheck = new JCheckBox("Ladies Classes", true);
	ladiesCheck.addChangeListener(this);
	
	openCheck = new JCheckBox("Open Classes", true);
	openCheck.addChangeListener(this);
	
	bonusCheck = new JCheckBox("Bonus Style Dialins", true);		
	bonusCheck.addChangeListener(this);
	
	table = new JTable(model);
	table.setAutoCreateRowSorter(true);
	table.setDefaultRenderer(Double.class, new D3Renderer());
	table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
	table.getColumnModel().getColumn(0).setMaxWidth(50);
	table.getColumnModel().getColumn(1).setMaxWidth(200);
	table.getColumnModel().getColumn(2).setMaxWidth(200);
	table.getColumnModel().getColumn(3).setMaxWidth(75);
	table.getColumnModel().getColumn(4).setMaxWidth(75);

	mainPanel.add(new JLabel("Number of Drivers"), "split");
	mainPanel.add(spinner, "gapbottom 10, wrap");

	mainPanel.add(ladiesCheck, "wrap");
	mainPanel.add(openCheck, "wrap");
	mainPanel.add(bonusCheck, "gapbottom 10, wrap");
	
	mainPanel.add(new JLabel("Click on column header to sort"), "center, wrap");
	mainPanel.add(new JScrollPane(table), "width 400, height 600, grow");
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:40,代码来源:BracketingList.java

示例14: SymbolPanel

import javax.swing.JTable; //导入方法依赖的package包/类
public SymbolPanel() {
  setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

  mainPanel = new JPanel();
  mainPanel.setBorder(BorderFactory.createLineBorder(Color.black));
  mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));

  Box box = Box.createHorizontalBox();
  box.add(new JLabel("Items"));
  mainPanel.add(box);

  model = new SymbolTableModel();
  table = new JTable(model);
  table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  if (getValueList() != null && getValueList().size() > 0) {
    table.getSelectionModel().setSelectionInterval(0, 0);
  }
  ListSelectionModel rowSM = table.getSelectionModel();
  rowSM.addListSelectionListener(new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
      if (e.getValueIsAdjusting()) return;

      ListSelectionModel lsm = (ListSelectionModel) e.getSource();
      if (lsm.isSelectionEmpty()) {
        showItem(NO_CURRENT_ITEM);
      }
      else {
        int selectedRow = lsm.getMinSelectionIndex();
        showItem(selectedRow);
      }
    }
  });

  scrollPane = new ScrollPane(table);
  table.setPreferredScrollableViewportSize(new Dimension(300, 100));
  mainPanel.add(scrollPane);

  detailPanel = new JPanel();
  mainPanel.add(new ScrollPane(detailPanel));

  add(mainPanel);

  showItem(0);

}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:46,代码来源:InstanceConfigurer.java

示例15: PanelCourses

import javax.swing.JTable; //导入方法依赖的package包/类
public PanelCourses(Student student,CourseOutline courseoutline) throws Exception{
	this.co=courseoutline;
	setLayout(new BorderLayout(0, 0));
	cmdao=new CourseMappingDAO();
	/*JScrollPane scrollPane = new JScrollPane();
	add(scrollPane, BorderLayout.CENTER);*/
	
	JLabel lblCoursesTaken = new JLabel("Courses Taken");
	//scrollPane.setColumnHeaderView(lblCoursesTaken);
	
	StudentCourseOutlineDAO sctodao = new StudentCourseOutlineDAO(student);
	ArrayList<String> course = sctodao.Coursedata(student);
      /* DefaultListModel<String> model = new DefaultListModel<>();
	int size = course.size();
	for(int i=0; i<size; i++){
    	model.addElement(course.get(i));
	}
	JList list = new JList(model);
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent arg0) {
			String course_name=(String)list.getSelectedValue();
			//System.out.println("Course id is::"+course_name);
			//System.out.println("Batch is ::"+student.getBatch());
			String path=cmdao.getDirectoryPath(course_name, student.getBatch());
			
			//System.out.println("Path is::"+path);
			//System.out.println(path);
			co.c_panel.curr_subject=course_name;
			try {
				co.c_panel.resetPanes(student, path);
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			 jb=(JLabel)co.panel.getComponent(7);
			 jb_c=(JLabel)co.panel.getComponent(6);
			jb.setVisible(true);
			jb_c.setVisible(true);
			jb.setText(course_name);
			CardLayout card=(CardLayout)co.panel_1.getLayout();
			co.panel_2.getComponent(0).setEnabled(true);
			card.show(co.panel_1, "CoursePanel");
		}
	});
	scrollPane.setViewportView(list);*/
	
	TableCellRenderer buttonRenderer = new ButtonRenderer();
	model=new CourseTableModel(course,this,student);
	table = new JTable();
	table.setRowHeight(30);
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.setDefaultRenderer(JButton.class,buttonRenderer);
	table.addMouseListener(new JTableButtonMouseListener(table));
	table.setModel(model);
	JScrollPane scrollPane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	//resizeColumnWidth(table);
	table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	TableColumnModel tcm = table.getColumnModel();
	tcm.getColumn(0).setPreferredWidth(800);    
	tcm.getColumn(1).setPreferredWidth(200);    
	
	
	scrollPane.setBounds(10, 57, 1320, 450);
	scrollPane.setColumnHeaderView(lblCoursesTaken);
	add(scrollPane, BorderLayout.CENTER);
	
	
}
 
开发者ID:jtatia,项目名称:Course-Management-System,代码行数:70,代码来源:PanelCourses.java


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