Raymond Cheng's Profile

About

 
Points: 1

Contact

 

Raymond Cheng
July 5, 2015 · Public

How to use setBackground in eclipse? I want to change the background color of a window.

Raymond Cheng
July 4, 2015 · Public

Hello Bucky,
why can't I run your program from up to the fifth tutorial in java game development?
I copied everything. Nothing pops out when I click the run button. It just pops out a program with nothing an sits there for 5 seconds.
Please check my code. there are two classes.

import java.awt.*;
import javax.swing.JFrame;

public class bucky extends JFrame {
public static void main(String[] args){

DisplayMode dm = new DisplayMode (800, 600, 16, DisplayMode.REFRESH_RATE_UNKNOWN);
bucky b = new bucky();
b.run(dm);


}

public void run(DisplayMode dm){
setBackground(Color.PINK);
setForeground(Color.WHITE);
setFont(new Font ("Arial", Font.PLAIN, 24));

Screen s = new Screen();
try{
s.setFullScreen(dm, this);
try{
Thread.sleep(5000);
}catch (Exception ex){}
}finally{
s.restoreScreen();
}
}

public void paint(Graphics g){
g.drawString("This is gonna be awesome", 200, 200);
}
}








import java.awt.*;
import javax.swing.JFrame;

public class Screen {

private GraphicsDevice vc;

public Screen(){
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
vc = env.getDefaultScreenDevice();
}

public void setFullScreen(DisplayMode dm, JFrame window){
window.setUndecorated(true);
window.setResizable(false);
vc.setFullScreenWindow(window);

if (dm != null && vc.isDisplayChangeSupported()){
try{
vc.setDisplayMode(dm);
}catch (Exception ex){}
}
}

public Window getFullScreenWindow(){
return vc.getFullScreenWindow();
}

public void restoreScreen(){
Window w = vc.getFullScreenWindow();
if (w != null){
w.dispose();
}
vc.setFullScreenWindow(null);
}
}

Raymond Cheng
July 2, 2015 · Public

Hi,

I am wondering how I can view websites that are blocked by China (where I live). Does it involve VPN, NAT, and/or port forwarding? I am trying to build a vpn server on my home router where the websites are not blocked. Can someone help me out?