• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

load: GetMenuGui.class is not public or has no public constructor.

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK, code listed below compiles correctly but when I try to run the applet, I get this error:
load: GetMenuGui.class is not public or has no public constructor.
I'm mighty confused.
The HTML looks like this:
<APPLET CODE = "GetMenuGui.class"
WIDTH: 800 HEIGHT: 600 > </applet>
What am I missing?
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.lang.Object.*;
import java.net.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;

public class GetMenuGui extends JApplet {
String wTitle;
String theName = "New Eritrea";
Vector cities;
Connection conn;
ResultSet rs;
Color white = new Color(255, 255, 255);
Color lBlue = new Color(196, 210, 234);
Dimension sSize = getToolkit().getScreenSize();
Font ArialBold12 = new Font("Arial Bold", 1, 12);
Font Arial12 = new Font("Arial", 1, 12);
Font ArialBold20 = new Font("Arial Bold", 1, 20);
public void init() {
doConnect connect = new doConnect();
conn = connect.doConnect();
drawMain();
}

public void start() {
}

/**
* Draw the output
*/
void drawMain() {
setBackground(white);
JPanel mainPanel = new JPanel();
mainPanel.setBackground(white);
JPanel scrollPanel = new JPanel();
scrollPanel.setBackground(white);
scrollPanel.setSize(sSize.width, 100);
scrollPanel.setLayout(new BoxLayout(scrollPanel, BoxLayout.Y_AXIS));
rs = getRestData(conn, theName);
JPanel header = new JPanel();
header.add(getHeader(rs, conn));
JPanel entrees = new JPanel();
entrees.setLayout(new BoxLayout(entrees, BoxLayout.Y_AXIS));
rs = getMenuEntrees(conn, theName, "eapetizers");
entrees.add(getMenuLines(rs, "Appetizers"));
rs = getMenuEntrees(conn, theName, "eEntrees");
entrees.add(getMenuLines(rs, "Entrees"));
rs = getMenuEntrees(conn, theName, "evegetarian");
entrees.add(getMenuLines(rs, "Vegetarian"));
entrees.setBackground(white);
scrollPanel.add(entrees);
JScrollPane sPane = new JScrollPane(scrollPanel);
sPane.setBackground(lBlue);
sPane.setPreferredSize(new Dimension(sSize.width, (sSize.height - 185)));
mainPanel.setPreferredSize(new Dimension(sSize.width, (sSize.height - 30)));
mainPanel.add(header);
mainPanel.add(sPane);
getContentPane().add(mainPanel);
//pack();
}

/**
* Gets the menuEntees attribute of the GetMenuGui object
*
*@param conn Description of the Parameter
*@param theName Description of the Parameter
*@param tbName Description of the Parameter
*@return The menuEntees value
*/
ResultSet getMenuEntrees(Connection conn, String theName, String tbName) {
try {
Statement stmt = conn.createStatement();
String SQLStatement = "SELECT e.* FROM eRestaurants.";
SQLStatement = SQLStatement + tbName.trim() + " e,";
SQLStatement = SQLStatement +
"eRestaurants.eRestaurant r where ";
SQLStatement = SQLStatement +
"r.rest_id = e.rest_id and r.name = '" +
theName + "';";
System.out.println(SQLStatement);
ResultSet rs = stmt.executeQuery(SQLStatement);
return rs;
} catch (SQLException e) {
System.err.println(e.getMessage());
return null;
}
}

/**
* Gets the menuBooze attribute of the GetMenuGui object
*
*@param conn Description of the Parameter
*@param theName Description of the Parameter
*@return The menuBooze value
*/
ResultSet getMenuBooze(Connection conn, String theName) {
try {
Statement stmt = conn.createStatement();
String SQLStatement = "SELECT e.* FROM eRestaurants.ebooze e,";
SQLStatement = SQLStatement +
"eRestaurants.eRestaurant r where ";
SQLStatement = SQLStatement +
"r.rest_id = e.rest_id and r.name = '" +
theName + "';";
System.out.println(SQLStatement);
ResultSet rs = stmt.executeQuery(SQLStatement);
return rs;
} catch (SQLException e) {
System.err.println(e.getMessage());
return null;
}
}

/**
* Gets the restData attribute of the GetMenuGui object
*
*@param conn Description of the Parameter
*@param theName Description of the Parameter
*@return The restData value
*/
ResultSet getRestData(Connection conn, String theName) {
try {
Statement stmt = conn.createStatement();
String SQLStatement = "SELECT name, ";
SQLStatement = SQLStatement + " street1, ";
SQLStatement = SQLStatement + " street2,";
SQLStatement = SQLStatement + " city,";
SQLStatement = SQLStatement + " zip,";
SQLStatement = SQLStatement + " phone,";
SQLStatement = SQLStatement + " fax,";
SQLStatement = SQLStatement + " email,";
SQLStatement = SQLStatement + " wsite,";
SQLStatement = SQLStatement + " header,";
SQLStatement = SQLStatement + " blurb,";
SQLStatement = SQLStatement + " rest_id";
SQLStatement = SQLStatement + " FROM eRestaurants.eRestaurant";
SQLStatement = SQLStatement + " where name = '" + theName +
"';";
ResultSet rs = stmt.executeQuery(SQLStatement);
return rs;
} catch (SQLException e) {
System.err.println(e.getMessage());
return null;
}
}

/**
* Gets the menuParts attribute of the GetMenuGui object
*
*@param RS Description of the Parameter
*@param theType Description of the Parameter
*@return The menuParts value
*/
JPanel getMenuLines(ResultSet RS, String theType) {
JPanel theMenuPanel = new JPanel();
theMenuPanel.setLayout(new BoxLayout(theMenuPanel, BoxLayout.Y_AXIS));
JPanel theDishPanel = new JPanel();
JTextPane jtp = new JTextPane();
int row = 0;
boolean isFirst = true;
try {
while (RS.next()) {
if (isFirst) {
JPanel typePanel = new JPanel();
typePanel.setPreferredSize(new Dimension(sSize.width,
30));
JLabel theTypeLabel = new JLabel(theType);
theTypeLabel.setFont(ArialBold20);
typePanel.add(theTypeLabel);
typePanel.setBackground(white);
theMenuPanel.add(typePanel);
isFirst = false;
}
theDishPanel = new JPanel();
theDishPanel.setLayout(new BoxLayout(theDishPanel,
BoxLayout.X_AXIS));
jtp = new JTextPane();
jtp.setPreferredSize(new Dimension((int) (sSize.width * .2),
50));
String tText = ++row + " ) " + rs.getString("eName");
jtp.setText(tText.trim());
jtp.setFont(ArialBold12);
jtp.setEditable(false);
theDishPanel.add(jtp);
jtp = new JTextPane();
jtp.setPreferredSize(new Dimension((int) (sSize.width * .65), 50));
tText = rs.getString("eDescr");
jtp.setText(tText);
jtp.setFont(Arial12);
jtp.setEditable(false);
theDishPanel.add(jtp);
jtp = new JTextPane();
jtp.setPreferredSize(new Dimension((int) (sSize.width * .1), 50));
tText = rs.getString("ePrice");
jtp.setText(tText);
jtp.setFont(Arial12);
jtp.setEditable(false);
theDishPanel.add(jtp);
theDishPanel.setBackground(white);
theMenuPanel.add(theDishPanel);
}
theMenuPanel.setBackground(white);
return theMenuPanel;
} catch (SQLException eSql) {
System.err.println(eSql.getMessage());
}
return null;
}

/**
* Gets the header attribute of the GetMenuGui object
*
*@param RS Description of the Parameter
*@param conn Description of the Parameter
*@return The header value
*/
JPanel getHeader(ResultSet RS, Connection conn) {
JPanel theHeader = new JPanel();
theHeader.setLayout(new BoxLayout(theHeader, BoxLayout.X_AXIS));
theHeader.setPreferredSize(new Dimension(sSize.width, 125));
JTextPane header = new JTextPane();
header.setPreferredSize(new Dimension((int) (sSize.width * .75), 125));
String findUs = "";
String blurb = "";
String Street1 = "Address: ";
String Street2 = "";
String city = "";
String zip = "";
String phone = "Phone: ";
String fax = "Fax: ";
String email = "E-Mail: ";
String wSite = "Web Site: ";
ResultSet theImages;
int idRest = 0;
try {
while (RS.next()) {
if (RS.getString("street1") != null) {
findUs = Street1 + RS.getString("street1") + " ";
}
if (RS.getString("street2") != null) {
findUs = findUs + Street2 + RS.getString("street2") +
" ";
}
if (RS.getString("city") != null) {
findUs = findUs + city + RS.getString("city");
}
if (RS.getString("zip") != null) {
findUs = findUs + zip + ", " + RS.getString("zip");
}
if (RS.getString("phone") != null) {
findUs = findUs + "\n" + phone +
formatPhone(RS.getString("phone"));
}
if (RS.getString("fax") != null) {
findUs = findUs + " \n" + fax +
formatPhone(RS.getString("fax"));
}
if (RS.getString("email") != null) {
findUs = findUs + "\n" + email + RS.getString("email");
}
if (RS.getString("wSite") != null) {
findUs = findUs + "\n" + wSite + RS.getString("wSite");
}
if (RS.getString("blurb") != null) {
blurb = (RS.getString("blurb"));
}
try {
theImages = getImages(RS.getInt("rest_id"), conn);
while (theImages.next()) {
String theImage = theImages.getString("Img1Filename");
theImage = theImage.trim();
ImageIcon ii = new ImageIcon(new URL(theImage));
theHeader.add(new JLabel(resizeImage(ii)));
}
} catch (SQLException eSql2) {
System.err.println("SQL Error " + eSql2.getMessage());
} catch (MalformedURLException mal) {
System.err.println(
"Maformed URL Error " + mal.getMessage());
}
header.setFont(ArialBold12);
header.setText(findUs + "\n\n" + blurb);
header.setEditable(false);
JScrollPane theScroll = new JScrollPane(header);
theHeader.add(theScroll);
}
theHeader.setBackground(white);
return theHeader;
} catch (SQLException eSql) {
System.err.println(eSql.getMessage());
}
return null;
}

/**
* Gets the images attribute of the GetMenuGui object
*
*@param idRest Description of the Parameter
*@param conn Description of the Parameter
*@return The images value
*/
ResultSet getImages(int idRest, Connection conn) {
String SQLStatement = "";
ResultSet theImages;
try {
Statement stmt = conn.createStatement();
SQLStatement = "select Img1Filename,";
SQLStatement = SQLStatement + "Img2Filename ";
SQLStatement = SQLStatement + "from eRestaurants.eImages ";
SQLStatement = SQLStatement + "where idRest = " + idRest + ";";
theImages = stmt.executeQuery(SQLStatement);
return theImages;
} catch (SQLException e) {
System.err.println(e.getMessage());
return null;
}
}

/**
* Description of the Method
*
*@param phone Description of the Parameter
*@return Description of the Return Value
*/
String formatPhone(String phone) {
phone = phone.trim();
if (phone.length() > 0) {
return " (" + phone.substring(0, 3) + ") " +
phone.substring(3, 6) + "-" + phone.substring(6, 10);
}
return phone;
}

/**
* Description of the Method
*
*@param iIcon Description of the Parameter
*@return Description of the Return Value
*/
ImageIcon resizeImage(ImageIcon iIcon) {
Image iImage;
double iconWide = ((double) iIcon.getIconWidth() / (double) iIcon.getIconHeight());
iImage = iIcon.getImage();
iImage = iImage.getScaledInstance((int) (125 * iconWide), 125, 1);
iIcon = new ImageIcon(iImage);
return iIcon;
}
}
[ May 15, 2003: Message edited by: Tod Sterben ]
 
Could you hold this kitten for a sec? I need to adjust this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic