本文整理了Java中javax.swing.JWindow.getWidth()
方法的一些代码示例,展示了JWindow.getWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JWindow.getWidth()
方法的具体详情如下:
包路径:javax.swing.JWindow
类名称:JWindow
方法名:getWidth
暂无
代码示例来源:origin: google/sagetv
private static void splash()
{
splashWindow = new javax.swing.JWindow();
splashWindow.getContentPane().setLayout(new java.awt.BorderLayout());
java.awt.Image theImage = java.awt.Toolkit.getDefaultToolkit().createImage(MiniClient.class.getClassLoader().getResource("images/splash.gif"));
GFXCMD2.ensureImageIsLoaded(theImage);
javax.swing.JLabel splashImage = new javax.swing.JLabel(new javax.swing.ImageIcon(theImage));
splashWindow.getContentPane().add(splashImage, "Center");
java.awt.Dimension scrSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
splashWindow.pack();
java.awt.Point center = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
splashWindow.setLocation(center.x - splashWindow.getWidth()/2, center.y - splashWindow.getHeight()/2);
splashWindow.setVisible(true);
}
代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit
@Override
public synchronized void paintComponent(Graphics g)
{
Dimension size = getSize();
g.setColor(Color.black);
g.drawRect(0,0,size.width - 1,size.height - 1);
g.drawImage(image,1,1,this);
// XXX: This should not be hardcoded
g.setColor(Color.white);
g.fillRect(1,image.getHeight(this) + 1,
((win.getWidth() - 2) * progress) / PROGRESS_COUNT, PROGRESS_HEIGHT);
g.setColor(Color.black);
if (label != null)
{
int drawOffsetX = (getWidth() - fm.stringWidth(label)) / 2;
int drawOffsetY = image.getHeight(this) + (PROGRESS_HEIGHT
+ fm.getAscent() + fm.getDescent()) / 2;
paintString(g, label, drawOffsetX, drawOffsetY);
}
String version = "version " + jEdit.getVersion();
int drawOffsetX = (getWidth() / 2) - (fm.stringWidth(version) / 2);
int drawOffsetY = image.getHeight(this) - fm.getDescent() - 2;
paintString(g, version, drawOffsetX, drawOffsetY);
notify();
} //}}}
代码示例来源:origin: com.fifesoft/autocomplete
/**
* Sets the location of this tool tip relative to the given rectangle.
*
* @param r The visual position of the caret (in screen coordinates).
*/
public void setLocationRelativeTo(Rectangle r) {
// Multi-monitor support - make sure the completion window (and
// description window, if applicable) both fit in the same window in
// a multi-monitor environment. To do this, we decide which monitor
// the rectangle "r" is in, and use that one (just pick top-left corner
// as the defining point).
Rectangle screenBounds = Util.getScreenBoundsForPoint(r.x, r.y);
//Dimension screenSize = tooltip.getToolkit().getScreenSize();
// Try putting our stuff "above" the caret first.
int y = r.y - 5 - tooltip.getHeight();
if (y<0) {
y = r.y + r.height + 5;
}
// Get x-coordinate of completions. Try to align left edge with the
// caret first.
int x = r.x;
if (x<screenBounds.x) {
x = screenBounds.x;
}
else if (x+tooltip.getWidth()>screenBounds.x+screenBounds.width) { // completions don't fit
x = screenBounds.x + screenBounds.width - tooltip.getWidth();
}
tooltip.setLocation(x, y);
}
代码示例来源:origin: google/sagetv
public void run()
{
Rectangle screenRect = getScreenArea0();
poppy.setLocation(Math.min(screenRect.x + screenRect.width - poppy.getWidth(),
Math.max(mouseX, screenRect.x)), Math.min(screenRect.y + screenRect.height - poppy.getHeight(),
Math.max(mouseY, screenRect.y)));
poppy.setVisible(true);
poppy.toFront();
poppy.repaint();
}
});
代码示例来源:origin: stackoverflow.com
int x = screenSize.width - newWin.getWidth();
int y = screenSize.height - taskBar - newWin.getHeight();
newWin.setLocation(x,y);
代码示例来源:origin: chatty/chatty
int prevWidth = infoWindow.getWidth();
|| prevWidth != infoWindow.getWidth()) {
newPosition = true;
location.x -= infoWindow.getWidth() / 4;
if (location.x + infoWindow.getWidth() > textField.getWidth()) {
location.x = textField.getWidth() - infoWindow.getWidth();
} else if (location.x < 8) {
location.x = 8;
代码示例来源:origin: GoldenGnu/jeveassets
public void show(final String text, final LockWorker lockWorker) {
jLabel.setText(text);
jWindow.pack();
//Get the parent size
Dimension parentSize = parent.getSize();
//Calculate the frame location
int x = (parentSize.width - jWindow.getWidth()) / 2;
int y = (parentSize.height - jWindow.getHeight()) / 2;
//Set the new frame location
jWindow.setLocation(x, y);
jWindow.setLocationRelativeTo(parent);
parent.setEnabled(false);
jProgress.setIndeterminate(false);
jProgress.setIndeterminate(true);
jWindow.setVisible(true); //Does not block!
Wait wait = new Wait(lockWorker);
wait.execute();
}
代码示例来源:origin: stackoverflow.com
if (x + popup.getWidth() > bounds.x + bounds.width) {
x = (bounds.x + bounds.width) - popup.getWidth();
if (y + popup.getWidth() > bounds.y + bounds.height) {
y = (bounds.y + bounds.height) - popup.getHeight();
代码示例来源:origin: undera/jmeter-plugins
private synchronized void showHoverInfo() {
if (isPreview
|| chartRect.width == 0 || chartRect.height == 0
|| xHoverInfo == -1 || yHoverInfo == -1) {
return;
}
long realX = minXVal + (maxXVal - minXVal) * (xHoverInfo - chartRect.x) / chartRect.width;
double realY = minYVal + (maxYVal - minYVal) * (chartRect.height - yHoverInfo + chartRect.y) / chartRect.height;
xAxisLabelRenderer.setValue(realX);
yAxisLabelRenderer.setValue(realY);
String hoverInfo = "(" + xAxisLabelRenderer.getText() + " ; " + yAxisLabelRenderer.getText() + ")";
hoverLabel.setText(hoverInfo);
int labelWidth = hoverLabel.getPreferredSize().width + 5;
int labelHeight = hoverLabel.getPreferredSize().height;
if (hoverWindow.getWidth() < labelWidth || hoverWindow.getHeight() < labelHeight) {
hoverWindow.setSize(labelWidth, labelHeight);
}
Point mousePos = MouseInfo.getPointerInfo().getLocation();
int hoverWindowX = mousePos.x + hoverGap;
int hoverWindowY = mousePos.y + hoverGap;
//we move window only if far from pointer to limit cpu
double deltaX = Math.abs(hoverWindow.getLocation().getX() - hoverWindowX);
double deltaY = Math.abs(hoverWindow.getLocation().getY() - hoverWindowY);
if (forceHoverPosition || deltaX >= hoverGap || deltaY >= hoverGap) {
//prevent out of screen
int correctedX = Math.min(hoverWindowX, Toolkit.getDefaultToolkit().getScreenSize().width - hoverWindow.getSize().width);
hoverWindow.setLocation(correctedX, hoverWindowY);
forceHoverPosition = false;
}
}
代码示例来源:origin: kg.apc/jmeter-plugins-cmn-jmeter
private synchronized void showHoverInfo() {
if (isPreview
|| chartRect.width == 0 || chartRect.height == 0
|| xHoverInfo == -1 || yHoverInfo == -1) {
return;
}
long realX = minXVal + (maxXVal - minXVal) * (xHoverInfo - chartRect.x) / chartRect.width;
double realY = minYVal + (maxYVal - minYVal) * (chartRect.height - yHoverInfo + chartRect.y) / chartRect.height;
xAxisLabelRenderer.setValue(realX);
yAxisLabelRenderer.setValue(realY);
String hoverInfo = "(" + xAxisLabelRenderer.getText() + " ; " + yAxisLabelRenderer.getText() + ")";
hoverLabel.setText(hoverInfo);
int labelWidth = hoverLabel.getPreferredSize().width + 5;
int labelHeight = hoverLabel.getPreferredSize().height;
if (hoverWindow.getWidth() < labelWidth || hoverWindow.getHeight() < labelHeight) {
hoverWindow.setSize(labelWidth, labelHeight);
}
Point mousePos = MouseInfo.getPointerInfo().getLocation();
int hoverWindowX = mousePos.x + hoverGap;
int hoverWindowY = mousePos.y + hoverGap;
//we move window only if far from pointer to limit cpu
double deltaX = Math.abs(hoverWindow.getLocation().getX() - hoverWindowX);
double deltaY = Math.abs(hoverWindow.getLocation().getY() - hoverWindowY);
if (forceHoverPosition || deltaX >= hoverGap || deltaY >= hoverGap) {
//prevent out of screen
int correctedX = Math.min(hoverWindowX, Toolkit.getDefaultToolkit().getScreenSize().width - hoverWindow.getSize().width);
hoverWindow.setLocation(correctedX, hoverWindowY);
forceHoverPosition = false;
}
}
代码示例来源:origin: otros-systems/otroslogviewer
private void setSuggestionWindowLocation() {
if (textComponent.isShowing()){
suggestionWindow.pack();
if (textComponent instanceof JTextField) {
int width = Math.max(textComponent.getWidth(), suggestionWindow.getWidth());
int screenHeight = suggestionWindow.getGraphicsConfiguration().getDevice().getDisplayMode().getHeight();
suggestionWindow.setSize(width, (int) Math.min(suggestionWindow.getHeight(), screenHeight / 2));
int x = (int) textComponent.getLocationOnScreen().getX();
int y = (int) (textComponent.getLocationOnScreen().getY() + textComponent.getHeight());
suggestionWindow.setLocation(x, y);
} else {
try {
final int caretPosition = Math.min(textComponent.getText().length(), textComponent.getCaretPosition());
final Rectangle rectangle = textComponent.modelToView(caretPosition);
final Point p = new Point(rectangle.x, rectangle.y + rectangle.height);
SwingUtilities.convertPointToScreen(p, textComponent);
suggestionWindow.setLocation(p.x, p.y);
} catch (BadLocationException e) {
e.printStackTrace();
}
}
}
}
代码示例来源:origin: fcrepo3/fcrepo
splashScreen.getContentPane().add(splashPicAndText);
splashScreen.pack();
int xSize = splashScreen.getWidth();
int ySize = splashScreen.getHeight();
Dimension screenSize = getToolkit().getScreenSize();
代码示例来源:origin: com.eas.platypus/platypus-js-calendar-widget
if (x + _calendarWindow.getWidth() > screenSize.width) {
x = screenSize.width - _calendarWindow.getWidth();
_calendarWindow.setBounds(x, y, _calendarWindow.getWidth(),
_calendarWindow.getHeight());
_calendarWindow.setVisible(true);
代码示例来源:origin: com.fifesoft.rtext/fife.common
if (popupWindow.getWidth()!=getWidth()) {
updatePopupWindowDimensions();
popupWindow.pack();
代码示例来源:origin: net.java.dev.laf-widget/laf-widget
currTabPreviewInfo.tabPane = this.currTabbedPane;
currTabPreviewInfo.tabIndexToPreview = this.currTabIndex;
currTabPreviewInfo.setPreviewWidth(this.currTabWindow.getWidth() - 4);
currTabPreviewInfo.setPreviewHeight(this.currTabWindow.getHeight() - 20);
currTabPreviewInfo.previewCallback = new TabPagerPreviewCallback(
prevTabPreviewInfo.tabPane = this.currTabbedPane;
prevTabPreviewInfo.tabIndexToPreview = this.prevTabIndex;
prevTabPreviewInfo.setPreviewWidth(this.prevTabWindow.getWidth() - 4);
prevTabPreviewInfo.setPreviewHeight(this.prevTabWindow.getHeight() - 20);
prevTabPreviewInfo.previewCallback = new TabPagerPreviewCallback(
nextTabPreviewInfo.tabPane = this.currTabbedPane;
nextTabPreviewInfo.tabIndexToPreview = this.nextTabIndex;
nextTabPreviewInfo.setPreviewWidth(this.nextTabWindow.getWidth() - 4);
nextTabPreviewInfo.setPreviewHeight(this.nextTabWindow.getHeight() - 20);
nextTabPreviewInfo.previewCallback = new TabPagerPreviewCallback(
内容来源于网络,如有侵权,请联系作者删除!