// JP opened flex table

Click to See Complete Forum and Search --> : No applet html file produced.


zhshqzyc
March 24th, 2007, 12:19 PM
It works well in netbean, a snapshop is created. But I didn't see any applet html file in the folder c:\...\build\class

import javax.swing.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.Timestamp;

public class dbJava extends JApplet implements ActionListener{
public String login;
public String pwd;
private boolean isStandalone=false;
private JTextField jtfuser=new JTextField(5);
private TextField jtfpwd;

private JPanel jpanel1;
private JButton jbtLogin=new JButton("Login");
public Statement state, db2state;
// private medicalform newMf;
public static JFrame frame;

/** Creates a new instance of dbJava */
public dbJava() {

}

//initialize applet
public void init(){


initialize();
jtfpwd=new TextField(5);
jtfpwd.setEchoChar('*');

jpanel1=new JPanel();
jpanel1.add(new JLabel("User name"));
jpanel1.add(jtfuser);
jpanel1.add(new JLabel("Password"));
jpanel1.add(jtfpwd);
jpanel1.add(jbtLogin);

getContentPane().setLayout(new FlowLayout());
getContentPane().add(jpanel1, BorderLayout.NORTH);
jbtLogin.addActionListener(this);



}
private void initialize(){

try{

//load jbc driver
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver Loaded");

//Establish connection
Connection connection=DriverManager.getConnection("jdbc:mysql://localhost/books","root","000405");

System.out.println("Database connected");
//create statement
state=connection.createStatement();

}
catch(Exception ex){
ex.printStackTrace();
}

}

public void actionPerformed(ActionEvent e){

login=jtfuser.getText();
pwd=jtfpwd.getText();
try{
String query="select firstName, lastName from authors " + "where firstName = '" + login +"' and lastName = '"+pwd +"' ";

ResultSet rset=state.executeQuery(query);
if(rset.next()){
String user=rset.getString(1);
String pswd=rset.getString(2);
jpanel1.removeAll();

initialzeSecondDB();

}else
//Display if user not found
JOptionPane.showMessageDialog(null, "User not found");
}
catch(SQLException ex){
ex.printStackTrace();
}
}
void initialzeSecondDB(){
try{
close();
medicalform newMf=new medicalform();

}
catch(Exception ex){
ex.printStackTrace();
}

}
public void close(){

frame.setVisible(false);

}

public void init2(){


initialize();

jtfpwd=new TextField(5);
jtfpwd.setEchoChar('*');

jpanel1=new JPanel();
jpanel1.add(new JLabel("User name"));
jpanel1.add(jtfuser);
jpanel1.add(new JLabel("Password"));
jpanel1.add(jtfpwd);
jpanel1.add(jbtLogin);

jbtLogin.addActionListener(this);
// this.getContentPane().add(jpanel1, BorderLayout.NORTH);

frame=new JFrame();
dbJava applet=new dbJava();

applet.isStandalone=true;

// frame.getContentPane().add(applet, BorderLayout.NORTH);

applet.init();
// applet.start();



frame.setTitle("Medical Database");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,100);
frame.setVisible(true);

}
public static void main(String args[]){
//create frame
frame=new JFrame();
dbJava applet=new dbJava();

applet.isStandalone=true;

frame.getContentPane().add(applet, BorderLayout.EAST);

applet.init();
// applet.start();


frame.setTitle("Medical Database");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(400,100);
frame.setVisible(true);


}
}

zhshqzyc
March 24th, 2007, 03:33 PM
The xxx.html launcher file in the build folder is never found.

zhshqzyc
March 27th, 2007, 01:42 PM
Please help me. I just followed the simple example of the link,but no MyApplet.html is generated.

http://www.netbeans.org/kb/50/tutorial-applets.html#runanddebug

keang
March 27th, 2007, 02:02 PM
But I didn't see any applet html file in the folder c:\...\build\classAre you sure you are looking in the right place. The tutorial shows the applet html file will be created in the build directory and not the class subdirectory.

Note: it will only be called MyApplet.html if your applet class is called MyApplet.class

zhshqzyc
March 27th, 2007, 02:19 PM
keang, I tried a simple example, it doesn't work.
I use Netbeans and follow the link.
http://www.netbeans.org/kb/50/tutorial-applets.html#runanddebug
After I created MyApplet.jar in the dist folder,

Failed to load Main class manifest attibute from
C:\Documents and Settings\...\MyApplet.jar



Here is the code

package org.me.hello;

import java.applet.Applet;
import java.awt.Graphics;

public class MyApplet extends Applet {
public void paint(Graphics g) {
g.drawString("Hello applet!", 50, 25);
}
}

wwwillem
December 1st, 2007, 05:45 PM
The NetBeans Applet Tutorial is correct but more than a little confusion. Took me half an hour to figure it out.

Where it says "Right-click the applet class node in the Projects window and choose Run File from the contextual menu" what you have to do is:

1) click the "Projects" tab
2) locate "MyApplet.java"
3) right click that one and select "Run File" ("Run Project" is something different)

After that the MyApplet.html is generated. You will see it under the "Files" tab.

Willem

//JP added flex table