本文整理匯總了Java中javax.swing.JViewport.getBounds方法的典型用法代碼示例。如果您正苦於以下問題:Java JViewport.getBounds方法的具體用法?Java JViewport.getBounds怎麽用?Java JViewport.getBounds使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JViewport
的用法示例。
在下文中一共展示了JViewport.getBounds方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTriangle
import javax.swing.JViewport; //導入方法依賴的package包/類
/**
*
* Generates a polygon like this :
*
* /|
* / |
* ----
*
* This triangle represents the triangle for the bottom right corner of the
* viewport.
*
* @return the triangle
*/
private Polygon getTriangle() {
JViewport viewport = getScrollPane().getViewport();
//get bounds of viewport
Rectangle bounds = viewport.getBounds();
//position of viewport relative to text area.
Point viewportPosition = viewport.getViewPosition();
int w = viewportPosition.x + bounds.width;
int h = viewportPosition.y + bounds.height;
int[] xs = {w, w, w - triangleSize};
int[] ys = {h - triangleSize, h, h};
Polygon polygon = new Polygon(xs, ys, 3);
return polygon;
}