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


Java JTable.setShowGrid方法代码示例

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


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

示例1: createConstraintsTable

import javax.swing.JTable; //导入方法依赖的package包/类
public JTable createConstraintsTable(boolean rebuild) {		
    JTable table = new JTable(new VRPTableModel(rebuild));	      
    
    table.setPreferredScrollableViewportSize(new Dimension(60, 60));
    table.setAutoscrolls(true);
    table.setAutoCreateColumnsFromModel(true);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
    table.setMaximumSize(new Dimension(60, 60));
    table.setBackground(Color.LIGHT_GRAY);
    table.setBorder(BorderFactory.createCompoundBorder());
    table.setForeground(Color.BLACK);
    table.setShowGrid(true);
    
      return table;
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:16,代码来源:VRPSettings.java

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

示例3: setup

import javax.swing.JTable; //导入方法依赖的package包/类
private void setup()
{
	actions = new ArrayList<TLEAction>();
	actions.add(upAction);
	actions.add(downAction);
	actions.add(addAction);
	actions.add(removeAction);

	model = new PowerSearchModel(repository);
	table = new JTable(model)
	{
		private static final long serialVersionUID = 1L;

		@Override
		public boolean getScrollableTracksViewportHeight()
		{
			// fetch the table's parent
			Container viewport = getParent();

			// if the parent is not a viewport, calling this isn't useful
			if( !(viewport instanceof JViewport) )
			{
				return false;
			}

			// return true if the table's preferred height is smaller
			// than the viewport height, else false
			return getPreferredSize().height < viewport.getHeight();
		}
	};
	table.setShowGrid(false);
	table.addMouseListener(new TablePopupListener(table, actions));
	table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

	addListSelectionListener(new ListSelectionListener()
	{
		@Override
		public void valueChanged(ListSelectionEvent e)
		{
			if( !e.getValueIsAdjusting() )
			{
				updateButtons();
			}
		}
	});

	TableColumn c = table.getColumnModel().getColumn(1);
	c.setMinWidth(50);
	c.setMaxWidth(50);
	c.setWidth(50);

	JScrollPane tableScroll = new JScrollPane(table);

	JButton addButton = new JButton(addAction);
	JButton removeButton = new JButton(removeAction);
	JButton upButton = new JTextlessButton(upAction);
	JButton downButton = new JTextlessButton(downAction);

	final int height1 = upButton.getPreferredSize().height;
	final int height2 = removeButton.getPreferredSize().height;
	final int width1 = upButton.getPreferredSize().width;
	final int width2 = removeButton.getPreferredSize().width;

	final int[] rows = {TableLayout.FILL, height1, height1, TableLayout.FILL, height2,};
	final int[] cols = {width1, TableLayout.FILL, width2, width2, TableLayout.FILL,};

	setLayout(new TableLayout(rows, cols, 5, 5));

	add(tableScroll, new Rectangle(1, 0, 4, 4));
	add(upButton, new Rectangle(0, 1, 1, 1));
	add(downButton, new Rectangle(0, 2, 1, 1));
	add(addButton, new Rectangle(2, 4, 1, 1));
	add(removeButton, new Rectangle(3, 4, 1, 1));

	updateButtons();

	changeDetector = new ChangeDetector();
	changeDetector.watch(model);
}
 
开发者ID:equella,项目名称:Equella,代码行数:80,代码来源:PowerSearchList.java


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