Sponsored link
SWT3.0 Example Monitor
概要
SWT3.0からマルチモニターがサポートされました。
Monitorクラスには、モニターのサイズ・位置情報があります。
注意事項は、
Displayインスタンス.getMonitors()
で得られるモニターの配列の0番目がPrimaryモニター(メインモニター)とは限らないことです。
サンプル
モニターごとにshellを開く
example/monitor/DualMonitor.java
public DualMonitor(Display display,Shell shell) {
Monitor monitors[]=display.getMonitors();
for(int i=0;i<monitors.length;i++){
if(monitors[i].equals(display.getPrimaryMonitor())){
shell.setBounds(monitors[i].getBounds());
}else{
Shell newshell=new Shell(shell);
newshell.setBounds(monitors[i].getBounds());
newshell.open();
}
}
}
子Shellと同時に親Shellを閉じる。
Shellのサンプルですが
ShellListenerを実装します。
example/monitor/DualMonitorClose.java
public void shellClosed(ShellEvent arg0) {
// TODO Auto-generated method stub
((Shell)((Shell)arg0.getSource()).getParent()).close();
}
