本文整理汇总了Java中javax.swing.JWindow.setSize方法的典型用法代码示例。如果您正苦于以下问题:Java JWindow.setSize方法的具体用法?Java JWindow.setSize怎么用?Java JWindow.setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JWindow
的用法示例。
在下文中一共展示了JWindow.setSize方法的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: init
import javax.swing.JWindow; //导入方法依赖的package包/类
public static void init( Window applicationWindow ) {
if ( inited ) {
throw new RuntimeException( "Multiple inits." );
}
// System.out.println( "Setting repaintManagerPhet." );
RepaintManager.setCurrentManager( repaintManagerPhet );
offscreen = new JWindow( applicationWindow ) {
public void invalidate() {
}
public void paint( Graphics g ) {
}
}; //this seems to work. I thought you might have needed a visible component, though (maybe for some JVM implementations?)
// System.out.println( "offscreen.getOwner() = " + offscreen.getOwner() );
// offscreen.getOwner().setVisible( true );
offscreen.setSize( 0, 0 );
offscreen.setVisible( true );
offscreenContentPane.setOpaque( false );
offscreen.setContentPane( offscreenContentPane );
inited = true;
}
示例4: SwingSplashScreen
import javax.swing.JWindow; //导入方法依赖的package包/类
SwingSplashScreen(BufferedImage image, int width, int height) {
window = new JWindow((Window) null);
window.setBackground(new Color(0, 0, 0, 0));
window.setSize(width, height);
window.setLocationRelativeTo(null);
// alwaysOnTop keeps the LWJGL2 Display window from popping up and it can't be triggered manually
// window.setAlwaysOnTop(true);
window.add(new Component() {
private static final long serialVersionUID = 1717818903226627606L;
@Override
public void paint(Graphics g) {
if (image != null) {
g.drawImage(image, 0, 0, width, height, null);
}
for (Overlay overlay : getOverlays()) {
overlay.render((Graphics2D) g);
}
}
});
window.setVisible(true);
}
示例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: 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);
}
示例8: start
import javax.swing.JWindow; //导入方法依赖的package包/类
/** Start the bot. */
public void start() {
Toolkit tk = Toolkit.getDefaultToolkit();
int xSize = ((int) tk.getScreenSize().getWidth());
int ySize = ((int) tk.getScreenSize().getHeight());
window = new JWindow();
window.setSize(xSize, ySize);
window.setOpacity(0.0f);
window.setVisible(true);
window.setAlwaysOnTop(true);
window.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (clicks < _numberOfLocations) {
location[clicks] = getLocation();
window.setVisible(false);
sleep();
click();
sleep();
window.setVisible(true);
sleep();
clicks += 1;
}
if (clicks == _numberOfLocations) {
window.setVisible(false);
process();
}
}
});
}
示例9: main
import javax.swing.JWindow; //导入方法依赖的package包/类
public static void main(String[] args) {
Robot r = Util.createRobot();
JWindow w = new JWindow();
w.setSize(100, 100);
w.setVisible(true);
Util.waitForIdle(r);
final JPopupMenu menu = new JPopupMenu();
JButton item = new JButton("A button in popup");
menu.add(item);
w.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent me) {
menu.show(me.getComponent(), me.getX(), me.getY());
System.out.println("Showing menu at " + menu.getLocationOnScreen() +
" isVisible: " + menu.isVisible() +
" isValid: " + menu.isValid());
}
});
Util.clickOnComp(w, r);
Util.waitForIdle(r);
if (!menu.isVisible()) {
throw new RuntimeException("menu was not shown");
}
menu.hide();
System.out.println("Test passed.");
}
示例10: showSplashWindow
import javax.swing.JWindow; //导入方法依赖的package包/类
/**
* <p>Displays a splash window for <code>duration</code> milliseconds displaying the specified <code>image</code>.
* An optional <code>actionListener</code> can be attached to perform a function after the splash window has
* closed. If null is specified then the default listener will be used.</p>
*
* @param image
* - the image icon to display
* @param duration
* - how long to show the window (milliseconds)
* @param windowSize
* - the size of the window
* @param frameOwner
* - the parent window or owner, null if none
* @param actionListener
* - a custom actionListener to be performed after the splash window is closed
*/
public static void showSplashWindow(ImageIcon image, int duration, Dimension windowSize, Window frameOwner, ActionListener actionListener) {
JLabel splashImage = new JLabel();
splashImage.setHorizontalAlignment(JLabel.CENTER);
splashImage.setOpaque(true);
splashImage.setIcon(image);
final JWindow window = new JWindow(frameOwner);
window.add(splashImage, BorderLayout.CENTER);
window.setSize(windowSize);
splashImage.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
UITool.center(window);
window.setVisible(true);
ActionListener defaultActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
window.setVisible(false);
window.dispose();
}
};
Timer timer = new Timer(duration, defaultActionListener);
if(actionListener != null) {
timer.addActionListener(actionListener);
}
timer.setRepeats(false);
timer.start();
}
示例11: initializeSlider
import javax.swing.JWindow; //导入方法依赖的package包/类
private void initializeSlider(TopicMapGraphPanel gp) {
int minValue = getMinValue(gp);
int maxValue = getMaxValue(gp);
int defaultValue = getDefaultValue(gp);
if(defaultValue < minValue) defaultValue = minValue;
if(defaultValue > maxValue) defaultValue = maxValue;
slider = new SimpleSlider(SimpleSlider.HORIZONTAL, minValue, maxValue, defaultValue);
sliderLabel = new SimpleLabel();
sliderPopup = new JWindow();
slider.setPreferredSize(new Dimension(120, 24));
slider.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
sliderLabel.setFont(UIConstants.smallButtonLabelFont);
sliderLabel.setPreferredSize(new Dimension(30, 24));
sliderLabel.setHorizontalAlignment(SimpleLabel.CENTER);
JPanel panel = new JPanel();
panel.setBorder(new LineBorder(UIConstants.defaultBorderShadow));
panel.setLayout(new BorderLayout(2,2));
panel.add(slider, BorderLayout.CENTER);
panel.add(sliderLabel, BorderLayout.EAST);
sliderPopup.setLayout(new BorderLayout(2,2));
sliderPopup.add(panel, BorderLayout.CENTER);
sliderPopup.setSize(150, 24);
// sliderPopup.addMouseListener(this);
sliderPopup.setAlwaysOnTop(true);
slider.addChangeListener(this);
slider.addMouseListener(this);
}
示例12: LoadingScreen
import javax.swing.JWindow; //导入方法依赖的package包/类
public LoadingScreen(int nbSteps, int minTime){
this.minTime = minTime;
this.nombreEtapes = nbSteps;
etapeActuelle = 0;
frmPrincipale = new JWindow();
frmPrincipale.setSize(400, 260);
JPanel pnlChargement = new JPanel(new BorderLayout());
pgbChargement = new JProgressBar();
pgbChargement.setValue(0);
jtMessage = new JLabel();
jtMessage.setHorizontalAlignment(SwingConstants.CENTER);
SplashImage image = new SplashImage();
frmPrincipale.add(image);
pnlChargement.add(jtMessage,BorderLayout.NORTH);
pnlChargement.add(pgbChargement,BorderLayout.SOUTH);
frmPrincipale.add(pnlChargement,BorderLayout.SOUTH);
frmPrincipale.setLocationRelativeTo(null);
frmPrincipale.setVisible(true);
startTime = System.currentTimeMillis();
}
示例13: 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;
}
示例14: updateSize
import javax.swing.JWindow; //导入方法依赖的package包/类
protected void updateSize(JWindow win, Container parent) {
Insets insets =parent.getInsets();
win.setSize(parent.getSize().width - insets.left - insets.right, parent.getSize().height - insets.top - insets.bottom);
}
示例15: Splash
import javax.swing.JWindow; //导入方法依赖的package包/类
public Splash() {
splashImg = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/de/rub/dez6a3/jpdfsigner/resources/images/jpdfsignersplash12.png"));
ImageIcon splashImgIcon = new ImageIcon(splashImg);
splashWidth = splashImgIcon.getIconWidth();
splashHeight = splashImgIcon.getIconHeight();
bufferedImage = new BufferedImage(splashWidth, splashHeight, BufferedImage.TYPE_INT_RGB);
bg = (Graphics2D) bufferedImage.getGraphics();
bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
bg.setFont(new Font("Arial", Font.PLAIN, 9));
splashFrame = new JWindow() {
@Override
public void paint(Graphics g) {
bg.drawImage(splashImg, 0, 0, this);
bg.setColor(new Color(0, 0, 0, 50));
bg.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
int x = 27;
int y = 105;
int width = ((splashWidth - (x * 2)) * percentBar) / 100;
int height = 7;
if (percentBar == 100) {
loadingMessage = LanguageFactory.getText(LanguageFactory.SPLASH_LOADING_DONE);
}
bg.setColor(new Color(150, 150, 150));
bg.drawString(loadingMessage, x, 205);
if (percentBar < 0) {
percentBar = 0;
}
if (percentBar > 100) {
percentBar = 100;
}
bg.setColor(new Color(210, 210, 210));
bg.fillRoundRect(x, y, getWidth() - (x * 2), height, 8, 8);
bg.setColor(Color.white);
bg.fillRoundRect(x + 1, y + 1, (getWidth() - (x * 2)) - 2, height - 2, 7, 7);
bg.setColor(new Color(255, 0, 0, 40));
bg.fillRoundRect(x + 2, y + 2, width - 4, height - 4, 6, 6);
g.drawImage(bufferedImage, 0, 0, this);
graphicsInit = true;
}
};
Dimension splashDimension = new Dimension(splashWidth, splashHeight);
splashFrame.setSize(splashDimension);
splashFrame.setPreferredSize(splashDimension);
splashFrame.setLocationRelativeTo(null);
}