The Artima Developer Community
Sponsored Link •

Java Answers Forum
what won't my applet run

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
natasha henry

Posts: 2
Nickname: ghettoslim
Registered: Apr, 2007

what won't my applet run Posted: Apr 11, 2007 9:25 PM
Reply to this message Reply
Advertisement
hey its me again-pretty gurl ghettoslim..i have another problem that doesn't really involve the issue of functionality but is rather a problem of my applet not showing. i know about the<html> <applet code=.........></applet> etc. to create an html so that the applet can be loaded. the only problem is that my java software-shelly cashman, doesn't have a JCreator or other feature that enables one to convert such a file to html. it has a more convenient feature but one that i cannot quite understand. whenever you go the the newoption there is the applet icon to pick from and this automatically creates something like(for example):

applet.WelcomeApplet.html
WelcomeApplet.java

however the only one that can be edited is WelcomeApplet.java
In this class i have the constructors and methods but i cannot compile this to produce an onscreen interface. therefore i go for the tester/sub-class WelcomeWindow but for me to do that i have to go through the same process like with the WelcomeApplet in creating a class. therefore in essence i have:

applet.WelcomeApplet.html
applet.WelcomeWindow.html
WelcomeApplet.java
W elcomeWindow.java
and still the same problem!!!!!!!!

HERE IS THE CODE

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.*;
import javax.swing.JButton;
import java.awt.BorderLayout;
import javax.swing.ButtonGroup;
import java.lang.String;
import java.awt.*;
import javax.swing.JApplet;
import java.awt.event.*;
import java.awt.Color;

public class Welcome extends JApplet implements ActionListener
{
private JLabel welcmLabel;
private JLabel reqLabel;
private JLabel usernameLabel;
private JLabel passwordLabel;
private JPanel Row;
public JTextField usernameField;
public JPasswordField passwordField;
public JButton Ok;
public JButton Exit;
private JApplet applet;
private String username;
private String password;
private String string1;
private String string2;

public void init()
{
JPanel Row= new JPanel();
//Construct buttons
JButton Ok=new JButton("OK");
JButton Exit= new JButton("EXIT");

//Construct label for each panel
JLabel welcmLabel=new JLabel("!!!!!!!!WELCOME!!!!!!!!!!");
JLabel reqLabel=new JLabel("Please enter your:");

//Construct label and fields
JTextField usernameField=new JTextField("Username");
usernameField.setEditable(false);
Row.add(usernameField);
JTextField passwordField=new JTextField("Password");
passwordField.setEditable(false);
Row.add(passwordField);
}
{
applet.add(welcmLabel,BorderLayout.NORTH);
applet.add(reqLabel,BorderLayout.AFTER_LAST_LINE);
applet.add(usernameField,BorderLayout.WEST);
applet.add(passwordField,BorderLayout.WEST);
applet.add(Ok);
applet.add(Exit);
applet.add(Row);
Row.add(welcmLabel);
Row.add(reqLabel);
Row.add(usernameField);
Row.add(passwordField);
usernameField.addActionListener(this);
passwordField.addActionListener(this); }
public void actionPerformed(ActionEvent e)
{
username=(usernameField.getSelectedText());
password=(passwordField.getSelectedText());
{
string1=("nymphospeed"); //declare string to display
string2=("vipuser"); //declare string to display

//condition to validate correct username and password entry
if(username==string2 && password==string1)

System.out.println("C...O..N..G..R...A...T...U...L...A...T...I...O...N...S!/n You now have access to ANDREW'S AUTOSYSTEM");

else

System.out.println("Incorrect, Please re-enter a valid password and/or username");
}
} //end if

}



TESTER CLASS

package applet2;

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import javax.swing.*;
import applet.WelcomeApplet;

i accented out the bulk of these lines bcuz i don't understand them...these automatically opened with both applet classes upon just starting...could these be the key? the codes that i have before and after these lines is what i compile
/*public class WelcomeWindow extends {
boolean isStandalone = false;

//Construct the applet
public WelcomeWindow() {
}

//Initialize the applet
public void init() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}

//Component initialization
private void jbInit() throws Exception {
this.setSize(new Dimension(400,300));
}

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

//Get parameter info
public String[][] getParameterInfo() {
return null;
}
// static initializer for setting look & feel
static {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch (Exception e) {}
}

} */

public class WelcomeWindow extends WelcomeApplet
{
public static void main(String args[])

{
WelcomeApplet window=new WelcomeApplet();
window.setName("ANDREW'S AUTOSYSTEM");
window.setSize(250,250);
window.setBackground(Color.pink.black.blue);
window.setVisible(true);
}}

Topic: what won't my applet run Previous Topic   Next Topic Topic: good sites for java tutorial

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use