本文整理了Java中javax.swing.JPanel.getBounds()
方法的一些代码示例,展示了JPanel.getBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JPanel.getBounds()
方法的具体详情如下:
包路径:javax.swing.JPanel
类名称:JPanel
方法名:getBounds
暂无
代码示例来源:origin: graphhopper/graphhopper
@Override
protected void paintComponent(Graphics g) {
g.setColor(Color.WHITE);
Rectangle b = infoPanel.getBounds();
g.fillRect(0, 0, b.width, b.height);
g.setColor(Color.BLUE);
g.drawString(latLon, 40, 20);
g.drawString("scale:" + mg.getScaleX(), 40, 40);
int w = mainPanel.getBounds().width;
int h = mainPanel.getBounds().height;
g.drawString(mg.setBounds(0, w, 0, h).toLessPrecisionString(), 40, 60);
}
};
代码示例来源:origin: stackoverflow.com
public JPanel getPanelColliding(JPanel dragPanel, JPanel[] panels)
{
Rectangle rDrag = dragPanel.getBounds();
for (JPanel panel : panels){
if (panel == dragPanel) continue;
Rectangle r = panel.getBounds();
if (r.insersects(rDrag))
return r;
}
return null;
}
代码示例来源:origin: com.eas.platypus/platypus-js-scalable-widget
@Override
public Rectangle getBounds() {
Rectangle lrt = super.getBounds();
lrt.height = Math.round(lrt.height * scale);
lrt.width = Math.round(lrt.width * scale);
return lrt;
}
代码示例来源:origin: com.eas.platypus/platypus-js-scalable-widget
@Override
public Rectangle getBounds(Rectangle rv) {
Rectangle lrt = super.getBounds(rv);
lrt.height = Math.round(lrt.height * scale);
lrt.width = Math.round(lrt.width * scale);
return lrt;
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
public void colorPanel(int r, int g, int b) {
if(graphics != null) {
red=r;
green=g;
blue=b;
graphics.setColor(new Color(red, green, blue));
Rectangle bounds=panel.getBounds();
graphics.fillRect(0, 0, bounds.width, bounds.height);
graphics.setColor(default_color);
}
}
代码示例来源:origin: org.jgroups/com.springsource.org.jgroups
public void clearPanel() {
Rectangle bounds=null;
if(panel == null || graphics == null)
return;
bounds=panel.getBounds();
graphics.clearRect(0, 0, bounds.width, bounds.height);
}
代码示例来源:origin: net.sf.taverna.t2.ui-exts/perspective-biocatalogue
public void run() {
expandRect = jlExpand.getBounds();
expandRect.x -= Math.abs(thisPanel.getBounds().x);
}
});
代码示例来源:origin: robo-code/robocode
/**
* Rather than use a layout manager for the battleview panel, we just
* calculate the proper aspect ratio and set the battleview's size. We could
* use a layout manager if someone wants to write one...
*/
private void battleViewPanelResized() {
battleView.setBounds(getBattleViewPanel().getBounds());
}
代码示例来源:origin: aterai/java-swing-tips
protected void initPanel() {
panel.setVisible(!panel.isVisible());
label.setText(String.format("%s %s", panel.isVisible() ? "△" : "▼", title));
revalidate();
// fireExpansionEvent();
EventQueue.invokeLater(() -> panel.scrollRectToVisible(panel.getBounds()));
}
代码示例来源:origin: edu.toronto.cs.medsavant/mfiume-component-transition
static BufferedImage getImageFromSource(JPanel source, Dimension dim) {
int width = dim.width;
int height = dim.height;
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics g = image.createGraphics();
Rectangle originalBounds = source.getBounds();
source.setBounds(0, 0, width, height);
source.updateUI();
source.paint(g);
source.setBounds(originalBounds);
g.dispose();
return image;
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public void doLayout() {
super.doLayout();
if (searchpanel != null && searchpanel.isDisplayable()) {
Rectangle visibleRect = getVisibleRect();
int width = Math.min (
getPreferredSize ().width - SEARCH_FIELD_SPACE * 2,
SEARCH_FIELD_PREFERRED_SIZE - SEARCH_FIELD_SPACE);
searchpanel.setBounds(
Math.max (SEARCH_FIELD_SPACE,
visibleRect.x + visibleRect.width - width),
visibleRect.y + SEARCH_FIELD_SPACE,
Math.min (visibleRect.width, width) - SEARCH_FIELD_SPACE,
heightOfTextField);
System.err.println("Laid out search field: " + searchpanel.getBounds());
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public void doLayout() {
super.doLayout();
if (searchpanel != null && searchpanel.isDisplayable()) {
Rectangle visibleRect = getVisibleRect();
int width = Math.min (
getPreferredSize ().width - SEARCH_FIELD_SPACE * 2,
SEARCH_FIELD_PREFERRED_SIZE - SEARCH_FIELD_SPACE);
searchpanel.setBounds(
Math.max (SEARCH_FIELD_SPACE,
visibleRect.x + visibleRect.width - width),
visibleRect.y + SEARCH_FIELD_SPACE,
Math.min (visibleRect.width, width) - SEARCH_FIELD_SPACE,
heightOfTextField);
System.err.println("Laid out search field: " + searchpanel.getBounds());
}
}
代码示例来源:origin: in.jlibs/org-netbeans-swing-outline
/**
* Removes the search field from the table.
*/
private void removeSearchField() {
if (searchPanel.isDisplayable()) {
remove(searchPanel);
Rectangle r = searchPanel.getBounds();
this.repaint(r);
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-j2ee-sun-ddui
/** Enables to place this dialog in the middle of the given panel.
* @param panel where the dialog should be placed
*/
protected void setLocationInside(JPanel panel) {
java.awt.Rectangle rect = this.getBounds();
int width = rect.width;
int height = rect.height;
java.awt.Rectangle panelRect = panel.getBounds();
if (width > panelRect.width || height > panelRect.height) {
setLocationRelativeTo(panel);
} else {
java.awt.Point location = panel.getLocationOnScreen();
setLocation(location.x + (panelRect.width - width) / 2,
location.y + (panelRect.height - height) / 2);
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/**
* Removes the search field from the tree.
*/
private void removeSearchField() {
if (searchpanel.isDisplayable ()) {
remove(searchpanel);
TreeView.this.getViewport().setScrollMode(originalScrollMode);
Rectangle r = searchpanel.getBounds();
this.repaint(r);
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/**
* Removes the search field from the tree.
*/
private void removeSearchField() {
if (searchpanel.isDisplayable ()) {
remove(searchpanel);
TreeView.this.getViewport().setScrollMode(originalScrollMode);
Rectangle r = searchpanel.getBounds();
this.repaint(r);
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/**
* Removes the search field from the tree.
*/
private void removeSearchField() {
if (searchpanel != null && searchpanel.isDisplayable()) {
remove(searchpanel);
ListView.this.getViewport().setScrollMode(originalScrollMode);
this.repaint(searchpanel.getBounds());
requestFocus();
}
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
/**
* Removes the search field from the tree.
*/
private void removeSearchField() {
if ((searchpanel != null) && searchpanel.isDisplayable()) {
remove(searchpanel);
ListView.this.getViewport().setScrollMode(originalScrollMode);
this.repaint(searchpanel.getBounds());
requestFocus();
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/**
* Removes the search field from the tree.
*/
private void removeSearchField() {
if (searchpanel != null && searchpanel.isDisplayable()) {
remove(searchpanel);
ListView.this.getViewport().setScrollMode(originalScrollMode);
this.repaint(searchpanel.getBounds());
requestFocus();
}
}
代码示例来源:origin: uk.co.caprica/vlcj
private void syncVideoSurface() {
if (frame.isVisible()) {
// We re-size and re-position to the reference panel contained within the frame rather than the frame
// itself, this makes it easy to add other UI elements without worrying about calculating the correct size
// and position for the video surface ourselves - the referencePanel is in effect a "proxy" for the video
// surface
referencePanel.getBounds(bounds);
bounds.setLocation(referencePanel.getLocationOnScreen());
window.setBounds(bounds);
}
}
内容来源于网络,如有侵权,请联系作者删除!