當前位置: 首頁>>代碼示例>>Java>>正文


Java JViewport.getHeight方法代碼示例

本文整理匯總了Java中javax.swing.JViewport.getHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java JViewport.getHeight方法的具體用法?Java JViewport.getHeight怎麽用?Java JViewport.getHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JViewport的用法示例。


在下文中一共展示了JViewport.getHeight方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getExtentBounds

import javax.swing.JViewport; //導入方法依賴的package包/類
/** Get position of the component extent. The (x, y) are set to (0, 0) if there's
* no viewport or (-x, -y) if there's one.
*/
public Rectangle getExtentBounds(Rectangle r) {
    if (r == null) {
        r = new Rectangle();
    }
    if (component != null) {
        JViewport port = getParentViewport();
        if (port != null) {
            Point p = port.getViewPosition();
            r.width = port.getWidth();
            r.height = port.getHeight();
            r.x = p.x;
            r.y = p.y;
        } else { // no viewport
            r.setBounds(component.getVisibleRect());
        }
    }
    return r;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:EditorUI.java

示例2: AtualizaTamanho

import javax.swing.JViewport; //導入方法依賴的package包/類
public void AtualizaTamanho() {
    int pos = alturaTexto;
    if (pos > getHeight()) {
        JViewport jvp = ((JViewport) getParent());

        setSize(jvp.getExtentSize().width, pos + 2);
        setPreferredSize(getSize());

        if (alturaTexto > jvp.getHeight()) {
            jvp.setViewPosition(new Point(espaco, getHeight()));
        }
        repaint();
    }
}
 
開發者ID:chcandido,項目名稱:brModelo,代碼行數:15,代碼來源:MasterCli.java

示例3: mouseClicked

import javax.swing.JViewport; //導入方法依賴的package包/類
@Override
public void mouseClicked(MouseEvent e) {
	if (e.getClickCount() == 2) {
		JTableHeader header = (JTableHeader) e.getSource();
		TableColumn tableColumn = getResizingColumn(header, e.getPoint());

		if (tableColumn == null) {
			return;
		}

		JTable table = header.getTable();

		if ((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) {
			if (table instanceof ExtendedJTable) {
				((ExtendedJTable) table).pack();
				e.consume();
			}
		} else {
			int col = header.getColumnModel().getColumnIndex(tableColumn.getIdentifier());
			int width = (int) header.getDefaultRenderer()
					.getTableCellRendererComponent(table, tableColumn.getIdentifier(), false, false, -1, col)
					.getPreferredSize().getWidth();

			int firstRow = 0;
			int lastRow = table.getRowCount();

			if (table instanceof ExtendedJTable) {
				ExtendedJScrollPane scrollPane = ((ExtendedJTable) table).getExtendedScrollPane();
				if (scrollPane != null) {
					JViewport viewport = scrollPane.getViewport();
					Rectangle viewRect = viewport.getViewRect();
					if (viewport.getHeight() < table.getHeight()) {
						firstRow = table.rowAtPoint(new Point(0, viewRect.y));
						firstRow = Math.max(0, firstRow);
						lastRow = table.rowAtPoint(new Point(0, viewRect.y + viewRect.height - 1));
						lastRow = Math.min(lastRow, table.getRowCount());
					}
				}
			}

			for (int row = firstRow; row < lastRow; row++) {
				int preferedWidth = (int) table.getCellRenderer(row, col)
						.getTableCellRendererComponent(table, table.getValueAt(row, col), false, false, row, col)
						.getPreferredSize().getWidth();
				width = Math.max(width, preferedWidth);
			}
			header.setResizingColumn(tableColumn); // this line is very important
			tableColumn.setWidth(width + table.getIntercellSpacing().width);

			e.consume();
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:54,代碼來源:ExtendedJTableColumnFitMouseListener.java

示例4: packColumn

import javax.swing.JViewport; //導入方法依賴的package包/類
public void packColumn() {
	JTableHeader header = getTableHeader();
	if (header != null) {
		int col = getSelectedColumn();
		if (col >= 0) {
			TableColumn tableColumn = header.getColumnModel().getColumn(col);

			if (tableColumn != null) {
				int width = (int) header.getDefaultRenderer()
						.getTableCellRendererComponent(this, tableColumn.getIdentifier(), false, false, -1, col)
						.getPreferredSize().getWidth();

				int firstRow = 0;
				int lastRow = getRowCount();

				ExtendedJScrollPane scrollPane = getExtendedScrollPane();
				if (scrollPane != null) {
					JViewport viewport = scrollPane.getViewport();
					Rectangle viewRect = viewport.getViewRect();
					if (viewport.getHeight() < getHeight()) {
						firstRow = rowAtPoint(new Point(0, viewRect.y));
						firstRow = Math.max(0, firstRow);
						lastRow = rowAtPoint(new Point(0, viewRect.y + viewRect.height - 1));
						lastRow = Math.min(lastRow, getRowCount());
					}
				}

				for (int row = firstRow; row < lastRow; row++) {
					int preferedWidth = (int) getCellRenderer(row, col)
							.getTableCellRendererComponent(this, getValueAt(row, col), false, false, row, col)
							.getPreferredSize().getWidth();
					width = Math.max(width, preferedWidth);
				}

				header.setResizingColumn(tableColumn); // this line is very important

				tableColumn.setWidth(width + getIntercellSpacing().width);
			}
		}
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:42,代碼來源:ExtendedJTable.java


注:本文中的javax.swing.JViewport.getHeight方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。