List of usage examples for java.awt Dialog pack
@SuppressWarnings("deprecation") public void pack()
From source file:Main.java
public static Window showCentered(Component parent, Window window) { if (null == window) throw new IllegalArgumentException("window null"); if (window instanceof Dialog) { Dialog dialog = (Dialog) window; boolean isResizable = dialog.isResizable(); dialog.setResizable(true);//from w ww .j ava2 s.c o m dialog.pack(); dialog.setResizable(isResizable); } else { window.pack(); } Dimension windowSize = window.getPreferredSize(); int newX; int newY; if (null == parent) { Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); newX = (screen.width - windowSize.width) / 2; newY = (screen.height - windowSize.height) / 2; } else { Dimension parentSize = parent.getSize(); Point loc = parent.getLocation(); newX = (parentSize.width - windowSize.width) / 2 + loc.x; newY = (parentSize.height - windowSize.height) / 2 + loc.y; if (0 > newX) newX = 0; if (0 > newY) newY = 0; } window.setLocation(newX, newY); window.setVisible(true); return window; }
From source file:edu.ku.brc.specify.datamodel.busrules.AttachmentBusRules.java
/** * shows/hides image attribute view based on type of attachment */// w w w .j a v a 2 s . c o m private void setupImageAttributeView() { if (origComp != null) { String fileName = origComp instanceof JTextField ? ((JTextField) origComp).getText() : browser.getValue().toString(); if (fileName != null && !fileName.isEmpty()) { String mimeType = fileName == null ? null : AttachmentUtils.getMimeType(fileName); boolean isImage = mimeType != null && mimeType.startsWith("image"); if (imageAttributeMultiView != null) { imageAttributeMultiView.setVisible(isImage); Dialog dlg = UIHelper.getDialog(imageAttributeMultiView); if (dlg != null) { dlg.pack(); } } } } }