本文整理汇总了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;
}