import java.applet.Applet; import java.awt.*; import java.awt.event.*; public class frame_menu extends userFrame implements Runnable{ Image off; Image star_img; Image back; Graphics back_g; Graphics off_g; Thread th; MediaTracker mt; int mouse_x; int mouse_y; boolean back_draw; double ra; BackEffect3 be3[] = new BackEffect3[10]; title t[] = new title[10]; int title_num; Applet ap; public frame_menu(String s, Applet ap){//コンストラクタ super(s); this.ap = ap; frameinit();//フレーム初期化 init(); addWindowListener(new Window_Adapter(this)); frameshow(); } public void frameinit(){//フレーム初期化 オーバーライト自由 setSize(400,400); setBackground(Color.black); setForeground(Color.white); setResizable(true); //setLocation(0,0); //setCursor(HAND_CURSOR); } //public void menuinit(){} /*********init()***********/ public void init(){ //off = createImage(400,400); //off_g = off.getGraphics(); th = null; mt = new MediaTracker(this); addMouseListener(this); addMouseMotionListener(this); star_img = ap.getImage(ap.getCodeBase(),"back.gif"); mt.addImage(star_img,0); back_draw = false; mouse_x = 200; mouse_y = 200; ra = Math.PI/2; for (int i = 0; i < 10; i++) be3[i] = new BackEffect3(); t[0] = new title("Profile", "http://www.u-aizu.ac.jp/~s1061133/profile.html"); t[1] = new title("Java", "http://www.u-aizu.ac.jp/~s1061133/profile.html"); t[2] = new title("Games", "http://www.u-aizu.ac.jp/~s1061133/profile.html"); t[3] = new title("BBS", "http://www.telejapan.com/af/cgi/aizu/bbs/jawanote.cgi"); t[4] = new title("Chat", "http://www.telejapan.com/af/cgi/aizu/chat/index.html"); t[5] = new title("Music", "http://www.u-aizu.ac.jp/~s1061133/profile.html"); t[6] = new title("Link", "http://www.u-aizu.ac.jp/~s1061133/profile.html"); title_num = 7; } /*********start()**********/ public void start(){ off_g.setFont(new Font("Dialog",Font.PLAIN,30)); if (th == null){ th = new Thread(this); th.start(); } } /********update()**********/ public void update(Graphics g){ paint(g); } /********run()***********/ public void run(){ while (true){ if (mt.checkID(0)){ if (!back_draw){ for (int x = 0; x < 400; x += 150){ for (int y = 0; y < 400; y+= 150) back_g.drawImage(star_img,x,y,this); } back_draw = true; } repaint(); } else { try { mt.waitForID(0); }catch(InterruptedException e){} } /********sleep*********/ try{ th.sleep(150); } catch (InterruptedException e){} } } /*********paint()*********/ public void paint(Graphics g){ if (mt.isErrorID(0)){ off_g.setColor(Color.black); off_g.fillRect(0,0,getSize().width,getSize().height); off_g.setColor(Color.white); off_g.drawString("Load Error...",50,50); } else if (mt.checkID(0)){ off_g.drawImage(back,0,0,this); /********マウスの位置とくらべる******/ for (int i = 0; i < title_num; i++) t[i].mouse_move(mouse_x,mouse_y); /********タイトルをうごかす***********/ for (int i = 0; i < title_num; i++){ double ra2 = ra + ((Math.PI*2)/title_num)*i; t[i].setXY(ra2); } /********タイトルを書く************/ for (int i = 0; i < title_num; i++) t[i].draw(off_g); for (int i = 0; i < 5; i++) be3[i].draw(mouse_x, mouse_y, off_g); for (int i = 5; i < 10; i++) be3[i].draw2(mouse_x,mouse_y,off_g); /*********raをうごかす**********/ if (ra > ((Math.PI/2)*5)-(Math.PI/(64*2))) ra = Math.PI/2; else ra += Math.PI/(64*2); } else { off_g.setColor(Color.black); off_g.fillRect(0,0,getSize().width,getSize().height); off_g.setColor(Color.white); off_g.drawString("Now Loding...",50,50); } g.drawImage(off,0,0,this); } /*************************************************************** マウス処理 *******************************************************************/ /********マウスをクリックしたとき**********/ public void mouseClicked (MouseEvent e){ for (int i = 0; i < 5; i++) t[i].clic(ap.getAppletContext()); } /*********マウスが入ったとき**************/ public void mouseEntered (MouseEvent e){ } /*********マウスが出たとき**************/ public void mouseExited (MouseEvent e){ } /*********マウスが押されたとき**************/ public void mousePressed (MouseEvent e){ } /*********マウスが離されたとき**************/ public void mouseReleased (MouseEvent e){ } /*********マウスがドラッグされたとき**************/ public void mouseDragged(MouseEvent e){ } /*********マウスが動かされたとき**************/ public void mouseMoved (MouseEvent e){ mouse_x = e.getX(); mouse_y = e.getY(); } public void stop(){ if(th != null){ th.stop(); th = null; } } public void frameshow(){ show(); g = getGraphics();//表に書くためのグラフィックオブジェクト off = createImage(getSize().width,getSize().height); off_g = off.getGraphics(); back = createImage(400,400); back_g = back.getGraphics(); } }