Op deze website gebruiken we cookies om content en advertenties te personaliseren, om functies voor social media te bieden en om ons websiteverkeer te analyseren. Ook delen we informatie over uw gebruik van onze site met onze partners voor social media, adverteren en analyse. Deze partners kunnen deze gegevens combineren met andere informatie die u aan ze heeft verstrekt of die ze hebben verzameld op basis van uw gebruik van hun services. Meer informatie.

Akkoord

Vraag & Antwoord

Webprogrammeren & scripting

.class applet en printen

Anoniem
Rynus Rein
3 antwoorden
  • Ik ben als hobbyprojectje bezig met een site. Ik heb hierop een fotoboek staan die aangestuurt wordt middels een .class applet. Het is echter niet mogelijk voor de bezoeker om de foto die erin staat af te drukken of uberhaupt iets anders met de foto te doen, zodra je er met de muis op klikt verschijnt er een stukje tekst van de maker (heb ik al gemailed, adres bestaat niet (meer)). Wie weet hoe ik hier een printfunctie in krijg of hoe ik een .class bestand kan editten, misschien snap ik er iets van en kan ik de muisklik functie veranderen of een printfunctie erbij zetten.
    De site is te vinden op http://members.chello.nl
    .vanzandt
    De foto's zijn dan te vinden via het menu "Fotos","Algemeen"

    Bedankt voor het meedenken.
  • Je kan zo'n class bestand terugbrengen naar de java broncode ervan, met een java decompiler zoals Jad.
    Ik weet alleen niet wat de kwaliteit ervan is.
  • Ok, toppie, dat werkt dus. Ik zie echter in beide applets wel een MouseEvent, echter snap ik niet hoe ik dat moet of kan wijzigen. Tevens vraag ik mij af hoe ik het bestand vervolgens weer terug krijg als een .class bestand, onderstaand beide .class (.jad) bestanden:
    [b:563878c50e]GalleryCanvas.jad[/b:563878c50e]
    // Decompiled by Jad v1.5.7. Copyright 1997-99 Pavel Kouznetsov.
    // Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
    // Decompiler options: packimports(3)
    // Source File Name: GalleryCanvas.java

    import java.applet.Applet;
    import java.awt.*;

    class GalleryCanvas extends Canvas
    {

    GalleryCanvas(ImageGallery imagegallery, int i, int j, boolean flag, Image image, Graphics g, Color color)
    {
    showInfo = false;
    topTitle = true;
    titleInImg = false;
    titleColor = Color.yellow;
    appletInfo1 = "ImageGallery v1.27 © 1997 Gabriel";
    appletInfo2 = "Email: txwudi@mbox2.singnet.com.sg";
    appletInfo3 = "";
    loadInfo = "Loading Image…";
    width = i;
    height = j;
    outer = imagegallery;
    imgTitle = flag;
    if(imgTitle)
    checkTitle();
    bufferImg = image;
    bufferG = g;
    backGround = color;
    resize(i, j);
    setFont(new Font("Helvetica", 1, 14));
    fontM = getFontMetrics(getFont());
    }

    public void removeStatus()
    {
    showInfo = false;
    }

    public void checkTitle()
    {
    String s = outer.getParameter("toptitle");
    if(s != null)
    {
    if(s.equalsIgnoreCase("true"))
    topTitle = true;
    else
    topTitle = false;
    s = null;
    }
    s = outer.getParameter("titleinimage");
    if(s != null)
    {
    if(s.equalsIgnoreCase("true"))
    titleInImg = true;
    else
    titleInImg = false;
    s = null;
    }
    s = outer.getParameter("titlecolor");
    if(s != null)
    {
    titleColor = outer.checkColor(s);
    if(titleColor == null)
    titleColor = Color.yellow;
    }
    }

    public void update(Graphics g)
    {
    paint(g);
    }

    public void paint(Graphics g)
    {
    bufferG.setFont(getFont());
    bufferG.setColor(backGround);
    bufferG.fillRect(0, 0, width, height);
    if(!showInfo)
    {
    if(outer.getGalleryImg() != null)
    {
    int i = (width - outer.getGalleryImg().getWidth(this)) / 2;
    int k = (height - outer.getGalleryImg().getHeight(this)) / 2;
    bufferG.drawImage(outer.getGalleryImg(), i, k, this);
    if(imgTitle)
    {
    int l = (width - fontM.stringWidth(outer.getImgTitle())) / 2;
    bufferG.setColor(titleColor);
    if(topTitle)
    {
    if(titleInImg)
    bufferG.drawString(outer.getImgTitle(), l, k + 12);
    else
    bufferG.drawString(outer.getImgTitle(), l, 12);
    }
    else
    if(titleInImg)
    bufferG.drawString(outer.getImgTitle(), l, (k + outer.getGalleryImg().getHeight(this)) - 5);
    else
    bufferG.drawString(outer.getImgTitle(), l, height - 5);
    }
    }
    else
    {
    bufferG.setColor(Color.red);
    bufferG.drawString(loadInfo, (width - fontM.stringWidth(loadInfo)) / 2, height / 2 - 10);
    }
    }
    else
    {
    bufferG.setColor(Color.yellow);
    int j = (width - fontM.stringWidth(appletInfo1)) / 2;
    bufferG.drawString(appletInfo1, j, height / 2 - 18);
    j = (width - fontM.stringWidth(appletInfo2)) / 2;
    bufferG.drawString(appletInfo2, j, height / 2);
    j = (size().width - fontM.stringWidth(appletInfo3)) / 2;
    bufferG.drawString(appletInfo3, j, height / 2 + 18);
    }
    g.drawImage(bufferImg, 0, 0, null);
    }

    public boolean mouseDown(Event event, int i, int j)
    {
    if(!showInfo)
    {
    showInfo = true;
    repaint();
    return true;
    }
    else
    {
    showInfo = false;
    repaint();
    return true;
    }
    }

    ImageGallery outer;
    Image bufferImg;
    Graphics bufferG;
    int width;
    int height;
    boolean showInfo;
    boolean imgTitle;
    boolean topTitle;
    boolean titleInImg;
    Color titleColor;
    String appletInfo1;
    String appletInfo2;
    String appletInfo3;
    String loadInfo;
    Color backGround;
    FontMetrics fontM;
    }


    [b:563878c50e]ImageGallery.jad[/b:563878c50e]
    // Decompiled by Jad v1.5.7. Copyright 1997-99 Pavel Kouznetsov.
    // Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
    // Decompiler options: packimports(3)
    // Source File Name: ImageGallery.java

    import java.applet.Applet;
    import java.applet.AppletContext;
    import java.awt.*;
    import java.util.Hashtable;

    public class ImageGallery extends Applet
    implements Runnable
    {

    public void init()
    {
    numberImg = Integer.parseInt(getParameter("number"));
    imgName = getParameter("thename");
    format = getParameter("format");
    time = getParameter("delay");
    if(time == null)
    count = 10;
    else
    try
    {
    count = Integer.parseInt(time);
    }
    catch(NumberFormatException _ex)
    {
    count = 10;
    }
    String s = getParameter("imgtitle");
    if(s != null)
    {
    if(s.trim().equalsIgnoreCase("true"))
    imgTitle = true;
    else
    imgTitle = false;
    s = null;
    }
    if(imgTitle)
    {
    imgDescribe = new String[numberImg];
    for(int i = 0; i < numberImg; i++)
    {
    imgDescribe = getParameter("title" + (i + 1));
    if(imgDescribe == null)
    imgDescribe = "No Title";
    }

    s = getParameter("titleinnumber");
    if(s != null && s.equalsIgnoreCase("true"))
    {
    for(int j = 0; j < numberImg; j++)
    {
    imgDescribe[j] = getParameter("numbertitle");
    if(imgDescribe[j] == null)
    imgDescribe[j] = "Image";
    imgDescribe[j] = imgDescribe[j].concat(" " + String.valueOf(j + 1));
    }

    }
    }
    s = getParameter("border");
    if(s != null)
    {
    appletBorderColor = checkColor(s);
    if(appletBorderColor == null)
    appletBorderColor = Color.red;
    s = null;
    }
    s = getParameter("canvasborder");
    if(s != null)
    {
    canvasBorderColor = checkColor(s);
    if(canvasBorderColor == null)
    canvasBorderColor = Color.blue;
    s = null;
    }
    Color color = Color.black;
    s = getParameter("canvasbg");
    if(s != null)
    {
    color = checkColor(s);
    if(color == null)
    color = Color.black;
    s = null;
    }
    Color color1 = getBackground();
    s = getParameter("controlsbg");
    if(s != null)
    {
    color1 = checkColor(s);
    if(color1 == null)
    color1 = getBackground();
    }
    galleryImg = new Image[numberImg];
    loadOK = new boolean[numberImg];
    getImg = 0;
    imgTrack = new MediaTracker(this);
    retrievedImg();
    nowImage = galleryImg[0];
    previousBtn = new Button("<–");
    nextBtn = new Button("–>");
    setBackground(color1);
    Image image = createImage(size().width - 10, size().height - 41);
    Graphics g = image.getGraphics();
    theCanvas = new GalleryCanvas(this, size().width - 10, size().height - 41, imgTitle, image, g, color);
    add(theCanvas);
    theCanvas.reshape(10, 5, size().width - 10, size().height - 41);
    add(previousBtn);
    previousBtn.disable();
    if(numberImg == 1)
    nextBtn.disable();
    add(nextBtn);
    point = 0;
    checkLoad(point);
    }

    public void retrievedImg()
    {
    int i = getImg;
    getAppletContext().showStatus("Retrieving Images…");
    if(numberImg - getImg < 3)
    {
    getImg = numberImg;
    totalImg = numberImg;
    }
    else
    {
    getImg += 3;
    totalImg += 3;
    }
    for(; i != getImg; i++)
    {
    galleryImg = getImage(getDocumentBase(), imgName + (i + 1) + "." + format);
    imgTrack.addImage(galleryImg, i);
    loadOK = false;
    }

    getAppletContext().showStatus("Downloading Now…");
    if(getImg == numberImg)
    allLoaded = true;
    }

    public void checkLoad(int i)
    {
    if(imgTrack.checkID(i, true))
    {
    nowImage = galleryImg;
    if(imgTitle)
    nowTitle = imgDescribe;
    loadOK = true;
    if(i == totalImg - 1)
    count = 1;
    }
    else
    {
    nowImage = null;
    }
    theCanvas.repaint();
    }

    public void start()
    {
    if(galleryThread == null)
    {
    galleryThread = new Thread(this);
    galleryThread.start();
    }
    }

    public void stop()
    {
    if(galleryThread != null)
    galleryThread.stop();
    galleryThread = null;
    }

    public void run()
    {
    while(galleryThread.isAlive())
    {
    if(!allLoaded)
    {
    getAppletContext().showStatus("Next Retrieval in: " + count + " sec");
    count–;
    if(count == 0)
    {
    nextBtn.enable();
    retrievedImg();
    if(time == null)
    count = 10;
    else
    try
    {
    count = Integer.parseInt(time);
    }
    catch(NumberFormatException _ex)
    {
    count = 10;
    }
    }
    }
    if(!loadOK[point])
    checkLoad(point);
    if(imgTrack.checkAll(true) && allLoaded && galleryThread != null)
    galleryThread.suspend();
    try
    {
    Thread.sleep(1000L);
    }
    catch(InterruptedException _ex) { }
    }

    }

    public boolean action(Event event, Object obj)
    {
    if(event.target == previousBtn)
    {
    point–;
    nextBtn.enable();
    if(point == 0)
    previousBtn.disable();
    theCanvas.removeStatus();
    checkLoad(point);
    return true;
    }
    if(event.target == nextBtn)
    {
    point++;
    previousBtn.enable();
    if(point == totalImg - 1)
    nextBtn.disable();
    theCanvas.removeStatus();
    checkLoad(point);
    return true;
    }
    else
    {
    return super.action(event, obj);
    }
    }

    public boolean mouseEnter(Event event, int i, int j)
    {
    if(allLoaded)
    {
    getAppletContext().showStatus(getAppletInfo());
    return true;
    }
    else
    {
    return super.mouseEnter(event, i, j);
    }
    }

    public boolean mouseMove(Event event, int i, int j)
    {
    if(allLoaded)
    {
    getAppletContext().showStatus(getAppletInfo());
    return true;
    }
    else
    {
    return super.mouseMove(event, i, j);
    }
    }

    public boolean mouseExit(Event event, int i, int j)
    {
    if(allLoaded)
    {
    getAppletContext().showStatus("");
    return true;
    }
    else
    {
    return super.mouseExit(event, i, j);
    }
    }

    public String getAppletInfo()
    {
    return "Applet: ImageGallery v1.27 © 1997 Gabriel";
    }

    public Color checkColor(String s)
    {
    Color color = Color.black;
    if(s.charAt(0) == '#')
    color = constructColor(s.substring(1));
    else
    color = (Color)defaultColor.get(s.toLowerCase());
    return color;
    }

    public Color constructColor(String s)
    {
    Color color;
    try
    {
    int i = Integer.parseInt(s.substring(0, 2), 16);
    int j = Integer.parseInt(s.substring(2, 4), 16);
    int k = Integer.parseInt(s.substring(4), 16);
    color = new Color(i, j, k);
    }
    catch(NumberFormatException _ex)
    {
    color = null;
    }
    return color;
    }

    public void paint(Graphics g)
    {
    g.setColor(appletBorderColor);
    g.drawRect(0, 0, size().width - 2, size().height - 2);
    g.drawRect(1, 1, size().width - 3, size().height - 3);
    g.setColor(canvasBorderColor);
    g.drawRect(4, 4, size().width - 9, size().height - 40);
    }

    public Image getGalleryImg()
    {
    return nowImage;
    }

    public String getImgTitle()
    {
    return nowTitle;
    }

    public ImageGallery()
    {
    canvasBorderColor = Color.blue;
    appletBorderColor = Color.red;
    allLoaded = false;
    imgTitle = false;
    }

    Image galleryImg[];
    Image nowImage;
    String imgDescribe[];
    String nowTitle;
    Button previousBtn;
    Button nextBtn;
    Thread galleryThread;
    String imgName;
    String format;
    String time;
    int numberImg;
    int totalImg;
    int getImg;
    int count;
    int point;
    GalleryCanvas theCanvas;
    MediaTracker imgTrack;
    Color canvasBorderColor;
    Color appletBorderColor;
    boolean allLoaded;
    boolean loadOK[];
    boolean imgTitle;
    static Hashtable defaultColor;

    static
    {
    defaultColor = new Hashtable();
    defaultColor.put("black", Color.black);
    defaultColor.put("blue", Color.blue);
    defaultColor.put("cyan", Color.cyan);
    defaultColor.put("darkgray", Color.darkGray);
    defaultColor.put("gray", Color.gray);
    defaultColor.put("green", Color.green);
    defaultColor.put("lightgray", Color.lightGray);
    defaultColor.put("magenta", Color.magenta);
    defaultColor.put("orange", Color.orange);
    defaultColor.put("pink", Color.pink);
    defaultColor.put("red", Color.red);
    defaultColor.put("white", Color.white);
    defaultColor.put("yellow", Color.yellow);
    }
    }

Beantwoord deze vraag

Dit is een gearchiveerde pagina. Antwoorden is niet meer mogelijk.