Frank1984
09-30-2004, 01:30 PM
Hi,
I've a problem with a java applet. I now have the following:
import java.applet.*;
import java.awt.*;
import java.net.*;
public class ScreenRes extends java.applet.Applet {
public void start() {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
String file = null;
URL url = null;
switch(screenSize.width) {
case 640: file = "pc/index.htm"; // 640x480
break;
case 800: file = "pc/index.htm"; // 800x600
break;
case 1024: file = "pc/index.htm"; // 1024x768
break;
case 1280: file = "pc/index.htm"; // 1280x1024
break;
case 1400: file = "pc/index.htm"; // 1400x1150
break;
case 1600: file = "pc/index.htm"; // 1600x1200
break;
default: file = "phone/index.htm";
break;
}
try { url = new URL(getDocumentBase(), file); }
catch ( MalformedURLException e) {
url = null;
}
if (url != null) {
getAppletContext().showDocument(url);
}
}
}
But what I need is that when the screen width is smaller than 640 then go to phone/index.htm and when the width is equal or bigger than 640 then go to pc/index.htm
Could somebody change the code for me?
Thanks in advance!
Frank
I've a problem with a java applet. I now have the following:
import java.applet.*;
import java.awt.*;
import java.net.*;
public class ScreenRes extends java.applet.Applet {
public void start() {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
String file = null;
URL url = null;
switch(screenSize.width) {
case 640: file = "pc/index.htm"; // 640x480
break;
case 800: file = "pc/index.htm"; // 800x600
break;
case 1024: file = "pc/index.htm"; // 1024x768
break;
case 1280: file = "pc/index.htm"; // 1280x1024
break;
case 1400: file = "pc/index.htm"; // 1400x1150
break;
case 1600: file = "pc/index.htm"; // 1600x1200
break;
default: file = "phone/index.htm";
break;
}
try { url = new URL(getDocumentBase(), file); }
catch ( MalformedURLException e) {
url = null;
}
if (url != null) {
getAppletContext().showDocument(url);
}
}
}
But what I need is that when the screen width is smaller than 640 then go to phone/index.htm and when the width is equal or bigger than 640 then go to pc/index.htm
Could somebody change the code for me?
Thanks in advance!
Frank