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


Java JTable.setDefaultRenderer方法代码示例

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


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

示例1: init

import javax.swing.JTable; //导入方法依赖的package包/类
private void init(JLabel label, String[] columns) {
    tableModel = new PropertiesTableModel(columns);
    tableModel.addTableModelListener(this);
    table = new JTable(tableModel);
    table.getTableHeader().setReorderingAllowed(false);
    table.setDefaultRenderer(String.class, new PropertiesTableCellRenderer());
    //table.setDefaultEditor(CommitOptions.class, new CommitOptionsCellEditor());
    table.setRowHeight(table.getRowHeight());
    table.addAncestorListener(this);
    component = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    component.setPreferredSize(new Dimension(340, 150));
    table.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PropertiesTable.class, "ACSD_PropertiesTable")); // NOI18N        
    table.getAccessibleContext().setAccessibleName(NbBundle.getMessage(PropertiesTable.class, "ACSN_PropertiesTable")); // NOI18N        
    label.setLabelFor(table);
    setColumns(columns);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:PropertiesTable.java

示例2: TableDialogEditDemo

import javax.swing.JTable; //导入方法依赖的package包/类
public TableDialogEditDemo() {
    super(new GridLayout(1, 0));

    JTable table = new JTable(new MyTableModel());
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    // Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    // Set up renderer and editor for the Favorite Color column.
    table.setDefaultRenderer(Color.class, new ColorRenderer(true));
    table.setDefaultEditor(Color.class, new ColorEditor());

    // Add the scroll pane to this panel.
    add(scrollPane);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:18,代码来源:TableDialogEditDemo.java

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

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

示例5: PhotoList

import javax.swing.JTable; //导入方法依赖的package包/类
public PhotoList(ZooracleContentPanel zooracleContentPanel)
	{

		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		this.zooracleContentPanel = zooracleContentPanel;
		// Set the frame characteristics
//		setSize(150, 600);
		setBackground(Color.gray);

		// Create a panel to hold all other components
		topPanel = new JPanel();
		topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));

		this.add(topPanel);


		// Create some data
//		String dataValues[][] = { { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279", "9033", "3092" } };

		// Create a new table instance
		table = new JTable(null, columnNames);
//		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

//		table.setMinimumSize(new Dimension(150, 600));
//		table.setPreferredSize(new Dimension(150, 600));

		// table.setD
		selectionModel = new DefaultListSelectionModel();
		
		model = new DefaultTableModel();
		

		// table.setC
		selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		selectionModel.addListSelectionListener(new ListSelectionListener()
		{

			public void valueChanged(ListSelectionEvent e)
			{
				int selectionIndex = table.getSelectedRow();
				if (lastSelectionIndex != selectionIndex)
				{
					
					lastSelectionIndex = selectionIndex;
					
					if (selectionIndex==-1)
						return;
					System.out.println(table.getValueAt(selectionIndex, 0));
					System.out.println("sele:" + selectionIndex);
					
					if (PhotoList.this.zooracleContentPanel instanceof ImportView)
					{
						((ImportView)(PhotoList.this.zooracleContentPanel)).setCurrentPhoto(selectionIndex);
					}
//					if (selectionIndex > 2)
//						PhotoList.this.maximize(false);
				}
			}
		});
		// table.setDefaultRenderer(Object.class, new EditedCellRenderer(this));
		table.setSelectionModel(selectionModel);
		table.setDefaultRenderer(String.class, new BoardTableCellRenderer());
		table.setDefaultRenderer(Object.class, new BoardTableCellRenderer());
		
		table.setModel(model);
//		table.setMaximumSize(new Dimension(100, 300));
		

		// Add the table to a scrolling pane
		scrollPane = new JScrollPane();
//		scrollPane.add(table.getTableHeader());
//		scrollPane.add(table);
//		topPanel.add(scrollPane);
		
		topPanel.add(table.getTableHeader());
		topPanel.add(new JScrollPane(table));
	}
 
开发者ID:fossasia,项目名称:zooracle,代码行数:78,代码来源:PhotoList.java

