Java Code Examples for javax.swing.JTable#setShowGrid()

The following examples show how to use javax.swing.JTable#setShowGrid() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FileExplorer.java    From MeteoInfo with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Constructor
 * @param path Path
 */
public FileExplorer(File path) {
    super(new BorderLayout());
    
    this.path = path;
    this.setForeground(Color.white);
    dtmFile = new LocalTableModel();
    dtmFile.addColumn("Name");
    dtmFile.addColumn("Size");
    dtmFile.addColumn("File Type");
    dtmFile.addColumn("Date Modified");
    jtFile = new JTable(dtmFile);
    jtFile.getColumnModel().getColumn(0).setCellRenderer(new IconRenderer());
    jtFile.setShowGrid(false);
    jtFile.addMouseListener(this);

    add(new JScrollPane(jtFile), "Center");

    //Show current path files
    //path = new File(System.getProperty("user.dir"));
    if (path != null)
        listFiles(path);    

    init = true;
}
 
Example 2
Source File: TableUtils.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static JScrollPane createToggleButtonSelectionPane(JTable table, JTable rowheaderTable,
	JToggleButton button)
{
	rowheaderTable.setAutoCreateColumnsFromModel(false);
	// force the tables to share models
	rowheaderTable.setModel(table.getModel());
	rowheaderTable.setSelectionModel(table.getSelectionModel());
	rowheaderTable.setRowHeight(table.getRowHeight());
	rowheaderTable.setIntercellSpacing(table.getIntercellSpacing());
	rowheaderTable.setShowGrid(false);
	rowheaderTable.setFocusable(false);

	TableColumn column = new TableColumn(-1);
	column.setHeaderValue(new Object());
	column.setCellRenderer(new TableCellUtilities.ToggleButtonRenderer(button));
	rowheaderTable.addColumn(column);
	rowheaderTable.setPreferredScrollableViewportSize(new Dimension(20, 0));

	JScrollPane scrollPane = new JScrollPane();
	scrollPane.setViewportView(table);
	scrollPane.setRowHeaderView(rowheaderTable);
	return scrollPane;
}
 
Example 3
Source File: TableUtils.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
private static JScrollPane createToggleButtonSelectionPane(JTable table, JTable rowheaderTable,
	JToggleButton button)
{
	rowheaderTable.setAutoCreateColumnsFromModel(false);
	// force the tables to share models
	rowheaderTable.setModel(table.getModel());
	rowheaderTable.setSelectionModel(table.getSelectionModel());
	rowheaderTable.setRowHeight(table.getRowHeight());
	rowheaderTable.setIntercellSpacing(table.getIntercellSpacing());
	rowheaderTable.setShowGrid(false);
	rowheaderTable.setFocusable(false);

	TableColumn column = new TableColumn(-1);
	column.setHeaderValue(new Object());
	column.setCellRenderer(new TableCellUtilities.ToggleButtonRenderer(button));
	rowheaderTable.addColumn(column);
	rowheaderTable.setPreferredScrollableViewportSize(new Dimension(20, 0));

	JScrollPane scrollPane = new JScrollPane();
	scrollPane.setViewportView(table);
	scrollPane.setRowHeaderView(rowheaderTable);
	return scrollPane;
}
 
Example 4
Source File: Hottable.java    From pdfxtk with Apache License 2.0 6 votes vote down vote up
public void activateTool(BrowserContext context, Element e) {
  this.context = context;

  nodes = DOMUtils.getChildElements(e);
  columns = getColumns(e.getAttribute("columns"));

  String name = e.hasAttribute("name") ? e.getAttribute("name") : "Hotlist";
  window = context.getWindowCreator().createWindow(name);

  table = new JTable(model);
  table.setShowGrid(false);
  table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
  table.getSelectionModel().addListSelectionListener(this);

  window.getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
  window.open();

  flagAccess = context.flagger.addFlagListener(FlagManager.SELECTION, this);
}
 
