本文整理汇总了Java中javax.swing.JWindow.setLocation方法的典型用法代码示例。如果您正苦于以下问题:Java JWindow.setLocation方法的具体用法?Java JWindow.setLocation怎么用?Java JWindow.setLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JWindow
的用法示例。
在下文中一共展示了JWindow.setLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import javax.swing.JWindow; //导入方法依赖的package包/类
public void show(Point location) {
Rectangle screenBounds = null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
for (GraphicsDevice device : gds) {
GraphicsConfiguration gc = device.getDefaultConfiguration();
screenBounds = gc.getBounds();
if (screenBounds.contains(location)) {
break;
}
}
// showing the popup tooltip
cp = new TooltipContentPanel(master.getTextComponent());
Window w = SwingUtilities.windowForComponent(master.getTextComponent());
contentWindow = new JWindow(w);
contentWindow.add(cp);
contentWindow.pack();
Dimension dim = contentWindow.getSize();
if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
}
if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
}
contentWindow.setSize(dim);
contentWindow.setLocation(location.x, location.y - 1); // slight visual adjustment
contentWindow.setVisible(true);
Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
w.addWindowFocusListener(this);
contentWindow.addWindowFocusListener(this);
}
示例2: show
import javax.swing.JWindow; //导入方法依赖的package包/类
public void show(Point location) {
Rectangle screenBounds = null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
for (GraphicsDevice device : gds) {
GraphicsConfiguration gc = device.getDefaultConfiguration();
screenBounds = gc.getBounds();
if (screenBounds.contains(location)) {
break;
}
}
// showing the popup tooltip
cp = new TooltipContentPanel(master.getTextComponent());
Window w = SwingUtilities.windowForComponent(master.getTextComponent());
contentWindow = new JWindow(w);
contentWindow.add(cp);
contentWindow.pack();
Dimension dim = contentWindow.getSize();
if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
}
if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
}
contentWindow.setSize(dim);
contentWindow.setLocation(location.x, location.y - 1); // slight visual adjustment
contentWindow.setVisible(true);
Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
w.addWindowFocusListener(this);
contentWindow.addWindowFocusListener(this);
}
示例3: SplashScreen
import javax.swing.JWindow; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param parent
* @param isApplet
*/
public SplashScreen(JFrame parent, boolean isApplet) {
this.isApplet = isApplet;
splashLabel = new JLabel(IconsRegistry.getImageIcon("splash.gif"));
if (!isApplet) {
splashScreen = new JWindow(parent);
splashScreen.getContentPane().add(splashLabel);
splashScreen.pack();
Rectangle screenRect = parent.getGraphicsConfiguration()
.getBounds();
splashScreen
.setLocation(screenRect.x + screenRect.width / 2
- splashScreen.getSize().width / 2, screenRect.y
+ screenRect.height / 2
- splashScreen.getSize().height / 2);
}
}
示例4: showSplash
import javax.swing.JWindow; //导入方法依赖的package包/类
public static void showSplash() {
screen = new JWindow();
final URL resource = MainFrame.class.getResource("mpcmaidlogo400_400.png");
final JLabel label = new JLabel(new ImageIcon(resource));
screen.getContentPane().add(label);
screen.setLocationRelativeTo(null);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension labelSize = screen.getPreferredSize();
screen
.setLocation(screenSize.width / 2 - (labelSize.width / 2), screenSize.height / 2
- (labelSize.height / 2));
screen.pack();
screen.setVisible(true);
label.repaint();
screen.repaint();
}
示例5: splashInit
import javax.swing.JWindow; //导入方法依赖的package包/类
public static void splashInit() {
JWindow window = new JWindow();
java.net.URL imgURL = SplashScreen.class.getResource("resources/images/SplashScreen.png");
window.getContentPane().add(
new JLabel("", new ImageIcon(imgURL), SwingConstants.CENTER));
window.setBounds(500, 150, 300, 200);
window.setSize(500, 400);
java.awt.Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
window.setLocation(dim.width/2-window.getSize().width/2, dim.height/2-window.getSize().height/2);
setupAudio();
window.setVisible(true);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
System.out.println("Caught InterrupedException");
}
window.setVisible(false);
window.dispose();
}
示例6: MesquiteFileDialog
import javax.swing.JWindow; //导入方法依赖的package包/类
public MesquiteFileDialog (MesquiteWindow f, String message, int type) {
super(getFrame(f), message, type);
if (type == FileDialog.LOAD && (MesquiteTrunk.isMacOS() || MesquiteTrunk.isMacOSX()) && MesquiteTrunk.getOSXVersion()>10){
titleWindow = new JWindow();
titleWindow.setSize(twWidth,twHeight);
titleWindowLabel = new Label();
titleWindowLabel.setBackground(ColorDistribution.veryLightYellow); //ColorTheme.getExtInterfaceBackground()); //ColorDistribution.veryLightGray
titleWindow.add(titleWindowLabel);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int v, h;
h = (screenSize.width-twWidth)/2;
v = 26;
titleWindow.setLocation(h, v);
titleWindowLabel.setText(" " + message);
// Color darkBlue = new Color((float)0.0, (float)0.0, (float)0.7);
titleWindowLabel.setForeground(ColorDistribution.darkBlue); //ColorTheme.getExtInterfaceElement(true));
}
this.message = message;
this.type = type;
currentFileDialog = this;
//mfdThread = new MFDThread(this);
//mfdThread.start();
MainThread.incrementSuppressWaitWindow();
}
示例7: prepareResources
import javax.swing.JWindow; //导入方法依赖的package包/类
@Override
protected void prepareResources() {
window = new JWindow(SwingUtilities.getWindowAncestor(owner));
window.setType(JWindow.Type.POPUP);
window.getContentPane().add (contents);
window.setLocation (new Point (x, y));
window.pack();
disableShadow(window);
}
示例8: show
import javax.swing.JWindow; //导入方法依赖的package包/类
void show(Point location) {
Rectangle screenBounds = null;
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gds = ge.getScreenDevices();
for (GraphicsDevice device : gds) {
GraphicsConfiguration gc = device.getDefaultConfiguration();
screenBounds = gc.getBounds();
if (screenBounds.contains(location)) {
break;
}
}
// showing the popup tooltip
cp = new TooltipContentPanel();
Window w = SwingUtilities.windowForComponent(parent);
contentWindow = new JWindow(w);
contentWindow.add(cp);
contentWindow.pack();
Dimension dim = contentWindow.getSize();
if (screenBounds.width + screenBounds.x - location.x < cp.longestLine) {
// the whole window does fully not fit to the right
// the x position where the window has to start to fully fit to the right
int left = screenBounds.width + screenBounds.x - cp.longestLine;
// the window should have x pos minimally at the screen's start
location.x = Math.max(screenBounds.x, left);
}
if (location.y + dim.height + SCREEN_BORDER > screenBounds.y + screenBounds.height) {
dim.height = (screenBounds.y + screenBounds.height) - (location.y + SCREEN_BORDER);
}
if (location.x + dim.width + SCREEN_BORDER > screenBounds.x + screenBounds.width) {
dim.width = (screenBounds.x + screenBounds.width) - (location.x + SCREEN_BORDER);
}
contentWindow.setSize(dim);
contentWindow.setLocation(location.x, location.y + 1); // slight visual adjustment
contentWindow.setVisible(true);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
cp.scrollRectToVisible(new Rectangle(1, 1));
}
});
Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.KEY_EVENT_MASK);
w.addWindowFocusListener(this);
contentWindow.addWindowFocusListener(this);
contentWindow.addKeyListener(this);
w.addKeyListener(this);
}
示例9: _initWindow
import javax.swing.JWindow; //导入方法依赖的package包/类
private void _initWindow()
{
Window ancestor = SwingUtilities.getWindowAncestor(_textField);
_win = new JWindow(ancestor);
_win.addWindowFocusListener(_fwl);
_textField.addAncestorListener(_fwl);
ancestor.addMouseListener(_fwl);
_lsl = new ListSelListener();
_lml = new ListMouseListener();
_list = new JList(_lm);
_list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
_list.setFocusable(false);
_list.setPrototypeCellValue("Prototype");
_list.addListSelectionListener(_lsl);
_list.addMouseListener(_lml);
_sp = new JScrollPane(_list,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
_sp.setFocusable(false);
_sp.getVerticalScrollBar().setFocusable(false);
_setWindowHeight();
_win.setLocation(_textField.getLocationOnScreen().x, _textField.getLocationOnScreen().y + _textField.getHeight());
_win.getContentPane().add(_sp);
}
示例10: showProperties
import javax.swing.JWindow; //导入方法依赖的package包/类
public void showProperties(Point p)
{
p = SwingUtilities.convertPoint(page, p, this);
JWindow w = PropertiesPage.generatePropertiesWindow(model);
SwingUtilities.convertPointToScreen(p, this);
w.setLocation(p);
}
示例11: createWindow
import javax.swing.JWindow; //导入方法依赖的package包/类
/**
* Creates the WindowGui
* @param icon
* @param head
* @param body
* @param posx
* @param posy
* @param backgroundcolor
* @param headerColor
* @param messageColor
* @return
*/
private static JWindow createWindow(Icon icon, String head, String body,
int posx, int posy, Color backgroundcolor, Color headerColor, Color messageColor) {
final JWindow window = new JWindow();
JPanel windowpanel = new JPanel(new GridBagLayout());
windowpanel.setBackground(backgroundcolor);
AWTUtilities.setWindowShape(window, new RoundRectangle2D.Float(0, 0,
WIDTH, HEIGHT, 20, 20));
AWTUtilities.setWindowOpaque(window, true);
JLabel text = new JLabel("<HTML>" + body + "</HTML>");
text.setForeground(messageColor);
JLabel header = new JLabel(head);
header.setForeground(headerColor);
header.setFont(new Font(header.getFont().getName(), Font.BOLD, header
.getFont().getSize() + 2));
windowpanel.add(new JLabel(icon), new GridBagConstraints(0, 0, 1, 2, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
windowpanel.add(header, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 0, 5), 0, 0));
windowpanel.add(text, new GridBagConstraints(1, 1, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
window.add(windowpanel);
window.setSize(WIDTH, HEIGHT);
window.setLocation(posx - (WIDTH+5), posy+5);
window.setAlwaysOnTop(true);
return window;
}
示例12: show
import javax.swing.JWindow; //导入方法依赖的package包/类
public void show() {
// Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
// if (focusOwner != null) focusRef = new WeakReference(focusOwner);
owner = ownerRef == null ? null : ownerRef.get();
ownerLocation = owner == null ? null : owner.getLocationOnScreen();
window = new JWindow(owner);
window.setType(Window.Type.POPUP);
window.setAlwaysOnTop(false);
window.setFocusable(true);
window.setFocusableWindowState(true);
window.setAutoRequestFocus(true);
window.getContentPane().add(content);
window.pack();
if (popupAlign == -1) {
window.setLocation(location.getLocation());
} else {
Dimension size = content.getSize();
int x;
switch (popupAlign) {
case SwingConstants.EAST:
case SwingConstants.NORTH_EAST:
case SwingConstants.SOUTH_EAST:
x = location.x + location.width - size.width + 1;
break;
default:
x = location.x + 1;
break;
}
int y;
switch (popupAlign) {
case SwingConstants.NORTH:
case SwingConstants.NORTH_EAST:
case SwingConstants.NORTH_WEST:
y = location.y - size.height + 1;
break;
default:
y = location.y + location.height + 1;
break;
}
window.setLocation(x, y);
}
window.setVisible(true);
Component defaultFocus = content.getFocusTraversalPolicy().getDefaultComponent(content);
if (defaultFocus != null) defaultFocus.requestFocusInWindow();
content.installListeners();
if (listener != null) listener.popupShown();
}
示例13: Main
import javax.swing.JWindow; //导入方法依赖的package包/类
public Main(File []files, Dimension size) {
setBackground(Color.black);
this.files = files;
UserAgentAdapter ua = new UserAgentAdapter();
renderer = new StaticRenderer();
userAgent = ua;
loader = new DocumentLoader(userAgent);
ctx = new BridgeContext(userAgent, loader);
ua.setBridgeContext(ctx);
if (size == null) {
size = Toolkit.getDefaultToolkit().getScreenSize();
}
setPreferredSize(size);
setDoubleBuffered(false);
addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent me) {
if (done)
System.exit(0);
else
togglePause();
}
});
size.width += 2;
size.height += 2;
display = new BufferedImage(size.width, size.height,
BufferedImage.TYPE_INT_BGR);
Thread t = new RenderThread();
t.start();
JWindow w = new JWindow();
w.setBackground(Color.black);
w.getContentPane().setBackground(Color.black);
w.getContentPane().add(this);
w.pack();
w.setLocation(new Point(-1, -1));
w.setVisible(true);
}
示例14: updateLocation
import javax.swing.JWindow; //导入方法依赖的package包/类
protected void updateLocation(JWindow win, Container parent) {
Insets insets =parent.getInsets();
win.setLocation(parent.getLocation().x + insets.left, parent.getLocation().y + insets.top);
}
示例15: createAndShowLoading
import javax.swing.JWindow; //导入方法依赖的package包/类
private static void createAndShowLoading(){
// create loading welcome
JWindow loading = new JWindow();
loading.setAlwaysOnTop(true);
// set backgroud
loading.setBackground(new Color(0, 0, 0, 0));
// set transparent content
loading.setContentPane(new JPanel(){
@Override
public void setOpaque(boolean isOpaque) {
super.setOpaque(false);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
// get g2
Graphics2D g2 = (Graphics2D)g.create();
g2.setComposite(AlphaComposite.SrcOver.derive(0.0f));
g2.setColor(getBackground());
g2.fillRect(0, 0, getWidth(), getHeight());
}
});
JLabel mainLabel = null;
// add the icon
java.net.URL imgURL = WirelessLCDSystem.class.getResource("resource/welcome.png");
if(null != imgURL){
mainLabel = new JLabel(new ImageIcon(imgURL));
loading.add(mainLabel);
}
// set the property location
loading.setLocationRelativeTo(null);
int x = loading.getLocation().x;
int y = loading.getLocation().y;
loading.setLocation(x-400, y-250);
// pack and show
loading.pack();
// show
loading.setVisible(true);
// use a thread to update the logo
(new WelcomeLogo(loading, mainLabel)).execute();
}