インスペクタを整列させる
患者さんがご家族で受診された場合など,インスペクタを3つくらい同時に開いて診察することがある。ウインドウメニューから,コマンドでインスペクタを整列できるようにした。
helper/WindowSupport.java
// frame を整列させるときの初期位置と移動幅
public static int INITIAL_X = 256;
public static int INITIAL_Y = 40;
public static int INITIAL_DX = 192;
public static int INITIAL_DY = 20;
// プライベートコンストラクタ
private WindowSupport(JFrame frame, JMenuBar menuBar, JMenu windowMenu, Action windowAction) {
・
・
//pns^
// インスペクタを整列するアクションだけはあらかじめ入れておく
// こうしておかないと,1回 window メニューを開かないと accelerator が効かないことになる
windowMenu.add(new ArrangeInspectorAction());
//pns$
}
public void menuSelected(MenuEvent e) {
・
・
wm.add(action);
count++;
}
}
// インスペクタウインドウを整列する
if (count != 0) {
wm.addSeparator();
count = 0;
Action a = new ArrangeInspectorAction();
wm.add(a);
}
}
/**
* インスペクタを整列する action
*/
class ArrangeInspectorAction extends AbstractAction {
public ArrangeInspectorAction() {
putValue(Action.NAME, "インスペクタを整列");
putValue(Action.SMALL_ICON, GUIConst.ICON_WINDOWS_22);
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_UNDERSCORE, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
}
public void actionPerformed(ActionEvent e) {
JFrame f;
int x = INITIAL_X; int y = INITIAL_Y; int width = 0; int height = 0;
for (WindowSupport ws : allWindows) {
f = ws.getFrame();
if (f.getTitle().contains("インスペクタ")) {
if (width == 0) width = f.getBounds().width;
if (height == 0) height = f.getBounds().height;
f.setBounds(x, y, width, height);
f.toFront();
x += INITIAL_DX; y += INITIAL_DY;
}
}
}
}
« 新しい iMac に移行して焦る | トップページ | com.apple.eawt.Application の仕様変更 »
「OpenDolphin」カテゴリの記事
- OpenDolphin: Java 25 / WildFly 38 への移行(2025.11.09)
- 運用17年目のまとめ(2025.02.03)
- IME on/off の切換 - その2(2024.12.02)
- OrcaController オルコン(2024.11.28)
- OpenDolphin: java 21 / wildfly 34 への移行(2024.11.08)



