Java Utililty Methods Window

List of utility methods to do Window

  1. HOME
  2. Java
  3. W
  4. Window

Description

The list of methods to do Window are organized into topic(s).

Method

Point arrangeWithin(final Shape shapeToArrange, final Rectangle window, final int arrangement, Insets padding)
arrange Within
if (shapeToArrange == null)
 throw new IllegalArgumentException("Parameter 'shapeToArrange' must not be null!");
if (window == null)
 throw new IllegalArgumentException("Parameter 'window' must not be null!");
if (padding == null)
 padding = new Insets(0, 0, 0, 0);
final Rectangle bounds = shapeToArrange.getBounds();
switch (arrangement) {
...
JFrame buildWindow(Float opacity)
build Window
JFrame frame = new JFrame();
frame.setUndecorated(true);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setOpacity(opacity);
frame.getContentPane().setBackground(Color.black);
frame.setLayout(null);
frame.setVisible(true);
...
void cascade(Window[] windows, Rectangle dBounds, int separation)
cascade
int margin = 10 * separation;
int width = dBounds.width - margin;
int height = dBounds.height - margin;
for (int i = 0; i < windows.length; i++) {
 int offset = (windows.length - i - 1) * separation;
 int xOffset = dBounds.x + offset;
 if (xOffset > (dBounds.x + dBounds.width) - width) {
 xOffset -= margin;
...
void closeByESC(final Window window, JPanel panel)
close By ESC
panel.getActionMap().put("close", new AbstractAction() {
 private static final long serialVersionUID = 1L;
 public void actionPerformed(ActionEvent e) {
 window.dispose();
});
panel.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT)
 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
...
JLabel createWindow(String name, int width, int height, boolean guiOn)
create Window
JFrame imageFrame = new JFrame(name);
imageFrame.setSize(width, height);
imageFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel imagePane = new JLabel();
imagePane.setLayout(new BorderLayout());
imageFrame.setContentPane(imagePane);
imageFrame.setVisible(guiOn);
return imagePane;
...
void decorate(final Window w)
decorate
center(w);
setIcon(w);
void dock(Window window, Window dockTo)
"Injects" windows's content to another window
window.setVisible(false);
((RootPaneContainer) dockTo).getContentPane().add(((RootPaneContainer) window).getContentPane(),
 BorderLayout.SOUTH);
dockTo.setVisible(true);
void enableCloseWindowWithEscape(final W window)
Configures the given window to be closed when the Escape button is pressed.
Action closeAction = new AbstractAction() {
 @Override
 public void actionPerformed(ActionEvent e) {
 window.dispatchEvent(new WindowEvent(window, WindowEvent.WINDOW_CLOSING));
};
window.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW)
 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close");
...
void fadeOut(final Window window, final boolean dispose)
Fade out.
enableParentOfModalDialog(window);
final Timer timer = new Timer(FADE_TIMER_DURATION, null);
timer.setRepeats(true);
timer.addActionListener(new ActionListener() {
 private float opacity = 1;
 @Override
 public void actionPerformed(final ActionEvent e) {
 this.opacity -= OPCICITY_INC_DEC;
...
void flashMessage(final Window parent, String string)
flash Message
flashMessage(parent, string, Color.WHITE, Color.BLACK, 1000);


AltStyle によって変換されたページ (->オリジナル) /