import java.applet.*; import java.awt.*; import java.awt.event.*; public class FullScreenTest3Old extends Applet implements ActionListener { //Eclipseの場合、シリアライズ可能クラスでこれがないと警告が出る private static final long serialVersionUID=0; // TextField leftField=new TextField("100",3); TextField topField=new TextField("100",3); TextField widthField=new TextField("100",3); TextField heightField=new TextField("100",3); // Button showButton=new Button("JWindow表示"); Button fullSizeButton=new Button("サイズ指定でFullScreen"); Button fullSysButton=new Button("システムでFullScreen"); // public void init() { // Panel panel=new Panel(); panel.setLayout(new FlowLayout()); panel.add(new Label("左位置")); panel.add(leftField); panel.add(new Label("上位置")); panel.add(topField); panel.add(new Label("幅")); panel.add(widthField); panel.add(new Label("高さ")); panel.add(heightField); panel.add(showButton); // Panel panel2=new Panel(); panel2.setLayout(new FlowLayout()); panel2.add(fullSizeButton); panel2.add(new Label(" ")); panel2.add(fullSysButton); // add(panel,BorderLayout.CENTER); add(panel2,BorderLayout.SOUTH); // showButton.addActionListener(this); fullSizeButton.addActionListener(this); fullSysButton.addActionListener(this); } public void actionPerformed(ActionEvent e) { if(e.getSource()==showButton){ //位置とサイズ取得 int left,top,width,height; try{ left=Integer.parseInt(leftField.getText()); }catch(NumberFormatException nfe){ left=100; leftField.setText("100"); } try{ top=Integer.parseInt(topField.getText()); }catch(NumberFormatException nfe){ top=100; topField.setText("100"); } try{ //幅は100以上(ボタンがはみ出ないため) width=Integer.parseInt(widthField.getText()); if(width<100){ width=100; widthField.setText("100"); } }catch(NumberFormatException nfe){ width=100; widthField.setText("100"); } try{ //高さは100以上(ボタンがはみ出ないため) height=Integer.parseInt(heightField.getText()); if(height<100){ height=100; heightField.setText("100"); } }catch(NumberFormatException nfe){ height=100; heightField.setText("100"); } // NoFrameWindow window=new NoFrameWindow(); window.setBounds(left,top,width,height); window.setVisible(true); }else if(e.getSource()==fullSizeButton){ //画面のサイズを取得 Dimension dim=getToolkit().getScreenSize(); // NoFrameWindowOld window=new NoFrameWindowOld(); window.setBounds(0,0,dim.width,dim.height+50); //***下のバーが画面下に隠れるようにする*** window.setVisible(true); window.toFront(); }else if(e.getSource()==fullSysButton){ //その環境で利用可能なグラフィックデバイスを取得 GraphicsDevice device=GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); // if(device.isFullScreenSupported()){ NoFrameWindowOld window=new NoFrameWindowOld(); window.setVisible(true); //window.toFront(); device.setFullScreenWindow(window); //このフレームをフルスクリーンに /*これでは上手くいかない try{ device.setFullScreenWindow(this); //このフレームをフルスクリーンに }finally{ device.setFullScreenWindow(null); //不正終了したら元に戻るように } */ }else{ //システムがフルスクリーン出来ない //何もしない } } } }