Java Code Examples for javax.swing.table.JTableHeader#setPreferredSize()

The following examples show how to use javax.swing.table.JTableHeader#setPreferredSize() . 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: InspectorPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
PropertiesPanel(FlutterApp flutterApp, InspectorService inspectorService) {
  super(new ListTreeTableModelOnColumns(
    new DefaultMutableTreeNode(),
    new ColumnInfo[]{
      new PropertyNameColumnInfo("Property"),
      new PropertyValueColumnInfo("Value")
    }
  ));
  this.flutterApp = flutterApp;
  this.groups = new InspectorObjectGroupManager(inspectorService, "panel");
  setRootVisible(false);

  setStriped(true);
  setRowHeight(getRowHeight() + JBUI.scale(4));

  final JTableHeader tableHeader = getTableHeader();
  tableHeader.setPreferredSize(new Dimension(0, getRowHeight()));

  getColumnModel().getColumn(0).setPreferredWidth(120);
  getColumnModel().getColumn(1).setPreferredWidth(200);
}
 
Example 2
Source File: InspectorPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
PropertiesPanel(FlutterApp flutterApp, InspectorService inspectorService) {
  super(new ListTreeTableModelOnColumns(
    new DefaultMutableTreeNode(),
    new ColumnInfo[]{
      new PropertyNameColumnInfo("Property"),
      new PropertyValueColumnInfo("Value")
    }
  ));
  this.flutterApp = flutterApp;
  this.groups = new InspectorObjectGroupManager(inspectorService, "panel");
  setRootVisible(false);

  setStriped(true);
  setRowHeight(getRowHeight() + JBUI.scale(4));

  final JTableHeader tableHeader = getTableHeader();
  tableHeader.setPreferredSize(new Dimension(0, getRowHeight()));

  getColumnModel().getColumn(0).setPreferredWidth(120);
  getColumnModel().getColumn(1).setPreferredWidth(200);
}
 
Example 3
Source File: SyncPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "SyncPanel.table.header.info.toolTip=Click to sort by Information",
    "SyncPanel.table.header.remotePath.toolTip=Click to sort by Remote Path",
    "SyncPanel.table.header.localPath.toolTip=Click to sort by Local Path",
    "SyncPanel.table.header.operation.toolTip=Click to swap Remote Path and Local Path"
})
private void initTableHeader() {
    JTableHeader header = itemTable.getTableHeader();
    header.setPreferredSize(new Dimension(itemTable.getColumnModel().getTotalColumnWidth(), Math.max(20, itemTable.getFont().getSize() + 5)));
    header.setReorderingAllowed(false);
    // columns
    TableColumn infoColumn = header.getColumnModel().getColumn(0);
    infoColumn.setHeaderRenderer(new HeaderRenderer(Bundle.SyncPanel_table_header_info_toolTip()));
    infoColumn.setHeaderValue(ImageUtilities.loadImageIcon(HEADER_INFO_ICON_PATH, false));
    TableColumn operationColumn = header.getColumnModel().getColumn(2);
    operationColumn.setHeaderRenderer(new HeaderRenderer(Bundle.SyncPanel_table_header_operation_toolTip()));
    operationColumn.setHeaderValue(ImageUtilities.loadImageIcon(HORIZONTAL_ICON_PATH, false));
    TableColumn remotePathColumn = header.getColumnModel().getColumn(remotePathFirst ? 1 : 3);
    remotePathColumn.setHeaderRenderer(new HeaderRenderer(Bundle.SyncPanel_table_header_remotePath_toolTip()));
    TableColumn localPathColumn = header.getColumnModel().getColumn(remotePathFirst ? 3 : 1);
    localPathColumn.setHeaderRenderer(new HeaderRenderer(Bundle.SyncPanel_table_header_localPath_toolTip()));
    // listener
    itemTable.getTableHeader().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (itemTable.columnAtPoint(e.getPoint()) == 2) {
                swapPaths();
            }
        }
    });
}
 
Example 4
Source File: TableDemo.java    From littleluck with Apache License 2.0 4 votes vote down vote up
protected void initComponents() {
    setLayout(new BorderLayout());

    controlPanel = createControlPanel();
    add(controlPanel, BorderLayout.NORTH);

    //<snip>Create JTable
    oscarTable = new JTable(oscarModel);
    //</snip>

    //</snip>Set JTable display properties
    oscarTable.setColumnModel(createColumnModel());
    oscarTable.setAutoCreateRowSorter(true);
    oscarTable.setRowHeight(26);
    oscarTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
    oscarTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    oscarTable.setIntercellSpacing(new Dimension(0, 0));
    //</snip>

    //<snip>Initialize preferred size for table's viewable area
    Dimension viewSize = new Dimension();
    viewSize.width = oscarTable.getColumnModel().getTotalColumnWidth();
    viewSize.height = 10 * oscarTable.getRowHeight();
    oscarTable.setPreferredScrollableViewportSize(viewSize);
    //</snip>

    //<snip>Customize height and alignment of table header
    JTableHeader header = oscarTable.getTableHeader();
    header.setPreferredSize(new Dimension(30, 26));
    TableCellRenderer headerRenderer = header.getDefaultRenderer();
    if (headerRenderer instanceof JLabel) {
        ((JLabel) headerRenderer).setHorizontalAlignment(JLabel.CENTER);
    }
    //</snip>

    LuckScrollPane scrollpane = new LuckScrollPane(oscarTable);
    dataPanel = new Stacker(scrollpane);
    add(dataPanel, BorderLayout.CENTER);

    add(createStatusBar(), BorderLayout.SOUTH);

}
 
Example 5
Source File: TableDemo.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
protected void initComponents() {
	setLayout(new BorderLayout());

	controlPanel = createControlPanel();
	add(controlPanel, BorderLayout.NORTH);

	// <snip>Create JTable
	oscarTable = new JTable(oscarModel);
	// </snip>

	// </snip>Set JTable display properties
	oscarTable.setColumnModel(createColumnModel());
	oscarTable.setAutoCreateRowSorter(true);
	oscarTable.setRowHeight(26);
	oscarTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN);
	oscarTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	oscarTable.setIntercellSpacing(new Dimension(0, 0));
	// </snip>

	// <snip>Initialize preferred size for table's viewable area
	Dimension viewSize = new Dimension();
	viewSize.width = oscarTable.getColumnModel().getTotalColumnWidth();
	viewSize.height = 10 * oscarTable.getRowHeight();
	oscarTable.setPreferredScrollableViewportSize(viewSize);
	// </snip>

	// <snip>Customize height and alignment of table header
	JTableHeader header = oscarTable.getTableHeader();
	header.setPreferredSize(new Dimension(30, 26));
	TableCellRenderer headerRenderer = header.getDefaultRenderer();
	if (headerRenderer instanceof JLabel) {
		((JLabel) headerRenderer).setHorizontalAlignment(JLabel.CENTER);
	}
	// </snip>

	JScrollPane scrollpane = new JScrollPane(oscarTable);
	dataPanel = new Stacker(scrollpane);
	add(dataPanel, BorderLayout.CENTER);

	add(createStatusBar(), BorderLayout.SOUTH);

}
 
Example 6
Source File: AstrosoftTable.java    From Astrosoft with GNU General Public License v2.0 4 votes vote down vote up
private void setHeaderProperties(){
    JTableHeader header = getTableHeader();
    header.setFont(headerFont);
    header.setPreferredSize(new Dimension(getPreferredSize().width, rowHeight));
    //header.setBorder(new LineBorder(tableBorderClr));
}