示例6: checkTableGridLines

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

        TableModel dataModel = new AbstractTableModel() {
            public int getColumnCount() {
                return 10;
            }

            public int getRowCount() {
                return 10;
            }

            public Object getValueAt(int row, int col) {
                return " ";
            }
        };

        DefaultTableCellRenderer r = new DefaultTableCellRenderer();
        r.setOpaque(true);
        r.setBackground(CELL_RENDERER_BACKGROUND_COLOR);

        JTable table = new JTable(dataModel);
        table.setSize(WIDTH, HEIGHT);
        table.setDefaultRenderer(Object.class, r);
        table.setGridColor(GRID_COLOR);
        table.setShowGrid(true);
        table.setShowHorizontalLines(true);
        table.setShowVerticalLines(true);
        table.setBackground(TABLE_BACKGROUND_COLOR);

        checkTableGridLines(table);
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:DrawGridLinesTest.java

示例7: UpdateUIRecursionTest

import javax.swing.JTable; //导入方法依赖的package包/类
public UpdateUIRecursionTest() {
    super("UpdateUIRecursionTest");
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setSize(400, 400);

    String[] columnNames = {
            "First Name",
            "Last Name",
            "Sport",
            "# of Years",
            "Vegetarian"};

            Object[][] data = {
                {"Mary", "Campione",
                "Snowboarding", new Integer(5), new Boolean(false)},
                {"Alison", "Huml",
                "Rowing", new Integer(3), new Boolean(true)},
                {"Kathy", "Walrath",
                "Knitting", new Integer(2), new Boolean(false)},
                {"Sharon", "Zakhour",
                "Speed reading", new Integer(20), new Boolean(true)},
                {"Philip", "Milne",
                "Pool", new Integer(10), new Boolean(false)}
            };


    table = new JTable(data, columnNames);

    renderer = new DefaultTableCellRenderer();
    getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
    table.setDefaultRenderer(table.getColumnClass(1), this);

    setVisible(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:UpdateUIRecursionTest.java

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

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

示例10: createContent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
protected JPanel createContent() {
	JPanel content = new JPanel();
	GroupLayout layout = new GroupLayout(content);
	content.setLayout(layout);
	layout.setAutoCreateGaps(true);
	layout.setAutoCreateContainerGaps(true);

	// parameters panel
	hhTable = new JTable();
	hhTable.setAutoscrolls(true);
	JScrollPane resScrollPane = new JScrollPane(hhTable);
	resScrollPane
			.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
	resScrollPane
			.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	hhTable.setFillsViewportHeight(true);
	hhTable.setPreferredScrollableViewportSize(new Dimension(400, 100));
	hhTableModel = new MyTableModel();
	hhTable.setModel(hhTableModel);
	hhTable.setDefaultRenderer(Class.class, new MyClassTableCellRenderer());
	hhTable.setDefaultEditor(Double.class, new MyDoubleTableCellEditor());
	hhTableModel.addColumn("Select");
	hhTableModel.addColumn("Hidden Hop Mapping");
	hhTableModel.addColumn("Factor");
	JPanel hhPanel = new JPanel();
	hhPanel.setBorder(BorderFactory.createTitledBorder("Hidden Hops"));
	hhPanel.add(resScrollPane);

	// create the content for the hh panel
	for (Class<?> hh : getAllHhs()) {
		try {
			hh.getDeclaredField(new String("factor"));
			// add a row to the factor table.
			hhTableModel
					.addRow(new Object[] { false, hh, new Double(0.0) });
		} catch (NoSuchFieldException ex) {
		}
	}
	// add the panels
	layout.setHorizontalGroup(layout.createParallelGroup().addComponent(
			hhPanel));
	layout.setVerticalGroup(layout.createSequentialGroup().addComponent(
			hhPanel));

	return content;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:48,代码来源:HiddenHopsDialog.java

示例11: setupFilesSelectionTable

import javax.swing.JTable; //导入方法依赖的package包/类
public static void setupFilesSelectionTable(JTable table, FileDisplayName displayName) {
    table.setDefaultRenderer(File.class, new ConfigFileSelectionFileRenderer(displayName));
    table.setDefaultRenderer(Boolean.class, new ConfigFileSelectionBooleanRenderer(table.getDefaultRenderer(Boolean.class)));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ConfigFilesUIs.java

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