Example 5
Source File: DownloadListView.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
public DownloadListView(JPanel container) {
	model = new DownloadTableModel();
	XDMApp.getInstance().addListener(model);
	table = new JTable(model);
	table.setTableHeader(null);
	table.setDefaultRenderer(DownloadEntry.class, new XDMTableCellRenderer());
	table.setRowHeight(XDMUtils.getScaledInt(70));
	table.setShowGrid(false);
	table.setFillsViewportHeight(true);
	table.setBorder(new EmptyBorder(0, 0, 0, 0));
	table.setDragEnabled(true);
	// table.getSelectionModel().addListSelectionListener(new
	// ListSelectionListener() {
	// @Override
	// public void valueChanged(ListSelectionEvent e) {
	// int selectedRow = e.getFirstIndex();
	// selectedId = model.getIdAt(selectedRow);
	// Logger.log("Selected id1: " + selectedId+" row: "+selectedRow);
	// }
	// });
	//
	// model.addTableModelListener(new TableModelListener() {
	// @Override
	// public void tableChanged(TableModelEvent e) {
	// if(selectedId!=null){
	// int index=model.getIndexOfId(selectedId);
	// Logger.log("Index of "+selectedId+" is: "+index);
	// if(index>-1){
	// table.setRowSelectionInterval(index, index);
	// }
	// }
	// }
	// });

	JScrollPane jsp = new JScrollPane(table);
	jsp.setBorder(new EmptyBorder(0, 0, 0, 0));

	container.add(jsp);
}
 
Example 6
Source File: DrawGridLinesTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
 
Example 7
Source File: DrawGridLInesTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
 
Example 8
Source File: KseFrame.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
private JScrollPane wrapKeyStoreTableInScrollPane(JTable jtKeyStore) {

		jtKeyStore.setOpaque(true);
		jtKeyStore.setShowGrid(false);
		jtKeyStore.setFillsViewportHeight(true);
		JScrollPane jspKeyStoreTable = PlatformUtil.createScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
				ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

		jspKeyStoreTable.setViewportView(jtKeyStore);
		jspKeyStoreTable.setBorder(BorderFactory.createEtchedBorder());
		jspKeyStoreTable.setFocusable(false);

		return jspKeyStoreTable;
	}
 
Example 9
Source File: ScreenInfoPanel.java    From hprof-tools with MIT License 4 votes vote down vote up
public ScreenInfoPanel(@Nonnull final TabbedInfoWindow mainWindow, @Nonnull List<Screen> screens) {
    super(new BorderLayout());

    JPopupMenu popupMenu = new JPopupMenu();
    JMenuItem item = new JMenuItem("Inspect View");
    item.addActionListener(new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent actionEvent) {
            mainWindow.showInstancesListTab(rightClickedViewed.getClassName(), Collections.singletonList(rightClickedViewed.getInstance()));
        }
    });
    popupMenu.add(item);

    imagePanel = new ImagePanel();
    viewTree = new JTree(new DefaultMutableTreeNode("Loading..."));
    viewTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    viewTree.addTreeSelectionListener(this);
    viewTree.addMouseListener(new PopupListener(popupMenu));
    JScrollPane treeScroller = new JScrollPane(viewTree);

    rootPicker = new JComboBox(new Vector<Object>(screens));
    rootPicker.addItemListener(this);

    JPanel settingsPanel = new JPanel(new GridLayout(1, 2));
    showBoundsBox = new JCheckBox("Show layout bounds", true);
    showBoundsBox.addItemListener(this);
    forceAlpha = new JCheckBox("Force alpha", true);
    forceAlpha.addItemListener(this);
    settingsPanel.add(showBoundsBox);
    settingsPanel.add(forceAlpha);
    settingsPanel.setBorder(new EmptyBorder(10, 0, 0, 0));

    infoTable = new JTable();
    infoTable.setRowSelectionAllowed(false);
    infoTable.setColumnSelectionAllowed(false);
    infoTable.setCellSelectionEnabled(false);
    infoTable.setShowGrid(true);

    JPanel bottomPanel = new JPanel(new BorderLayout());
    bottomPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    bottomPanel.add(infoTable, BorderLayout.CENTER);
    bottomPanel.add(infoTable.getTableHeader(), BorderLayout.NORTH);
    bottomPanel.add(settingsPanel, BorderLayout.SOUTH);

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.add(rootPicker, BorderLayout.NORTH);
    leftPanel.add(treeScroller, BorderLayout.CENTER);
    leftPanel.add(bottomPanel, BorderLayout.SOUTH);

    // Split pane for the tree and image views
    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(imagePanel);
    add(splitPane, BorderLayout.CENTER);
    selectedScreen = screens.get(0);
    update();
}