ForumAlem
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Bedava forum | ©phpBB | Bedava yardımlaşma forumu | Suistimalı göstermek | Cookies | Son tartışmalar
ForumAlem

ForumAlem
 
AnasayfaAnasayfa  Latest imagesLatest images  AramaArama  Kayıt OlKayıt Ol  Giriş yapGiriş yap  

 

 Java da applet seklinde menu tasarimi

Aşağa gitmek 
YazarMesaj
KaoS
Admin
Admin
KaoS


Mesaj Sayısı : 170
Kayıt tarihi : 02/08/08
Yaş : 35
Nerden : KONYA

Java da applet seklinde menu tasarimi Empty
MesajKonu: Java da applet seklinde menu tasarimi   Java da applet seklinde menu tasarimi Icon_minitimeCuma Ağus. 15, 2008 12:02 pm

/*
*/

import java.awt.* ;
import java.awt.event.*;
import java.applet.*;
import java.util.*;
import java.net.*;

public class ImageMenu extends Applet {
Dimension d;

Image img, off;
Graphics offg;
int MAXITEMS = 64;
String url[] = new String[MAXITEMS];
String target[] = new String[MAXITEMS];
String urlPrefix, urlSuffix;
int selectedCell = -1;
int oldCell = -1;
int cellH;
int cells;

public void init() {
d = getSize();
urlPrefix = getParameter("urlPrefix");
urlSuffix = getParameter("urlSuffix");
StringTokenizer st;
st = new StringTokenizer(getParameter("urlList"), "+");
int i=0;
while(st.hasMoreTokens() && i < MAXITEMS)
url[i++] = st.nextToken();
cells = i;
cellH = d.height/cells;
st = new StringTokenizer(getParameter("targetList"), "+");
i=0;
while(st.hasMoreTokens() && i < MAXITEMS)
target[i++] = st.nextToken();
addMouseListener(new MyMouseAdapter());
addMouseMotionListener(new MyMouseMotionAdapter());
}

private void lateInit() {
off = createImage(d.width, d.height);
try {
img = getImage(getDocumentBase(), getParameter("img"));
MediaTracker t = new MediaTracker(this);
t.addImage(img, 0);
t.waitForID(0);
} catch(Exception e) {
showStatus("error: " + e);
}
}

public void update(Graphics g) {}
public void paint(Graphics g) {
if(off == null)
lateInit();

offg = off.getGraphics();
offg.drawImage(img, 0, 0, this);
if (selectedCell >= 0) {
offg.clipRect(0, selectedCell * cellH, d.width, cellH);
offg.drawImage(img, -d.width, 0, this);
}
g.drawImage(off, 0, 0, this);
}

class MyMouseMotionAdapter extends MouseMotionAdapter {
public void mouseDragged(MouseEvent me) {
mouseMoved(me);
}
public void mouseMoved(MouseEvent me) {
int y = me.getY();
selectedCell = (int)(y/(double)d.height*cells);
if (selectedCell != oldCell) {
paint(getGraphics());
showStatus(urlPrefix + url[selectedCell] + urlSuffix);
oldCell = selectedCell;
}
}
}

class MyMouseAdapter extends MouseAdapter {
public void mouseExited(MouseEvent me) {
selectedCell = oldCell = -1;
paint(getGraphics());
showStatus("");
}

public void mouseReleased(MouseEvent me) {
URL u = null;
try {
u = new URL(urlPrefix + url[selectedCell] + urlSuffix);
} catch(Exception e) {
showStatus("error: " + e);
}
if (me.isShiftDown())
getAppletContext().showDocument(u, "_blank");
else
getAppletContext().showDocument(u, target[selectedCell]);
}
}
}
Sayfa başına dön Aşağa gitmek
https://forumalem.hareketforum.net
 
Java da applet seklinde menu tasarimi
Sayfa başına dön 
1 sayfadaki 1 sayfası
 Similar topics
-
» Java da harika bir saat
» Makale - Java 5.0 (Tiger) ile Gelen Dil Yenilikleri

Bu forumun müsaadesi var:Bu forumdaki mesajlara cevap veremezsiniz
ForumAlem :: Programlama Dilleri :: Java/JSP-
Buraya geçin: