本文整理匯總了Java中java.awt.Window.pack方法的典型用法代碼示例。如果您正苦於以下問題:Java Window.pack方法的具體用法?Java Window.pack怎麽用?Java Window.pack使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.Window
的用法示例。
在下文中一共展示了Window.pack方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: repackWindow
import java.awt.Window; //導入方法依賴的package包/類
/**
* Repacks the window
*/
private void repackWindow() {
Window window = SwingUtilities.getWindowAncestor(this);
if (window != null) {
window.pack();
window.setLocationRelativeTo(null);
}
}
示例2: main
import java.awt.Window; //導入方法依賴的package包/類
public static void main(final String[] args) {
final GraphicsEnvironment lge = getLocalGraphicsEnvironment();
final GraphicsDevice dev = lge.getDefaultScreenDevice();
final GraphicsConfiguration config = dev.getDefaultConfiguration();
test(config.createCompatibleImage(10, 10).getGraphics());
test(config.createCompatibleImage(10, 10, OPAQUE).getGraphics());
test(config.createCompatibleImage(10, 10, BITMASK).getGraphics());
test(config.createCompatibleImage(10, 10, TRANSLUCENT).getGraphics());
test(new BufferedImage(10, 10, TYPE_INT_ARGB).getGraphics());
final Window frame = new Frame();
frame.pack();
try {
test(frame.getGraphics());
test(frame.createImage(10, 10).getGraphics());
} finally {
frame.dispose();
}
}
示例3: updateVisibility
import java.awt.Window; //導入方法依賴的package包/類
private void updateVisibility() {
// boolean advancedVisible = advancedInput.booleanValue().booleanValue();
advancedInput.getControls().setVisible(!destInput.getValue().equals(DEST_GRIDLOCATION));
boolean advancedVisible = advancedInput.booleanValue().booleanValue()
&& advancedInput.getControls().isVisible();
xIndexInput.getControls().setVisible(advancedVisible);
xOffsetInput.getControls().setVisible(advancedVisible);
yIndexInput.getControls().setVisible(advancedVisible);
yOffsetInput.getControls().setVisible(advancedVisible);
String destOption = destInput.getValueString();
xInput.getControls().setVisible(destOption.equals(DEST_LOCATION));
yInput.getControls().setVisible(destOption.equals(DEST_LOCATION));
mapControls.setVisible(!destOption.equals(DEST_COUNTER));
boardControls.setVisible(destOption.equals(DEST_LOCATION)
|| destOption.equals(DEST_GRIDLOCATION));
zoneInput.getControls().setVisible(destOption.equals(DEST_ZONE));
regionInput.getControls().setVisible(destOption.equals(DEST_REGION));
propertyInput.getControls().setVisible(destOption.equals(DEST_COUNTER));
gridLocationInput.getControls().setVisible(destOption.equals(DEST_GRIDLOCATION));
Window w = SwingUtilities.getWindowAncestor(controls);
if (w != null) {
w.pack();
}
}
示例4: updateVisibility
import java.awt.Window; //導入方法依賴的package包/類
private void updateVisibility() {
final boolean isLoop = loopConfig.booleanValue().booleanValue();
final boolean isIndex = indexConfig.booleanValue().booleanValue();
final String type = LoopControl.loopDescToType(loopTypeConfig.getValueString());
loopTypeConfig.getControls().setVisible(isLoop);
loopCountConfig.getControls().setVisible(
isLoop && type.equals(LoopControl.LOOP_COUNTED));
whileExpressionConfig.getControls().setVisible(
isLoop && type.equals(LoopControl.LOOP_WHILE));
untilExpressionConfig.getControls().setVisible(
isLoop && type.equals(LoopControl.LOOP_UNTIL));
preLoopKeyConfig.getControls().setVisible(isLoop);
postLoopKeyConfig.getControls().setVisible(isLoop);
indexConfig.getControls().setVisible(isLoop);
indexPropertyConfig.getControls().setVisible(isLoop && isIndex);
indexStartConfig.getControls().setVisible(isLoop && isIndex);
indexStepConfig.getControls().setVisible(isLoop && isIndex);
Window w = SwingUtilities.getWindowAncestor(box);
if (w != null) {
w.pack();
}
}
示例5: packIfNotMaximized
import java.awt.Window; //導入方法依賴的package包/類
static void packIfNotMaximized(Window window) {
// window peut être null lors de l'initialisation
if (window instanceof Frame
&& (((Frame) window).getExtendedState() & Frame.MAXIMIZED_BOTH) == 0) {
window.pack();
}
}
示例6: propertyChange
import java.awt.Window; //導入方法依賴的package包/類
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getSource() == currentPanel) {
if ("contentLoaded".equals(evt.getPropertyName())) { // NOI18N
Window w = SwingUtilities.getWindowAncestor(this);
if (w != null) {
w.pack();
}
}
}
}
示例7: show
import java.awt.Window; //導入方法依賴的package包/類
private void show(Window window, String command) {
JButton button = new JButton(command);
button.setActionCommand(command);
button.addActionListener(this);
button.setFont(button.getFont().deriveFont(64.0f));
window.add(button);
window.pack();
window.setVisible(true);
}
示例8: testPanelBackground
import java.awt.Window; //導入方法依賴的package包/類
public void testPanelBackground() {
Window window = new Frame();
window.setBackground(Color.GREEN);
Panel panel = new Panel();
window.add(panel);
window.pack();
window.setVisible(true);
if (panel.getBackground() != Color.GREEN) {
window.dispose();
throw new RuntimeException("Panel Background Color Not Valid");
}
window.dispose();
}
示例9: updateVisibility
import java.awt.Window; //導入方法依賴的package包/類
protected void updateVisibility() {
tf.setVisible(!isNamed());
keyName.setVisible(isNamed());
lastChar = 0;
Window w = SwingUtilities.getWindowAncestor(p);
if (w != null) {
w.pack();
}
}
示例10: show
import java.awt.Window; //導入方法依賴的package包/類
private void show(Window window) {
JButton jButton = new JButton("Show ColorChooser");
jButton.setActionCommand("Show ColorChooser");
jButton.addActionListener(this);
this.cbPlaf = new JComboBox<UIManager.LookAndFeelInfo>(UIManager.getInstalledLookAndFeels());
this.cbPlaf.addItemListener(new ItemListener(){
@Override
public void itemStateChanged(ItemEvent itemEvent) {
if (itemEvent.getStateChange() == 1) {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
UIManager.LookAndFeelInfo lookAndFeelInfo = (UIManager.LookAndFeelInfo)Test4319113.this.cbPlaf.getSelectedItem();
try {
UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
Frame[] arrframe = Frame.getFrames();
int n = arrframe.length;
while (--n >= 0) {
Test4319113.updateWindowTreeUI(arrframe[n]);
}
}
catch (Exception var2_3) {
System.err.println("Exception while changing L&F!");
}
}
});
}
}
});
window.add(this.cbPlaf);
window.add(jButton);
window.pack();
window.setVisible(true);
}
示例11: packAndCenter
import java.awt.Window; //導入方法依賴的package包/類
public static void packAndCenter(final Window win) {
// pack
win.pack();
final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
win.setSize(Math.min(win.getWidth(), screenSize.width), Math.min(win.getHeight(), screenSize.height - 20));
// Center on screen
win.setLocationRelativeTo(null);
}
示例12: repack
import java.awt.Window; //導入方法依賴的package包/類
protected void repack() {
colorBox.setVisible(((ColorSwatch) getValue()).getConfigureName().equals(ColorManager.SELECT_COLOR));
Window w = SwingUtilities.getWindowAncestor(colorBox);
if (w != null) {
w.pack();
}
}
示例13: setImageName
import java.awt.Window; //導入方法依賴的package包/類
public void setImageName(String name) {
imageName = name;
remove(0);
if (name == null || name.trim().length() == 0 || name.equals(NO_IMAGE)) {
imageName = "";
add(noImage,0);
}
else {
icon.setOp(Op.load(imageName));
Dimension d = new Dimension(icon.getIconWidth(), icon.getIconHeight());
if (d.width > 200) d.width = 200;
if (d.height > 200) d.height = 200; else d.height += 4;
imageScroller.setPreferredSize(d);
imageScroller.setMinimumSize(d);
add(imageViewer,0);
}
select.removeItemListener(this);
select.setSelectedItem(name);
if (name != null && !name.equals(select.getSelectedItem())) {
select.setSelectedItem(name+".gif");
}
select.addItemListener(this);
revalidate();
final Window w = SwingUtilities.getWindowAncestor(this);
if (w != null) {
w.pack();
}
repaint();
}
示例14: repack
import java.awt.Window; //導入方法依賴的package包/類
protected void repack() {
Window w = SwingUtilities.getWindowAncestor(panel);
if (w != null) {
w.pack();
}
}
示例15: Ed
import java.awt.Window; //導入方法依賴的package包/類
public Ed(ReportState piece) {
box = new JPanel();
box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));
descInput = new StringConfigurer(null, "Description: ", piece.description);
box.add(descInput.getControls());
keys = new NamedKeyStrokeArrayConfigurer(null, "Report on these keystrokes: ", piece.keys);
box.add(keys.getControls());
cycle = new JCheckBox("Cycle through different messages?");
box.add(cycle);
format = new PlayerIdFormattedStringConfigurer(null, "Report format: ", new String[]{COMMAND_NAME,
OLD_UNIT_NAME,
NEW_UNIT_NAME,
MAP_NAME,
OLD_MAP_NAME,
LOCATION_NAME,
OLD_LOCATION_NAME});
format.setValue(piece.reportFormat);
box.add(format.getControls());
cycleFormat = new StringArrayConfigurer(null, "Message formats", piece.cycleReportFormat);
box.add(cycleFormat.getControls());
cycleDownKeys = new NamedKeyStrokeArrayConfigurer(null, "Report previous message on these keystrokes: ", piece.cycleDownKeys);
box.add(cycleDownKeys.getControls());
ItemListener l = new ItemListener() {
public void itemStateChanged(ItemEvent e) {
format.getControls().setVisible(!cycle.isSelected());
cycleFormat.getControls().setVisible(cycle.isSelected());
cycleDownKeys.getControls().setVisible(cycle.isSelected());
Window w = SwingUtilities.getWindowAncestor(box);
if (w != null) {
w.pack();
}
}
};
l.itemStateChanged(null);
cycle.addItemListener(l);
cycle.setSelected(piece.cycleReportFormat.length > 0);
}