At a total loss with this code...

So i'm working on this applet for work and im lost. in the end, this will be a cash register type app thats integrated with our web database. as of right now, the code to download an html page works fine when run by itself, independent of the main class. but when the download PageDownload class is called from the sales class (the main class), i get this error:
register/sales.java [245:1] unreported exception java.lang.Exception; must be caught or declared to be thrown
pagey.main(null);
what's my problem?
-------------------------SALES.java----------------------------
* sales.java
* Created on December 6, 2003, 1:34 PM
package register;
import javax.swing.* ;
import java.util.*;
import java.lang.*;
import java.text.*;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.JComboBox.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.net.*;
import java.io.*;
* @author Geoff
public class sales extends java.applet.Applet {
/** Initializes the applet sales */
public void init() {
initComponents();
//private boolean DEBUG = false;
//Set the lblDate to contain today's date in mm/dd/yy format
Date today;
String dateOut;
DateFormat dateFormatter;
dateFormatter = DateFormat.getDateInstance(DateFormat.SHORT);
today = new Date();
dateOut = dateFormatter.format(today);
lblDate.setText(dateOut);
//set up the payment method choice box
cmbPaymentMethod.add("American Express");
cmbPaymentMethod.add("Cash");
cmbPaymentMethod.add("Check");
cmbPaymentMethod.add("Discover");
cmbPaymentMethod.add("Gift Card");
cmbPaymentMethod.add("Master Card");
cmbPaymentMethod.add("Visa");
JTable table = new JTable(new MyTableModel());
table.setPreferredScrollableViewportSize(new Dimension(500, 70));
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//Add the scroll pane to this panel.
add(scrollPane);
scrollPane.setBounds(0, 165, 600, 200);
scrollPane.setVisible(true);
TableColumn sysCol = table.getColumnModel().getColumn(0);
sysCol.setWidth(120);
sysCol.setMaxWidth(120);
TableColumn conCol = table.getColumnModel().getColumn(2);
conCol.setWidth(60);
conCol.setMaxWidth(60);
TableColumn qtyCol = table.getColumnModel().getColumn(3);
qtyCol.setWidth(40);
qtyCol.setMaxWidth(40);
TableColumn rateCol = table.getColumnModel().getColumn(4);
rateCol.setWidth(60);
rateCol.setMaxWidth(60);
TableColumn amtCol = table.getColumnModel().getColumn(5);
amtCol.setWidth(60);
amtCol.setMaxWidth(60);
class MyTableModel extends AbstractTableModel {
private String[] columnNames = {"System",
"Item",
"Contents",
"Qty.",
"Rate",
"Amount"};
private Object[][] data = {
public int getColumnCount() {
return columnNames.length;
public int getRowCount() {
return data.length;
public String getColumnName(int col) {
return columnNames[col];
public Object getValueAt(int row, int col) {
return data[row][col];
* JTable uses this method to determine the default renderer/
* editor for each cell. If we didn't implement this method,
* then the last column would contain text ("true"/"false"),
* rather than a check box.
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
* Don't need to implement this method unless your table's
* editable.
public boolean isCellEditable(int row, int col) {
//Note that the data/cell address is constant,
//no matter where the cell appears onscreen.
if (col < 2) {
return false;
} else {
return true;
* Don't need to implement this method unless your table's
* data can change.
public void setValueAt(Object value, int row, int col) {
//if (DEBUG) {
System.out.println("Setting value at " + row + "," + col
+ " to " + value
+ " (an instance of "
+ value.getClass() + ")");
data[row][col] = value;
fireTableCellUpdated(row, col);
/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
private void initComponents() {
label1 = new java.awt.Label();
txtSoldTo = new java.awt.TextArea();
label2 = new java.awt.Label();
lblDate = new java.awt.Label();
label4 = new java.awt.Label();
txtSoldBy = new java.awt.TextField();
label3 = new java.awt.Label();
lblSaleNumber = new java.awt.Label();
lblPaymentMethod = new java.awt.Label();
cmbPaymentMethod = new java.awt.Choice();
jButton1 = new javax.swing.JButton();
setLayout(null);
label1.setFont(new java.awt.Font("Dialog", 1, 12));
label1.setText("Sold To:");
add(label1);
label1.setBounds(10, 10, 50, 20);
add(txtSoldTo);
txtSoldTo.setBounds(10, 30, 180, 80);
label2.setFont(new java.awt.Font("Dialog", 1, 12));
label2.setText("Date:");
add(label2);
label2.setBounds(410, 10, 38, 20);
lblDate.setAlignment(java.awt.Label.CENTER);
lblDate.setText("dategoeshere");
add(lblDate);
lblDate.setBounds(390, 30, 90, 20);
label4.setFont(new java.awt.Font("Dialog", 1, 12));
label4.setText("Sold By:");
add(label4);
label4.setBounds(500, 70, 50, 20);
add(txtSoldBy);
txtSoldBy.setBounds(500, 90, 50, 20);
label3.setFont(new java.awt.Font("Dialog", 1, 12));
label3.setText("Sale No.");
add(label3);
label3.setBounds(500, 10, 50, 20);
lblSaleNumber.setAlignment(java.awt.Label.CENTER);
lblSaleNumber.setText("0");
add(lblSaleNumber);
lblSaleNumber.setBounds(490, 30, 70, 20);
lblPaymentMethod.setFont(new java.awt.Font("Dialog", 1, 12));
lblPaymentMethod.setText("Payment Method");
add(lblPaymentMethod);
lblPaymentMethod.setBounds(380, 70, 100, 20);
add(cmbPaymentMethod);
cmbPaymentMethod.setBounds(380, 90, 100, 20);
jButton1.setText("jButton1");
jButton1.setActionCommand("GO");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
add(jButton1);
jButton1.setBounds(210, 100, 81, 26);
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// Add your handling code here:
if( evt.getActionCommand().equals("GO")) {
PageDownload pagey = new PageDownload();
System.out.println("PageDownload created.");
pagey.main(null);
private String thepage;
// Variables declaration - do not modify
private java.awt.Choice cmbPaymentMethod;
private javax.swing.JButton jButton1;
private java.awt.Label label1;
private java.awt.Label label2;
private java.awt.Label label3;
private java.awt.Label label4;
private java.awt.Label lblDate;
private java.awt.Label lblPaymentMethod;
private java.awt.Label lblSaleNumber;
private java.awt.TextField txtSoldBy;
private java.awt.TextArea txtSoldTo;
// End of variables declaration
----------------------------PageDownload.java------------------------
package register;
* @author Geoff
import java.net.*;
import java.io.*;
import javax.swing.*;
import java.lang.Exception;
public class PageDownload extends java.applet.Applet {
/** Creates a new instance of PageDownload */
public PageDownload() {
public static void main(String[] args) throws Exception {
URL url = new URL("http://www.awebsite.com");
InputStream html = url.openStream();
int c = 0;
String a = "";
while(c != -1) {
a = "";
c = html.read();
if(c == (char)60) {
while(c != (char)62) {
a = a + (char)c;
c = html.read();
if(a == "") {}
else
System.out.println(a + ">");

Your PageDownload code has no non-static code other than the blank class instantiator. You shouldn't be calling a static method from an instance of the class. You could just as easily say:
PageDownload.main(null);
instead of:
PageDownload pagey = new PageDownload();
pagey.main(null);
the PageDownload class needs no instance since it has no object code of any value.
Re-think the design a bit, the pattern looks bad.
If your intention for the PageDownload class was to create a singleton then search the tutorials for the proper way to construct singletons, also decide wether or not you need this class to be a singleton.
Also output some of the error information to help diagnose what exactly is wrong with the URL, ie, try to output the URL, maybe it's blank

Similar Messages

  • What is wrong with this code? on(release) gotoAndPlay("2")'{'

    Please could someone tell me what is wrong with this code - on(release)
    gotoAndPlay("2")'{'
    this is the error that comes up and i have tried changing it but it is not working
    **Error** Scene=Scene 1, layer=Layer 2, frame=1:Line 2: '{' expected
         gotoAndPlay("2")'{'
    Total ActionScript Errors: 1 Reported Errors: 1
    Thanks

    If you have a frame labelled "2" then it should be:
    on (release) {
        this._parent.gotoAndPlay("2");
    or other wise just the following to go to frame 2:
    on (release) {
         this._parent.gotoAndPlay(2);
    You just had a missing curly bracket...

  • I can't figure out what's wrong with this code

    First i want this program to allow me to enter a number with the EasyReader class and depending on the number entered it will show that specific line of this peom:
    One two buckle your shoe
    Three four shut the door
    Five six pick up sticks
    Seven eight lay them straight
    Nine ten this is the end.
    The error message i got was an illegal start of expression. I can't figure out why it is giving me this error because i have if (n = 1) || (n = 2) statements. My code is:
    public class PoemSeventeen
    public static void main(String[] args)
    EasyReader console = new EasyReader();
    System.out.println("Enter a number for the poem (0 to quit): ");
    int n = console.readInt();
    if (n = 1) || (n = 2)
    System.out.println("One, two, buckle your shoe");
    else if (n = 3) || (n = 4)
    System.out.println("Three, four, shut the door");
    else if (n = 5) || (n = 6)
    System.out.println("Five, six, pick up sticks");
    else if (n = 7) || (n = 8)
    System.out.println("Seven, eight, lay them straight");
    else if (n = 9) || (n = 10)
    System.out.println("Nine, ten, this is the end");
    else if (n = 0)
    System.out.println("You may exit now");
    else
    System.out.println("Put in a number between 0 and 10");
    I messed around with a few other thing because i had some weird errors before but now i have narrowed it down to just this 1 error.
    The EasyReader class code:
    // package com.skylit.io;
    import java.io.*;
    * @author Gary Litvin
    * @version 1.2, 5/30/02
    * Written as part of
    * <i>Java Methods: An Introduction to Object-Oriented Programming</i>
    * (Skylight Publishing 2001, ISBN 0-9654853-7-4)
    * and
    * <i>Java Methods AB: Data Structures</i>
    * (Skylight Publishing 2003, ISBN 0-9654853-1-5)
    * EasyReader provides simple methods for reading the console and
    * for opening and reading text files. All exceptions are handled
    * inside the class and are hidden from the user.
    * <xmp>
    * Example:
    * =======
    * EasyReader console = new EasyReader();
    * System.out.print("Enter input file name: ");
    * String fileName = console.readLine();
    * EasyReader inFile = new EasyReader(fileName);
    * if (inFile.bad())
    * System.err.println("Can't open " + fileName);
    * System.exit(1);
    * String firstLine = inFile.readLine();
    * if (!inFile.eof()) // or: if (firstLine != null)
    * System.out.println("The first line is : " + firstLine);
    * System.out.print("Enter the maximum number of integers to read: ");
    * int maxCount = console.readInt();
    * int k, count = 0;
    * while (count < maxCount && !inFile.eof())
    * k = inFile.readInt();
    * if (!inFile.eof())
    * // process or store this number
    * count++;
    * inFile.close(); // optional
    * System.out.println(count + " numbers read");
    * </xmp>
    public class EasyReader
    protected String myFileName;
    protected BufferedReader myInFile;
    protected int myErrorFlags = 0;
    protected static final int OPENERROR = 0x0001;
    protected static final int CLOSEERROR = 0x0002;
    protected static final int READERROR = 0x0004;
    protected static final int EOF = 0x0100;
    * Constructor. Prepares console (System.in) for reading
    public EasyReader()
    myFileName = null;
    myErrorFlags = 0;
    myInFile = new BufferedReader(
    new InputStreamReader(System.in), 128);
    * Constructor. opens a file for reading
    * @param fileName the name or pathname of the file
    public EasyReader(String fileName)
    myFileName = fileName;
    myErrorFlags = 0;
    try
    myInFile = new BufferedReader(new FileReader(fileName), 1024);
    catch (FileNotFoundException e)
    myErrorFlags |= OPENERROR;
    myFileName = null;
    * Closes the file
    public void close()
    if (myFileName == null)
    return;
    try
    myInFile.close();
    catch (IOException e)
    System.err.println("Error closing " + myFileName + "\n");
    myErrorFlags |= CLOSEERROR;
    * Checks the status of the file
    * @return true if en error occurred opening or reading the file,
    * false otherwise
    public boolean bad()
    return myErrorFlags != 0;
    * Checks the EOF status of the file
    * @return true if EOF was encountered in the previous read
    * operation, false otherwise
    public boolean eof()
    return (myErrorFlags & EOF) != 0;
    private boolean ready() throws IOException
    return myFileName == null || myInFile.ready();
    * Reads the next character from a file (any character including
    * a space or a newline character).
    * @return character read or <code>null</code> character
    * (Unicode 0) if trying to read beyond the EOF
    public char readChar()
    char ch = '\u0000';
    try
    if (ready())
    ch = (char)myInFile.read();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (ch == '\u0000')
    myErrorFlags |= EOF;
    return ch;
    * Reads from the current position in the file up to and including
    * the next newline character. The newline character is thrown away
    * @return the read string (excluding the newline character) or
    * null if trying to read beyond the EOF
    public String readLine()
    String s = null;
    try
    s = myInFile.readLine();
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    if (s == null)
    myErrorFlags |= EOF;
    return s;
    * Skips whitespace and reads the next word (a string of consecutive
    * non-whitespace characters (up to but excluding the next space,
    * newline, etc.)
    * @return the read string or null if trying to read beyond the EOF
    public String readWord()
    StringBuffer buffer = new StringBuffer(128);
    char ch = ' ';
    int count = 0;
    String s = null;
    try
    while (ready() && Character.isWhitespace(ch))
    ch = (char)myInFile.read();
    while (ready() && !Character.isWhitespace(ch))
    count++;
    buffer.append(ch);
    myInFile.mark(1);
    ch = (char)myInFile.read();
    if (count > 0)
    myInFile.reset();
    s = buffer.toString();
    else
    myErrorFlags |= EOF;
    catch (IOException e)
    if (myFileName != null)
    System.err.println("Error reading " + myFileName + "\n");
    myErrorFlags |= READERROR;
    return s;
    * Reads the next integer (without validating its format)
    * @return the integer read or 0 if trying to read beyond the EOF
    public int readInt()
    String s = readWord();
    if (s != null)
    return Integer.parseInt(s);
    else
    return 0;
    * Reads the next double (without validating its format)
    * @return the number read or 0 if trying to read beyond the EOF
    public double readDouble()
    String s = readWord();
    if (s != null)
    return Double.parseDouble(s);
    // in Java 1, use: return Double.valueOf(s).doubleValue();
    else
    return 0.0;
    Can anybody please tell me what's wrong with this code? Thanks

    String[] message = {
        "One, two, buckle your shoe",
        "One, two, buckle your shoe",
        "Three, four, shut the door",
        "Three, four, shut the door",
        "Five, six, pick up sticks",
        "Five, six, pick up sticks",
        "Seven, eight, lay them straight",
        "Seven, eight, lay them straight",
        "Nine, ten, this is the end",
        "Nine, ten, this is the end"
    if(n>0)
        System.out.println(message[n]);
    else
        System.exit(0);

  • Can anybody help me to build an interface that can work with this code

    please help me to build an interface that can work with this code
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    public class Translate
    public static void main(String [] args) throws IOException
    if (args.length != 2)
    System.err.println("usage: Translate wordmapfile textfile");
    System.exit(1);
    try
    HashMap words = ReadHashMapFromFile(args[0]);
    System.out.println(ProcessFile(words, args[1]));
    catch (Exception e)
    e.printStackTrace();
    // static helper methods
    * Reads a file into a HashMap. The file should contain lines of the format
    * "key\tvalue\n"
    * @returns a hashmap of the given file
    @SuppressWarnings("unchecked")
    private static HashMap ReadHashMapFromFile(String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    HashMap map = null;
    try
    in = new BufferedReader(new FileReader(filename));
    String line;
    map = new HashMap();
    while ((line = in.readLine()) != null)
    String[] fields = line.split("
    t", 2);
    if (fields.length != 2) continue; //just ignore "invalid" lines
    map.put(fields[0], fields[1]);
    finally
    if(in!=null) in.close(); //may throw IOException
    return(map); //returning a reference to local variable is safe in java (unlike C/C++)
    * Process the given file
    * @returns String contains the whole file.
    private static String ProcessFile(Map words, String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    StringBuffer out = null;
    try
    in = new BufferedReader(new FileReader(filename));
    out = new StringBuffer();
    String line = null;
    while( (line=in.readLine()) != null )
    out.append(SearchAndReplaceWordsInText(words, line)+"\n");
    finally
    if(in!=null) in.close(); //may throw IOException
    return out.toString();
    * Replaces all occurrences in text of each key in words with it's value.
    * @returns String
    private static String SearchAndReplaceWordsInText(Map words, String text)
    Iterator it = words.keySet().iterator();
    while( it.hasNext() )
    String key = (String)it.next();
    text = text.replaceAll("\\b"key"
    b", (String)words.get(key));
    return text;
    * @returns: s with the first letter capitalized
    String capitalize(String s)
    return s.substring(0,0).toUpperCase() + s.substring(1);
    }... here's the head of my pirate_words_map.txt
    hello               ahoy
    hi                    yo-ho-ho
    pardon me       avast
    excuse me       arrr
    yes                 aye
    my                 me
    friend             me bucko
    sir                  matey
    madam           proud beauty
    miss comely    wench
    where             whar
    is                    be
    are                  be
    am                  be
    the                  th'
    you                 ye
    your                yer
    tell                be tellin'

    please help me i don t know how to go about this.my teacher ask me to build an interface that work with the code .
    Here is the interface i just build
    import java.util.Map;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.awt.*;
    import javax.swing.*;
    public class boy extends JFrame
    JTextArea englishtxt;
    JLabel head,privatetxtwords;
    JButton translateengtoprivatewords;
    Container c1;
    public boy()
            super("HAKIMADE");
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            setBackground(Color.white);
            setLocationRelativeTo(null);
            c1 = getContentPane();
             head = new JLabel(" English to private talk Translator");
             englishtxt = new JTextArea("Type your text here", 10,50);
             translateengtoprivatewords = new JButton("Translate");
             privatetxtwords = new JLabel();
            JPanel headlabel = new JPanel();
            headlabel.setLayout(new FlowLayout(FlowLayout.CENTER));
            headlabel.add(head);
            JPanel englishtxtpanel = new JPanel();
            englishtxtpanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,40));
            englishtxtpanel.add(englishtxt);
             JPanel panel1 = new JPanel();
             panel1.setLayout(new BorderLayout());
             panel1.add(headlabel,BorderLayout.NORTH);
             panel1.add(englishtxtpanel,BorderLayout.CENTER);
            JPanel translateengtoprivatewordspanel = new JPanel();
            translateengtoprivatewordspanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,40));
            translateengtoprivatewordspanel.add(translateengtoprivatewords);
             JPanel panel2 = new JPanel();
             panel2.setLayout(new BorderLayout());
             panel2.add(translateengtoprivatewordspanel,BorderLayout.NORTH);
             panel2.add(privatetxtwords,BorderLayout.CENTER);
             JPanel mainpanel = new JPanel();
             mainpanel.setLayout(new BorderLayout());
             mainpanel.add(panel1,BorderLayout.NORTH);
             mainpanel.add(panel2,BorderLayout.CENTER);
             c1.add(panel1, BorderLayout.NORTH);
             c1.add(panel2);
    public static void main(final String args[])
            boy  mp = new boy();
             mp.setVisible(true);
    }..............here is the code,please make this interface work with the code
    public class Translate
    public static void main(String [] args) throws IOException
    if (args.length != 2)
    System.err.println("usage: Translate wordmapfile textfile");
    System.exit(1);
    try
    HashMap words = ReadHashMapFromFile(args[0]);
    System.out.println(ProcessFile(words, args[1]));
    catch (Exception e)
    e.printStackTrace();
    // static helper methods
    * Reads a file into a HashMap. The file should contain lines of the format
    * "key\tvalue\n"
    * @returns a hashmap of the given file
    @SuppressWarnings("unchecked")
    private static HashMap ReadHashMapFromFile(String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    HashMap map = null;
    try
    in = new BufferedReader(new FileReader(filename));
    String line;
    map = new HashMap();
    while ((line = in.readLine()) != null)
    String[] fields = line.split("
    t", 2);
    if (fields.length != 2) continue; //just ignore "invalid" lines
    map.put(fields[0], fields[1]);
    finally
    if(in!=null) in.close(); //may throw IOException
    return(map); //returning a reference to local variable is safe in java (unlike C/C++)
    * Process the given file
    * @returns String contains the whole file.
    private static String ProcessFile(Map words, String filename) throws FileNotFoundException, IOException
    BufferedReader in = null;
    StringBuffer out = null;
    try
    in = new BufferedReader(new FileReader(filename));
    out = new StringBuffer();
    String line = null;
    while( (line=in.readLine()) != null )
    out.append(SearchAndReplaceWordsInText(words, line)+"\n");
    finally
    if(in!=null) in.close(); //may throw IOException
    return out.toString();
    * Replaces all occurrences in text of each key in words with it's value.
    * @returns String
    private static String SearchAndReplaceWordsInText(Map words, String text)
    Iterator it = words.keySet().iterator();
    while( it.hasNext() )
    String key = (String)it.next();
    text = text.replaceAll("\\b"key"
    b", (String)words.get(key));
    return text;
    * @returns: s with the first letter capitalized
    String capitalize(String s)
    return s.substring(0,0).toUpperCase() + s.substring(1);
    }... here's the head of my pirate_words_map.txt
    hello               ahoy
    hi                    yo-ho-ho
    pardon me       avast
    excuse me       arrr
    yes                 aye
    my                 me
    friend             me bucko
    sir                  matey
    madam           proud beauty
    miss comely    wench
    where             whar
    is                    be
    are                  be
    am                  be
    the                  th'
    you                 ye
    your                yer
    tell                be tellin'

  • Can anybody help me with this code?

    I am a beginner to J2ME. The following is a small program I wrote just for test.
    Theoretically, in my opinion, I shall see in the screen a number increase from 1 to 29999 rapidly after execute the code. But instead, it displays nothing but only displays 29999 after several seconds . Can some body point out what's wrong with this code? Thanks.
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    public class Test extends MIDlet{
    int x=1;
    String b="";
    private Display display;
    public Test() {
    display = Display.getDisplay(this);
    public void startApp() {
    MyCanvas mc = new MyCanvas() ;
    display.setCurrent(mc) ;
    while(x<30000){
    b=String.valueOf(x);
    mc.repaint();
    x++;
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    class MyCanvas extends Canvas{
    public void paint(Graphics g){
    g.drawString(b,10,10,0);

    thanks, I have already got the answer. you are right, if repaint in a high speed the screen will show nothing. here is the code for it, thanks the expert of nokia forum.
    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    //Counter
    //Need to know when a number has been painted and need to wait a for a fraction of a sec before
    //painting the next number. This wait also allows other events like "Exit" to be processed
    //Use double buffering to avoid flicker
    //Paint in a different thread to keep the UI responsive
    public class MyMIDlet extends MIDlet{
    int x=1;
    String b="";
    private Display display;
    Thread t = null;
    MyCanvas mc = null;
    public MyMIDlet() {
    display = Display.getDisplay(this);
    public void startApp() {
    mc = new MyCanvas();
    t = new Thread(mc) ;
    display.setCurrent(mc) ;
    b=String.valueOf(x);
    t.start();
    public void callbackPaintDone(){
    try{
    //provides the delay between every repaint and also time to react to Exit
    synchronized(this){
    wait(1);
    }catch(Exception e){}
    paintNextNumber();
    private void paintNextNumber(){
    if(x<30000){
    x++;
    b=String.valueOf(x);
    mc.doPaint = true; //signals that next number can be painted
    public void pauseApp() {
    public void destroyApp(boolean unconditional) {
    class MyCanvas extends Canvas implements Runnable{
    Image buf = null;
    Graphics bg = null;
    public boolean doPaint = true;
    public MyCanvas(){
    buf = Image.createImage(getWidth(),getHeight());
    bg = buf.getGraphics();
    public void paint(Graphics g){
    bg.setColor(255,255,255);
    bg.fillRect(0,0,getWidth(),getHeight());
    bg.setColor(0);
    bg.drawString(b,10,10,0);
    g.drawImage(buf,10,10,Graphics.TOP|Graphics.LEFT);
    // Callback for next number to be painted
    MyMIDlet.this.callbackPaintDone();
    public void run(){
    while(true){
    if(doPaint){ //only paints when a number has been painted, and next one is ready to be painted
    doPaint = false;
    repaint();
    serviceRepaints();

  • Can somebody help me with this code?

    Can anyone help me with this code? My problem is that i can't
    seem to position this form, i want to be able to center it
    vertically & horizontally in a div either using CSS or any
    other means.
    <div id="searchbar"><!--Search Bar -->
    <div id="searchcart">
    <div class="serchcartcont">
    <form action='
    http://www.romancart.com/search.asp'
    name="engine" target=searchwin id="engine">
    <input type=hidden value=????? name=storeid>
    <input type=text value='' name=searchterm>
    <input type=submit value='Go'> </form>
    </div>
    </div>
    <div class="searchcont">Search For
    Products:</div>
    </div><!-- End Search Bar -->
    Pleasssssseeeeeeee Help
    Thanks

    Hi,
    Your form is defined in a div named "serchcartcont", you can
    use attributes like position and align of the div to do what you
    want to do. But there are two more dives above this dive, you will
    have define the height width of these before you can center align
    the inner most div. If you are not defining the height & width
    then by default it decide it automatically to just fit the content
    in it.
    Hope this helps.
    Maneet
    LeXolution IT Services
    Web Development
    Company

  • Please tell me what is the problem with this code

    Hai,
    Iam new to Swings. can any one tell what is the problem with this code. I cant see those controls on the frame. please give me the suggestions.
    I got the frame ,but the controls are not.
    this is the code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ex2 extends JFrame
    JButton b1;
    JLabel l1,l2;
    JPanel p1,p2;
    JTextField tf1;
    JPasswordField tf2;
    public ex2()
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setTitle("Another example");
    setSize(500,500);
    setVisible(true);
    b1=new JButton(" ok ");
    p1=new JPanel();
    p1.setLayout(new GridLayout(2,2));
    p2=new JPanel();
    p2.setLayout(new BorderLayout());
    l1=new JLabel("Name :");
    l2=new JLabel("Password:");
    tf1=new JTextField(15);
    tf2=new JPasswordField(15);
    Container con=getContentPane();
    con.add(p1);
    con.add(p2);
    public static void createAndShowGUI()
    ex2.setDefaultLookAndFeelDecorated(true);
    public static void main(String ar[])
    createAndShowGUI();
    new ex2();
    }

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ex2 extends JFrame
        JButton b1;
        JLabel l1,l2;
        JPanel p1,p2;
        JTextField tf1;
        JPasswordField tf2;
        public ex2()
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            setTitle("Another example");
            b1=new JButton(" ok ");
            p1=new JPanel();
            p1.add(b1);
            p2=new JPanel();
            p2.setLayout(new GridLayout(2,2));
            l1=new JLabel("Name :");
            l2=new JLabel("Password:");
            tf1=new JTextField(15);
            tf2=new JPasswordField(15);
            p2.add(l1);
            p2.add(tf1);
            p2.add(l2);
            p2.add(tf2);
            Container con=getContentPane();
            con.add(p1, BorderLayout.NORTH);
            con.add(p2, BorderLayout.CENTER);
            pack();
            setVisible(true);
        public static void createAndShowGUI()
            ex2.setDefaultLookAndFeelDecorated(true);
        public static void main(String ar[])
            createAndShowGUI();
            new ex2();
    }

  • Vector, what is the problem with this code?

    Vector, what is the problem with this code?
    63  private java.util.Vector data=new Vector();
    64  Vector aaaaa=new Vector();
    65   data.addElement(aaaaa);
    74  aaaaa.addElement(new String("Mary"));on compiling this code, the error is
    TableDemo.java:65: <identifier> expected
                    data.addElement(aaaaa);
                                   ^
    TableDemo.java:74: <identifier> expected
                    aaaaa.addElement(new String("Mary"));
                                    ^
    TableDemo.java:65: package data does not exist
                    data.addElement(aaaaa);
                        ^
    TableDemo.java:74: package aaaaa does not exist
                    aaaaa.addElement(new String("Mary"));Friends i really got fed up with this code for more than half an hour.could anybody spot the problem?

    I can see many:
    1. i assume your code snip is inside a method. a local variable can not be declare private.
    2. if you didn't import java.util.* on top then you need to prefix package on All occurance of Vector.
    3. String in java are constant and has literal syntax. "Mary" is sufficient in most of the time, unless you purposly want to call new String("Mary") on purpose. Read java.lang.String javadoc.
    Here is a sample that would compile...:
    public class QuickMain {
         public static void main(String[] args) {
              java.util.Vector data=new java.util.Vector();
              java.util.Vector aaaaa=new java.util.Vector();
              data.addElement(aaaaa);
              aaaaa.addElement(new String("Mary"));
    }

  • Whath is wrong with this code???

    Whath is wrong with this code:
    import java.sql.*;
    class DataBaseConnexion
    Connection connexion;
    String url;
    DataBaseConnexion()
    {// 1-charger le driver JDBC-ODBC
    try
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    System.out.println("chargement du driver r�ussi");
    catch(ClassNotFoundException exc) {
    System.out.println("Erreur de chargement du pilote !");
    }// d�finir le pseudo URL pour joindre la BD
    url = "jdbc:odbc:cdi";//2- se connecter � la base de donn�es
    try {
    connexion = DriverManager.getConnection(url, "user_name", "pass_word");
    System.out.println("connexion r�ussie");
    catch(SQLException exc){
    System.out.println("Erreur 1 ! - " + exc.toString());
    public static void main(String Arg[])
    DataBaseConnexion db = new DataBaseConnexion();
    }//this errors occure
    File "C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java" Line 40: Syntax Error
    ---------------- JDK Release Build ------------------
    Compiling C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java
    C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java:40: 'class' or 'interface' expected
    public static void main(String Arg[])
    ^
    C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java:45: 'class' or 'interface' expected
    ^
    C:\Documents and Settings\Administrateur\Bureau\DataBaseConnexion.java:47: 'class' or 'interface' expected
    ^
    3 errors
    Finished

    I think you should remove the last closing curly brackets two lines above the main method.
    Regards

  • Can anyone help with this code

    i am trying to create a html5 video gallery for my website  I was wondering if anyone can help me with this code :  Am i missing something got this from the adobe widget browser i can get the button fuctions but i can not seem to get the video to play or work.. 

    This is the full page i am still working on it but the video code which i posted earlier is not working...    
    123456789101112131415
    Home
    Biography
    To Be Lead
    Gallery
    Videos
    Memorial Page
    Wallpaper
    Blog
    Forum
    Contact
    Randy Savage Bio
    Randy's Facts 101
    His Early Career
    Randy's Career in the WWF
    Randy's Career in WCW
    The Mega Powers  
    Mega powers Bio Mega Powers Facts 101 
    PM to fans and Elizabeth
    Randy's Radio interview
    His Death
    Elizabeth Hulette 
    Elizabeth Bio Elizabeth Facts 101 Her Career in the WWF Her Career in WCW Later Life Farewell to a Princess Elizabeth's Radio Interview Elizabeth Death 
    Sherri Martel
    Gorgeous George
    Team Madness
    Early Years
    ICW Gallery
    WWF Gallery
    WCW Gallery
    NWO Gallery
    Memorial Page for Randy
    Memorial Page for Elizabeth
                          Video of the Month    
    Site Disclaimer
    Macho-madness is in no way in contact with World Wrestling Entertainment. All photos are copyright to World Wrestling Entertainment or their respective owners and is being used under the fair copyright of Law 107.
    ©macho-madness.net All right's Reserved.  
            Affiliates
    Want to be an affiliate, elite, or partner site? Email: [email protected] with the list of things below.
    Place in the subject of email: “Randy Savage Online Affiliation”.
    Name: 
    Email: 
    Site Name: 
    Site URL: 
    When Will The Site Be Added?:
                        To see A List Click Here...
    ©macho-madness.net All right's Reserved.  
    Offical Links

  • I have bought a 25Euro Itunes Card from Germany and i have a account which i made in Hong kong store, but everytime i try to redeem it a error comes up with "This code must be redeemed in the German storefront" What do i do?

    I have bought a 25Euro Itunes Card from Germany and i have a account which i made in Hong kong store, but everytime i try to redeem it, a error comes up with "This code must be redeemed in the German storefront" What do i do?

    Sell the German iTunes card to someone who can use it in the German
    AppStore and use the money to buy a card for the Hong Kong store.
    iTunes cards are only valid in the country of original purchase. You cannot
    use a German card in Hong Kong.

  • I need help with this code error "unreachable statement"

    the error_
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errors
    import java.util.*;
    import javax.swing.*;
    import java.awt.*;
    public class Tools//tool class
    private int numberOfToolItems;
    private ToolItems[] toolArray = new ToolItems[10];
    public Tools()//array of tool
    numberOfToolItems = 0;
    for(int i = 0; i < toolArray.length; i++)//for loop to create the array tools
    toolArray[i] = new ToolItems();
    }//end for loop
    }//end of array of tools
    public int search(int id)//search mehtod
    int index = 0;
    while (index < numberOfToolItems)//while and if loop search
    if(toolArray[index].getID() == id)
    return index;
    else
    index ++;
    }//en while and if loop
    return -1;
    }//end search method
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0;
    int index;
    index = search(id); <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    }//end delete method
    public void display()//display method
    for(int i = 0; i < numberOfToolItems; i++)
    //toolArray.display(g,y,x);
    }//end display method
    public String getRecord(int i)//get record method
    // return toolArray[i].getName()+ "ID: "+toolArray[i].getID()
    }//end getrecod
    }//end class
    Edited by: ladsoftware on Oct 9, 2009 6:08 AM
    Edited by: ladsoftware on Oct 9, 2009 6:09 AM
    Edited by: ladsoftware on Oct 9, 2009 6:10 AM
    Edited by: ladsoftware on Oct 9, 2009 6:11 AM

    ladsoftware wrote:
    Subject: Re: I need help with this code error "unreachable statement"
    F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
    int index;
    ^
    F:\Java\Projects\Tools.java:71: missing return statement
    }//end delete method
    ^
    F:\Java\Projects\Tools.java:86: missing return statement
    }//end getrecod
    ^
    3 errorsThe compiler is telling you exactly what the problems are:
    public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
    if(numberOfToolItems >= toolArray.length)
    return 0; // <<== HERE you return, so everyting in the if block after this is unreachable
    int index;
    index = search(id);  //< -----------------------------------------------------------------------------------------------------------------HERE
    if (index == -1)
    toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
    numberInStock ++;
    return 1;
    }//end if index
    }//end if toolitem array
    return -1;
    }//end insert method
    public int delete(/*int id*/)//delete method
    // <<== HERE where is the return statement?
    }//end delete method
    public String getRecord(int i)//get record method
    // return toolArray.getName()+ "ID: "+toolArray[i].getID() <<== HERE you commented out the return statement
    }//end getrecod
    }//end class

  • Help me with this code..

    need help with this code... i am new to java programming.. and having difficulties with the code below...
    import java.awt.*;
    import javax.swing.*;
    import java.net.*;
    public class DisplayImage extends JApplet
         public void init()
              int[] imageData = {0x47,0x49,0x46,0x38,0x39,0x61,0x38,0x00,0x12,0x00,0xF3,0x00,0x00,0xFB,0x0B,0x0E,0xFF,0x24,0x00,0xFF,0x3C,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x7B,0xFF,0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x2C,0x00,0x00,0x00,0x00,0x38,0x00,0x12,0x00,0x00,0x04,0x68,0x10,0xC8,0x49,0xAB,0xBD,0x38,0xEB,0xCD,0xBB,0x0E,0x5E,0x26,0x84,0x64,0x69,0x9E,0xE6,0xA0,0x0E,0xD5,0xEA,0x4E,0xEE,0x4A,0xBD,0xA8,0x2A,0xD9,0x30,0xCB,0xE1,0x00,0xCE,0x93,0xBC,0x9F,0x6E,0x13,0x1C,0xF6,0x8C,0xA7,0x62,0x47,0x99,0x43,0xDD,0x8C,0x31,0x64,0x73,0xFA,0xAC,0xC9,0xA8,0x3F,0xEA,0x71,0x26,0x2D,0x65,0xB9,0x96,0xAC,0xEF,0x9B,0xEA,0x6E,0x5B,0xD2,0xA8,0x53,0x0B,0x6E,0x67,0xC8,0x44,0xA8,0x4E,0x88,0x14,0xCB,0x93,0xF3,0xFB,0xD9,0x3D,0x85,0x2F,0xAF,0x5C,0x64,0x82,0x80,0x6B,0x16,0x04,0x85,0x88,0x6B,0x05,0x89,0x12,0x11,0x00,0x3B};
              ImageIcon icon = null;
              try
                     icon = ImageIcon(ImageDate[]);
              catch(IOException e)
                   System.out.println("Failed to create URL:\n" + e);
                   return;
              loadImage(image);
              int imageWidth = icon.getIconWidth();     // Get icon width
              int imageHeight = icon.getIconHeight();     // and its height
              resize(imageWidth,imageHeight);          // Set applet size to fit the image
              //Create panel a showing the image
              ImagePanel imagePanel = new ImagePanel(icon.getImage());
              getContentPane().add(imagePanel);     // Add the panel to the content pane
         // Class representing a panel displaying an image
         class ImagePanel extends JPanel
              public ImagePanel(Image image)
                   this.image = image;
              public void paint(Graphics g)
                   g.drawImage(image, 0, 0, this);     // Display the image
         Image image;                         // The image
    }Thanks in advance...
    Uzair

    yeah true.... its not that i need someone to write the code.. just cos this code is giving me some problems thought i could get code from others...
    i noticed the extra bracket ending the init().. but thats not what i have problem with....
    It is with how to use ImageIcon(byte[])
    it is something that i need to use this thing in particular... as i am asked to do....

  • If the data network is not available for some time, to get it again we need to restart the phone instead it is not finding the data network instantly. why cant the iphone searches data net work offten if not available. i am totally disappointed with this!

    If the data network is not available for some time, to get it again we need to restart the phone instead it is not finding the data network instantly. why cant the iphone searches data net work offten if not available. i am totally disappointed with this!

    Still it could not find the data network.it searches for voice network instantly and works too. but even full voice network available, there is no data network.when i restart the phone it could find data network.
    Already i reset network settings for two times.

  • I have bought a access to PS CS6, can I activate my another computer with this code?

    As same as the title,I have bought a access to PS CS6, can I activate my another computer with this code?
    Or, I have to pay if I want to activate the product on my new computer.

    The license entitles one to two installations.
    If you should not use the old computer anymore you may want to deactivate Photoshop there, though.

Maybe you are looking for

  • Balance Carry Forward with New GL

    hi, I am trying to do balance carried forward using the new GL and I expect to see retained earnings splits by profit center and segment. I was able to run the program and see the revenue and expenses roll into Retained Earnings account split <u>by p

  • How do I get my book purchases from my iMac to my iPhone?

    They show up on my iMac but I can´t get them to appear on my iPhone.

  • Database Polling Strategy: Time portion of Date/Time not propogated to BPEL

    Hi, I have a simple BPEL process that uses a last update date polling strategy using a helper table. The table I'm going against is a simple, three column table, as defined below: CREATE TABLE XXSI_TEST_PRODUCTS ID VARCHAR2 (32) NOT NULL, DESCRIPTION

  • Invalidate data after submission

    Hi, I built a simple JSP/ Servlet application with some forms and doing some business logic in servlets.Here are the steps 1.Show a JSP form, upon submitting I validate the data and send them to confirm page after they suceed validation. 2. Now in th

  • Jerky 6500 Slide Video Playback

    The spec says it should playback video in QVGA(320x240) encoded as H263 or Mpeg 4 at 30fps. I just cant get it to play anything back without it being extrememly jerky and even sometimes losing sync with the sound. Stupidly I would have expected the s