Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    70

    Questa applet non vuole proprio funzionare!!!

    Cari amici,
    sono alle prime armi con java e la seguente applet anche se viene compilata correttamente, quando inserita in un file .html non appare ovvero si vede solo il riquadro grigio dell'applet!!!
    Come devo fare per far apparire l'interfaccia?!?
    Ecco il codice:

    package appsec;

    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import borland.jbcl.layout.*;
    import borland.jbcl.control.*;
    import java.net.*;
    import java.lang.*;
    import com.sun.java.swing.*;
    import java.applet.AppletContext;
    import java.io.*;

    //import com.sun.java.swing.UIManager;
    public class securepass extends Applet {
    XYLayout xYLayout1 = new XYLayout();
    boolean isStandalone = false;
    TextControl textControl1 = new TextControl();
    TextFieldControl Username = new TextFieldControl();
    TextControl textControl2 = new TextControl();
    TextFieldControl Password = new TextFieldControl();
    ButtonControl buttonControl1 = new ButtonControl();
    ButtonControl buttonControl2 = new ButtonControl();

    //Construct the applet

    public securepass() {

    }
    //Initialize the applet

    public void init() {
    try {
    jbInit();
    }
    catch (Exception e) {
    e.printStackTrace();
    }
    }
    //static {
    // try {
    // //UIManager.setLookAndFeel(new com.sun.java.swing.plaf.metal.MetalLookAndFeel());
    // //UIManager.setLookAndFeel(new com.sun.java.swing.plaf.motif.MotifLookAndFeel());
    // UIManager.setLookAndFeel(new com.sun.java.swing.plaf.windows.WindowsLookAndFeel ());
    // }
    // catch (Exception e) {}
    //}
    //Component initialization

    private void jbInit() throws Exception {
    this.setBackground(Color.white);
    xYLayout1.setWidth(369);
    xYLayout1.setHeight(240);
    textControl1.setAlignment(borland.jbcl.util.Alignm ent.CENTER | borland.jbcl.util.Alignment.MIDDLE);
    textControl1.setFont(new Font("SansSerif", 1, 14));
    textControl1.setText("Username:");
    textControl2.setAlignment(borland.jbcl.util.Alignm ent.CENTER | borland.jbcl.util.Alignment.MIDDLE);
    textControl2.setFont(new Font("SansSerif", 1, 14));
    textControl2.setText("Password:");
    Password.setBackground(Color.white);
    Password.setEchoChar('*');
    buttonControl1.setBackground(SystemColor.scrollbar );
    buttonControl1.setLabel("Enter");
    buttonControl2.setBackground(SystemColor.scrollbar );
    buttonControl2.setLabel("Reset");
    buttonControl2.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    buttonControl2_mouseClicked(e);
    }
    });
    buttonControl1.addMouseListener(new java.awt.event.MouseAdapter() {
    public void mouseClicked(MouseEvent e) {
    buttonControl1_mouseClicked(e);
    }

    });
    this.setLayout(xYLayout1);
    this.add(textControl1, new XYConstraints(25, 66, 87, 36));
    this.add(Username, new XYConstraints(124, 71, 169, 22));
    this.add(textControl2, new XYConstraints(27, 117, 80, 31));
    this.add(Password, new XYConstraints(122, 119, 171, 22));
    this.add(buttonControl1, new XYConstraints(128, 172, 79, 28));
    this.add(buttonControl2, new XYConstraints(205, 172, 78, 28));
    }
    //Get Applet information

    public String getAppletInfo() {
    return "Applet Information";
    }
    //Get parameter info

    public String[][] getParameterInfo() {
    return null;
    }

    void buttonControl1_mouseClicked(MouseEvent e) {
    String User=Username.getText();
    String Pass=Password.getText();
    if ((User=="uuu")&&(Pass=="ppp")){
    try{
    URL urll=new URL("http://www.dcdc.it");
    getAppletContext().showDocument(urll,"_blank");
    } //fine try
    catch(IOException x) {System.out.println("La pagina non è disponibile, riprova in un secondo momento");}
    } //fine if
    else{ try{
    URL urlerror = new URL("http://www.eded.it");
    getAppletContext().showDocument(urlerror);
    }
    catch(IOException xx){System.out.println("Error page not found"); }
    }//fine else
    }//fine funzione

    void buttonControl2_mouseClicked(MouseEvent e) {
    Username.setText("");
    Password.setText("");
    }






    }

    Vi ringrazio per l'aiuto!!!
    daniele

  2. #2
    Utente di HTML.it
    Registrato dal
    Jul 1999
    Messaggi
    88
    Ciao la mia risposta è banale, ma siccome dici di essere alle prime armi potrebbe esserti d'aiuto, molto spesso quando viene il riguadro grigio è dovuto al codice della pagina HTML che non è corretto (per esperienza personale il percorso molto spesso :adhone: ).
    Potrebbe essere corretta l'applett ma vai il browser la stà cercando in un URL sbagliato.

    Ciao
    Pmat
    :adhone:
    VB - Java - C/C++ - VC - CORBA -JDBC

  3. #3
    Utente di HTML.it
    Registrato dal
    Aug 2002
    Messaggi
    70
    Purtroppo il percorso è giusto visto che inserendone un'altra nella stessa pagina funziona!
    Grazie comunque!!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.