本文整理了Java中javax.swing.JWindow.pack()
方法的一些代码示例,展示了JWindow.pack()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JWindow.pack()
方法的具体详情如下:
包路径:javax.swing.JWindow
类名称:JWindow
方法名:pack
暂无
代码示例来源:origin: stackoverflow.com
frame.setContentPane(new TranslucentPane());
frame.add(new JLabel(new ImageIcon(ImageIO.read(getClass().getResource("/Puppy.png")))));
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
代码示例来源:origin: com.jidesoft/jide-oss
public void propertyChange(PropertyChangeEvent evt) {
if (_delegate != null) {
_delegate.pack();
}
}
});
代码示例来源:origin: com.jidesoft/jide-oss
public void add(Component component) {
_component = component;
_component.addPropertyChangeListener("preferredSize", new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (_delegate != null) {
_delegate.pack();
}
}
});
if (_delegate != null) {
_delegate.getContentPane().add(component);
_delegate.pack();
// workaround for a problem. JWindow somehow offset the height by 1
// See http://developer.java.sun.com/developer/bugParade/bugs/4511106.html
// looks like call pack again solve the problem.
_delegate.pack();
// mDelegate.setSize(mDelegate.getSize().width, mDelegate.getSize().height + 1);
}
}
代码示例来源:origin: stackoverflow.com
public class Spot {
public static void main(final String... args) throws IOException {
JWindow f = new JWindow();
f.setContentPane(new JLabel(new ImageIcon(ImageIO.read(new URL(
"http://i.stack.imgur.com/IPgpQ.png")))));
f.pack();
f.setVisible(true);
}
}
代码示例来源:origin: com.eas.platypus/platypus-js-calendar-widget
private void createCalendarWindow(Window aAncestor) {
if (aAncestor != null) {
_calendarWindow = new JCalendarPopupWindow(aAncestor);
} else {
_calendarWindow = new JCalendarPopupWindow();
}
JPanel contentPanel = (JPanel) _calendarWindow.getContentPane();
contentPanel.setLayout(new BorderLayout());
contentPanel.add(_calendarPanel, BorderLayout.CENTER);
_calendarWindow.pack();
}
代码示例来源: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: net.sf.ingenias/editor
public static JWindow showMessageWindow(String message, JWindow parent) {
JWindow jw = new JWindow(parent);
JLabel jl = new JLabel(message);
jl.setFont(new java.awt.Font("Dialog", 1, 36));
jw.getContentPane().add(jl);
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
jw.pack();
jw.setLocation(getCenter(d));
/* jw.setLocation(
d.width / 2 - jw.getSize().width / 2,
d.height / 2 - jw.getSize().height / 2);*/
jw.show();
// This line hangs swing
// jw.toFront();
return jw;
}
代码示例来源:origin: net.sf.ingenias/editor
public void run() {
JLabel jl = new JLabel(message);
jl.setFont(new java.awt.Font("Dialog", 1, 36));
jw.getContentPane().add(jl);
jw.pack();
jw.setLocation(getCenter(jw.getSize(),resources.getMainFrame()));
jw.setVisible(true);
}
});
代码示例来源:origin: org.gephi/ui-components
private void resizePopup() {
popupWindow.pack();
Point point = new Point(0, 0);
SwingUtilities.convertPointToScreen(point, ancestor);
Dimension dim = popupWindow.getSize();
Rectangle usableRect = Utilities.getUsableScreenBounds();
int sepShift = 0;
Point loc = new Point(point.x + ancestor.getSize().width - dim.width - sepShift - 5 * 2, point.y - dim.height - 5);
if (!usableRect.contains(loc)) {
loc = new Point(loc.x, point.y + 5 + ancestor.getSize().height);
}
popupWindow.setLocation(loc);
}
代码示例来源:origin: de.uni_leipzig.asv.toolbox/toolbox-utils
/**
* Show the splash screen while the rest of the program loads
*/
public void createSplashScreen() {
JLabel splashLabel = new JLabel(createImageIcon("Splash3.jpg"));
this.splashScreen = new JWindow();
this.splashScreen.getContentPane().add(splashLabel);
this.splashScreen.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.splashScreen.setLocation(screenSize.width / 2
- this.splashScreen.getSize().width / 2, screenSize.height / 2
- this.splashScreen.getSize().height / 2);
}
代码示例来源:origin: stackoverflow.com
public static void main(String args[]) {
JWindow w = new JWindow();
w.add(new JLabel("Testing a Window!!!!!"));
w.setLocation(300, 300);
w.pack();
w.setVisible(true);
}
代码示例来源:origin: net.sf.ingenias/editor
public static Dimension getSize(String classname, ingenias.editor.entities.ViewPreferences.ViewType kind){
synchronized (renderer) {
helperFrame.getContentPane().removeAll();
if (retrievePanel(classname,kind)==null){
throw new RuntimeException("Error: there is no renderer defined for \""+classname+"\" for the notation "+kind+". Existing renderers are :"+renderer.keySet());
}
helperFrame.getContentPane().add((JPanel)retrievePanel(classname,kind));
helperFrame.pack();
}
return helperFrame.getSize();
}
代码示例来源:origin: stackoverflow.com
ImageIcon icon = new ImageIcon("images/ajax-loader.gif");
JLabel label=new JLabel(icon);
JWindow myJFrame=new JWindow();
myJFrame.setLayout(new BorderLayout());
myJFrame.add(label,BorderLayout.CENTER);
myJFrame.setLocationRelativeTo(null);
myJFrame.setOpacity(0.5f);
myJFrame.setAlwaysOnTop(true);
label.setOpaque(false);
AWTUtilities.setWindowOpaque(myJFrame, false);
myJFrame.pack();
myJFrame.setVisible(true);
代码示例来源:origin: cpesch/RouteConverter
private void display(Point locationOnScreen, int mouseX, int mouseY) {
LatLong latLong = new MapViewProjection(mapView).fromPixels(mouseX, mouseY);
label.setText(mapViewCallback.createCoordinates(latLong.longitude, latLong.latitude));
window.pack();
window.setLocation(locationOnScreen.x + 16, locationOnScreen.y + 15);
show();
}
代码示例来源:origin: GoldenGnu/jeveassets
public void show() {
Point point = jButton.getLocationOnScreen();
jWindow.pack();
jWindow.setLocation(point.x + 2, point.y + jButton.getHeight() - 1);
jWindow.setVisible(true);
}
代码示例来源:origin: org.cytoscape/splash
public void showSplash() {
hideSplash();
JComponent content = new JLabel(image);
window = new JWindow();
window.getContentPane().add(content);
window.pack();
centerWindowLocation(window);
window.setVisible(true);
window.setAlwaysOnTop(true);
content.addMouseListener(new MouseListener() {
public void mouseClicked(MouseEvent e) {
hideSplash();
}
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mousePressed(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
});
}
代码示例来源: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: cpesch/RouteConverter
private void show(String message) {
label.setText(message);
JFrame frame = getFrame();
if(frame == null)
return;
Point locationOnScreen = frame.getLocationOnScreen();
Dimension frameSize = getFrame().getSize();
window.pack();
window.setLocation(locationOnScreen.x + frameSize.width - label.getWidth() - 25,
locationOnScreen.y + frameSize.height - label.getHeight() - 25);
window.setVisible(true);
}
代码示例来源:origin: javax.help/javahelp
/**
* show the window
*/
private void showPopup() {
if (currentPopup != null &&
SwingUtilities.getAncestorOfClass(JWindow.class, invoker) ==
currentPopup.getWindow()) {
setInvoker(currentPopup.getInvoker());
}
Rectangle popupBounds = computePopupBounds(getSize());
jheditor.setPreferredSize(new Dimension(popupBounds.width,
popupBounds.height));
window.setBounds(popupBounds.x, popupBounds.y,
popupBounds.width, popupBounds.height);
window.pack();
window.show();
currentPopup = this;
}
代码示例来源:origin: comtel2000/fx-experience
public void init() {
setLayout(new BorderLayout());
// create javafx panel
final JFXPanel javafxPanel = new JFXPanel();
javafxPanel.setFocusable(false);
javafxPanel.setOpaque(false);
add(javafxPanel, BorderLayout.CENTER);
JWindow fxKeyboard = new JWindow();
fxKeyboard.setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
fxKeyboard.getContentPane().add(javafxPanel);
fxKeyboard.setFocusable(false);
fxKeyboard.setBackground(null);
fxKeyboard.pack();
fxKeyboard.setLocationByPlatform(true);
// create JavaFX scene
Platform.runLater(() -> createScene(javafxPanel));
}
内容来源于网络,如有侵权,请联系作者删除!