Sizing an Applet, Need help.

The height parameter of the applet tag can be entered either in terms of number of pixels or % of the browser height.
Is there a way to specify the height as the maximum of two: a fixed size, say, 500 pixels, and a fixed percent, say, 70%, of the browser height? If a Javascript is necessary, could someone help me out with that?
Thanks in advance,
Sooby Bhattacharjee, SDSU

It is possible to use a % height in the html document and resize() the applet (within the applet) to 500 pixels in height if smaller.
Faifai

Similar Messages

  • Scrolling applet - need help

    I have an applet that contains too much information to fit on the screen, so I need a scrollbar so I can view the rest. The kind of scrollbar that's on the side of a web browser that lets you scroll down to view the rest of the page. It's a class that extends Applet and implements MouseListener and ActionListener. I've looked around the internet for the solution for an hour and found nothing. Any help would be much appreciated

    Put a JScrollpane your ScrollPane as the main Panel of your applet, then put the content of your applet in a JPanel yourPanel and finaly call yourScrollPane.setViewPortView(yourPanel).
    Try that. It should work.

  • Basic Math Applet - Need Help

    Hi all,
    I made program work fine as an application, but I cannot get it to work as an applet. I'm trying to write an applet that asks the user to enter two floating-point numbers, obtain the two numbers from the user and draws the sum, product, difference, and quotient of the two numbers.I appreicate any help. My main errors are in the calculations og *,/,-,+ .... I do not know how to fix this though I suspect it simple. Thanks for any help.
    import java.awt.Graphics;
    import javax.swing.*;
    public class Math extends JApplet {
         double sum, product, difference, quotient;
         public void init ()
              String firstNumber,
              secondNumber;
              Double number1,number2;
         firstNumber = JOptionPane.showInputDialog ("Enter first floating pt value" );
         secondNumber = JOptionPane.showInputDialog ("Enter second floating pt value");
         number1 = Double.parseDouble( firstNumber );
         number2 = Double.parseDouble( secondNumber );
         sum = number1 + number2;
         product = number1 * number2;
         difference = number1 - number2;
         quotient = number1 / number2;
         public void paint( Graphics g )
         g.drawRect(15, 10, 270, 20);
         g.drawString("The sum is: " + sum + "\n" +
         "The difference is: " + difference + "\n" + "The qoutient is: "
         + quotient + "\n" + "The product is: " + product, 25,25);
         System.exit (0);
    }

    Arrgg.... When I use this code in HTML it doesn't drop lines.
         public void paint( Graphics g )
         g.drawRect(15, 10, 270, 20);
         g.drawString("The sum is: " + sum + "\n" +
         "The difference is: " + difference + "\n" + "The qoutient is: "
         + quotient + "\n" + "The product is: " + product, 25,25);
    Why are the "\n" not working? Any thoughts?
    HTML:
    <html>
    <applet code="Math.class" width=500 height=200>
    </applet>
    </html>

  • My Applet need help

    Don't get expected results from my Applet
    and Applet does not compile.
    // expected results in the JTextField "box"
    // AF.PA;36,39;4/5/2007;17h35;+1,25;35,53;36,62;35,52;2547827
    // LVMH.PA;84,28;4/3/2007;17h38;+1,16;83,80;84,58;83,32;1963844
    import java.applet.AppletContext;
    import javax.swing.*;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import java.awt.Insets;
    import java.awt.event.*;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.io.*;

    public class ShowDocument extends JApplet
                              implements ActionListener {
        the_URLWindow the_URLWindow;

        public void init() {
            //Execute a job on the event-dispatching thread:
            //creating this applet's GUI.
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        createGUI();
            } catch (Exception e) {
                System.err.println("createGUI didn't successfully complete");

        private void createGUI() {
            JButton button = new JButton("Bring up the_URL window");
            button.addActionListener(this);
            add(button);

            JFrame.setDefaultLookAndFeelDecorated(true);
            the_URLWindow = new the_URLWindow(getAppletContext());
            the_URLWindow.pack();

        public void destroy() {
            //Execute a job on the event-dispatching thread:
            //creating this applet's GUI.
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        destroyGUI();
            } catch (Exception e) { }
        private void destroyGUI() {
            the_URLWindow.setVisible(false);
            the_URLWindow = null;

        public void actionPerformed(ActionEvent event) {
            the_URLWindow.setVisible(true);

    class the_URLWindow extends JFrame
                            implements ActionListener {
        JTextField the_URL_Field;
        JComboBox choice;
        AppletContext appletContext;

        public the_URLWindow(AppletContext appletContext) {
            super("Show a Document!");
            this.appletContext = appletContext;

            JPanel contentPane = new JPanel(new GridBagLayout());
            setContentPane(contentPane);
            contentPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
            GridBagConstraints c = new GridBagConstraints();
            c.fill = GridBagConstraints.HORIZONTAL;

            JLabel label1 = new JLabel("the_URL of document to show: ",
                           JLabel.TRAILING);
            add(label1, c);

            the_URL_Field = new JTextField("http://fr.finance.yahoo.com/d/quotes.txt?m=PA&f=sl1d1t1c1ohgv&e=.csv&s=AF.PA&s=LVMH.PA", 20);
            label1.setLabelFor(the_URL_Field);
            the_URL_Field.addActionListener(this);
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 1.0;
            add(the_URL_Field, c);

            JLabel label2 = new JLabel("Window/frame to show it in: ",
                           JLabel.TRAILING);
            c.gridwidth = 1;
            c.weightx = 0.0;
            add(label2, c);

            String[] strings = {
                "(browser's choice)", //don't specify
                "My Personal Window", //a window named "My Personal Window"
                "_blank",             //a new, unnamed window
                "_self",
                "_parent",
                "_top"                //the Frame that contained this applet
            choice = new JComboBox(strings);
            label2.setLabelFor(choice);
            c.fill = GridBagConstraints.NONE;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.insets = new Insets(5,0,0,0);
            c.anchor = GridBagConstraints.LINE_START;
            add(choice, c);
              JTextField box = new JTextField("Results");
              //box.setLines(10);
              box.setColumns(100);
              c.fill = GridBagConstraints.NONE;
              c.gridwidth = GridBagConstraints.REMAINDER;
              c.insets = new Insets(5,100,100,0);
            c.anchor = GridBagConstraints.LINE_START;
            add(box, c);
            JButton button = new JButton("Show document");
            button.addActionListener(this);
            c.weighty = 1.0;
            c.ipadx = 10;
            c.ipady = 10;
            c.insets = new Insets(10,0,0,0);
            c.anchor = GridBagConstraints.PAGE_END;
            add(button, c);
        public void actionPerformed(ActionEvent event) {
            String the_URL_String = the_URL_Field.getText();
            URL the_URL = null;
            try {
                the_URL = new URL(the_URL_String);
            } catch (MalformedURLException e) {
                System.err.println("Malformed URL: " + the_URL_String);

            if (the_URL != null) {
                   box.setText(showDocument(the_URL));// *********** Java Compiler error *************
                   URLConnection conn = the_URL.openConnection();
                   BufferedReader in =
                        new BufferedReader(new InputStreamReader(conn.getInputStream()));
                        String inputLine;

                        while ((inputLine = in.readLine()) != null) {
                             System.out.println(inputLine);
                        in.close();
                   if (choice.getSelectedIndex() == 0) {
                    appletContext.showDocument(the_URL);
                } else {
                    appletContext.showDocument(the_URL,
                          (String)choice.getSelectedItem());
    }Simple but compiler error.
    If I uncomments the following lines:
                   if (choice.getSelectedIndex() == 0) {
                    appletContext.showDocument(the_URL);
                } else {
                    appletContext.showDocument(the_URL,
                          (String)choice.getSelectedItem());
                   */I get the info but the ASCII file is downloaded in my default downloads folder "/Downloads".
    Right now I have 12 dozens of files named "quotes. txt quotes-1.txt etc ... quotes-n.txt"
    correspondind to n clicks on the button. Unmanageable.
    Just want to get the following in my JTextField named "box":
    AF.PA;36,39;4/5/2007;17h35;+1,25;35,53;36,62;35,52;2547827
    LVMH.PA;84,28;4/3/2007;17h38;+1,16;83,80;84,58;83,32;1963844
    1 - If I succeed I will read the content of the JTextField - line by line - do a split(";")
    on each line to get a vector of data and finnally connect with connector/J to
    add records to a mySQL database.
    2 - If I succeed for step 1, I will create a Thread calling the stuff every 20 mn.
    This is my final objective.
    All the working and not working stuff is at http://www.edelphy.com/ShowDocumentOK/ShowDocument.html
    Please help,
    TIA
    Message was edited by: me
    dimitryous
    Message was edited by:
    dimitryous

    // expected results in the JTextField "box"
    // AF.PA;36,39;4/5/2007;17h35;+1,25;35,53;36,62;35,52;2547827
    // LVMH.PA;84,28;4/3/2007;17h38;+1,16;83,80;84,58;83,32;1963844
    import java.applet.AppletContext;
    import javax.swing.*;
    import java.awt.GridBagLayout;
    import java.awt.GridBagConstraints;
    import java.awt.Insets;
    import java.awt.event.*;
    import java.net.URL;
    import java.net.MalformedURLException;
    import java.net.URLConnection;
    import java.io.*;
    public class ShowDocument extends JApplet
                              implements ActionListener {
        the_URLWindow the_URLWindow;
        public void init() {
            //Execute a job on the event-dispatching thread:
            //creating this applet's GUI.
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        createGUI();
            } catch (Exception e) {
                System.err.println("createGUI didn't successfully complete");
        private void createGUI() {
            JButton button = new JButton("Bring up the_URL window");
            button.addActionListener(this);
            add(button);
            JFrame.setDefaultLookAndFeelDecorated(true);
            the_URLWindow = new the_URLWindow(getAppletContext());
            the_URLWindow.pack();
        public void destroy() {
            //Execute a job on the event-dispatching thread:
            //creating this applet's GUI.
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        destroyGUI();
            } catch (Exception e) { }
        private void destroyGUI() {
            the_URLWindow.setVisible(false);
            the_URLWindow = null;
        public void actionPerformed(ActionEvent event) {
            the_URLWindow.setVisible(true);
    class the_URLWindow extends JFrame
                            implements ActionListener {
        JTextField the_URL_Field;
        JComboBox choice;
        AppletContext appletContext;
        JTextField box;
        public the_URLWindow(AppletContext appletContext) {
            super("Show a Document!");
            this.appletContext = appletContext;
            JPanel contentPane = new JPanel(new GridBagLayout());
            setContentPane(contentPane);
            contentPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
            GridBagConstraints c = new GridBagConstraints();
            c.fill = GridBagConstraints.HORIZONTAL;
            JLabel label1 = new JLabel("the_URL of document to show: ",
                           JLabel.TRAILING);
            add(label1, c);
            the_URL_Field = new JTextField("http://fr.finance.yahoo.com/d/quotes.txt?m=PA&f=sl1d1t1c1ohgv&e=.csv&s=AF.PA&s=LVMH.PA", 20);
            label1.setLabelFor(the_URL_Field);
            the_URL_Field.addActionListener(this);
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.weightx = 1.0;
            add(the_URL_Field, c);
            JLabel label2 = new JLabel("Window/frame to show it in: ",
                           JLabel.TRAILING);
            c.gridwidth = 1;
            c.weightx = 0.0;
            add(label2, c);
            String[] strings = {
                "(browser's choice)", //don't specify
                "My Personal Window", //a window named "My Personal Window"
                "_blank",             //a new, unnamed window
                "_self",
                "_parent",
                "_top"                //the Frame that contained this applet
            choice = new JComboBox(strings);
            label2.setLabelFor(choice);
            c.fill = GridBagConstraints.NONE;
            c.gridwidth = GridBagConstraints.REMAINDER;
            c.insets = new Insets(5,0,0,0);
            c.anchor = GridBagConstraints.LINE_START;
            add(choice, c);
              box = new JTextField("Results");
              //box.setLines(10);
              box.setColumns(100);
              c.fill = GridBagConstraints.NONE;
              c.gridwidth = GridBagConstraints.REMAINDER;
              c.insets = new Insets(5,100,100,0);
            c.anchor = GridBagConstraints.LINE_START;
            add(box, c);
            JButton button = new JButton("Show document");
            button.addActionListener(this);
            c.weighty = 1.0;
            c.ipadx = 10;
            c.ipady = 10;
            c.insets = new Insets(10,0,0,0);
            c.anchor = GridBagConstraints.PAGE_END;
            add(button, c);
        public void actionPerformed(ActionEvent event) {
            String the_URL_String = the_URL_Field.getText();
            URL the_URL = null;
            try {
                the_URL = new URL(the_URL_String);
            } catch (MalformedURLException e) {
                System.err.println("Malformed URL: " + the_URL_String);
            if (the_URL != null) {
                   box.setText("Hellooooooooooo");// *********** Java Compiler error *************
              try{     
                   URLConnection conn = the_URL.openConnection();
                   BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                        String inputLine;
                        while ((inputLine = in.readLine()) != null) {
                             System.out.println(inputLine);
                        in.close();
              } catch (Exception e) {
                   e.printStackTrace();
                   if (choice.getSelectedIndex() == 0) {
                    appletContext.showDocument(the_URL);
                } else {
                    appletContext.showDocument(the_URL,
                          (String)choice.getSelectedItem());
    }Create a HTML page as
    <HTML>
    <HEAD>
    <TITLE>ShowDocument</TITLE>
    </HEAD>
    <BODY>
    <H1>ShowDocument</H1>
    <BR>
    <APPLET CODE="ShowDocument" WIDTH=600 HEIGHT=50>
    If you can see this, your browser does not support Java applets.
    </APPLET>
    </BODY>
    </HTML>

  • Display image in applet - need help

    Ive got this code in my applet
    Image image1 = toolkit.getImage("images/background.jpg");
    Which runs fine when run locally, but when I try to run it from a html in a browser it starts to fire off lots of security messages.
    How can i do this?
    the remainder is I set it as my background
    g.drawImage(image, 0, 0, this);

    I have tried the following while running the applet in a browser and it worked...so I guess you can give this a try...
    java.net.URL backgroundImage = getClass().getResource("back.jpg");
    ImageIcon icon = new ImageIcon(backgroundImage);
    and then use this ImageIcon to set the background.

  • Need help with advanced applet

    I need help with designing an applet as follows. Can someone give me a basic layout of code and material so i can fill in the rest or at leats give me some hints so i can get started since i am like no good at applets.
    Design and implement an applet that graphically displays the processing
    of a selection sort. Use bars of various heights to represent
    the values being sorted. Display the set of bars after each swap. Put
    a delay in the processing of the sort to give the human observer a
    chance to see how the order of the values changes.
    heres a website that does something similar
    http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html

    elasolova wrote:
    i will not help you this time. but if you buy me a candy maybe i can reconsider the issue. :PI suggest an all-day sucker.

  • Need HELP with Stick Figure Applet

    I need help with this java program for college....we need to make a applet which displays a stick figure or some type of person using appleviewer..please can someone help me......
    email: [email protected]

    import java.awt.*;
    import java.applet.*;
    public class StickMan extends Applet {
         public void init() {
         public void paint(Graphics g) {
              g.drawOval(....);
              g.drawLine(....);
              g.drawLine(....);
              g.drawLine(....);
              g.drawLine(....);

  • I need help in establishing a smale applet

    Pleaze i need help in creating this small program. any one can help me pleaze.
    All what is required is to write a java applet, that does the following:
    1) Creates an empty file on the client side. The name of the file is given
    by the client user.
    2) Reads a file (example: c:\tmp\toto.txt) from the client side. The name
    of the file is given by the client user. If the file does not exist, the
    applet should display a message error �File does not exist�.
    pleaze help me in thaaaaaat :(

    Applets cannot access client files by default: In order to do either of these you will need to sign your applet. Google for applet signing and see what you find.

  • I need help with the Quote applet.

    Hey all,
    I need help with the Quote applet. I downloaded it and encoded it in the following html code:
    <html>
    <head>
    <title>Part 2</title>
    </head>
    <body>
    <applet      codebase="/demo/quote/classes" code="/demo/quote/JavaQuote.class"
    width="300" height="125" >
    <param      name="bgcolor"      value="ffffff">
    <param      name="bheight"      value="10">
    <param      name="bwidth"      value="10">
    <param      name="delay"      value="1000">
    <param      name="fontname"      value="TimesRoman">
    <param      name="fontsize"      value="14">
    <param      name="link"      value="http://java.sun.com/events/jibe/index.html">
    <param      name="number"      value="3">
    <param      name="quote0"      value="Living next to you is in some ways like sleeping with an elephant. No matter how friendly and even-tempered is the beast, one is affected by every twitch and grunt.|- Pierre Elliot Trudeau|000000|ffffff|7">
    <param      name="quote1"      value="Simplicity is key. Our customers need no special technology to enjoy our services. Because of Java, just about the entire world can come to PlayStar.|- PlayStar Corporation|000000|ffffff|7">
    <param      name="quote2"      value="The ubiquity of the Internet is virtually wasted without a platform which allows applications to utilize the reach of Internet to write ubiquitous applications! That's where Java comes into the picture for us.|- NetAccent|000000|ffffff|7">
    <param      name="space"      value="20">
    </applet>
    </body>
    </html>When I previewed it in Netscape Navigator, a box with a red X appeared, and this appeared in the console when I opened it:
    load: class /demo/quote/JavaQuote.class not found.
    java.lang.ClassNotFoundException: .demo.quote.JavaQuote.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: \demo\quote\JavaQuote\class.class (The system cannot find the path specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    Exception in thread "Thread-4" java.lang.NullPointerException
         at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
         at sun.plugin.AppletViewer.showAppletException(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    java.lang.NullPointerException
         at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
         at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)What went wrong? and how can I make it run correct?
    Thanks,
    Nathan Pinno

    JavaQuote.class is not where your HTML says it is. That is at the relative URL "/demo/quote/".

  • A Menu Applet Project (need help)

    The Dinner Menu Applet
    I would need help with those codes ...
    I have to write a Java applet that allows the user to make certain choices from a number of options and allows the user to pick three dinner menu items from a choice of three different groups, choosing only one item from each group. The total will change as each selection is made.
    Please send help at [email protected] (see the codes of the project at the end of that file... Have a look and help me!
    INSTRUCTIONS
    Design the menu program to include three soups, three
    entrees, and three desserts. The user should be informed to
    choose only one item from each group.
    Use the following information to create your project.
    Clam Chowder 2.79
    Vegetable soup 2.99
    Peppered Chicken Broth 2.49
    Chicken 12.79
    Fish 10.99
    Beef 14.99
    Vanilla Ice Cream 2.79
    Rice Pudding 2.99
    Cheesecake 4.29
    The user shouldn�t be able to choose more than one item
    from the same group. The item prices shouldn�t be visible to
    the user.
    When the user makes his or her first choice, the running
    total at the bottom of the applet should show the price of
    that item. As each additional item is selected, the running
    total should change to reflect the new total cost.
    The dinner menu should be 200 pixels wide &#56256;&#56437; 440 pixels
    high and be centered on the browser screen. The browser
    window should be titled �The Menu Program.�
    Use 28-point, regular face Arial for the title �Dinner Menu.�
    Use 16-point, bold face Arial for the dinner menu group titles
    and the total at the bottom of the applet. Use 14-point regular
    face Arial for individual menu items and their prices. If you
    do not have Arial, you may substitute any other sans-serif
    font in its place. Use Labels for the instructions.
    The checkbox objects will use the system default font.
    Note: Due to complexities in the way that Java handles
    numbers and rounding, your price may display more than
    two digits after the decimal point. Since most users are used
    to seeing prices displayed in dollars and cents, you�ll need to
    display the correct value.
    For this project, treat the item prices as integers. For example,
    enter the price of cheesecake as 429 instead of 4.29. That
    way, you�ll get an integer number as a result of the addition.
    Then, you�ll need to establish two new variables in place of
    the Total variable. Run the program using integers for the
    prices, instead of float variables with decimals.
    You�ll have the program perform two mathematical functions
    to get the value for the dollars and cents variables. First,
    divide the total price variable by 100. This will return a
    whole value, without the remainder. Then get the mod of the
    number versus 100, and assign this to the cents variable.
    Finally, to display the results, write the following code:
    System.out.println("Dinner Price is $ " + dollars +"." + cents);
    Please send code in notepad or wordpad to [email protected]
    Here are the expectations:
    HTML properly coded
    Java source and properly compiled class file included
    Screen layout as specified
    All menu items properly coded
    Total calculates correctly
    * MenuApplet.java
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    * @author Rulx Narcisse
         E-mail address: [email protected]
    public class MenuApplet extends java.applet.Applet implements ItemListener{
    //Variables that hold item price:
    int clamChowderPrice= 279;
    int vegetableSoupPrice= 299;
    int pepperedChickenBrothPrice= 249;
    int chickenPrice= 1279;
    int fishPrice= 1099;
    int beefPrice= 1499;
    int vanillaIceCreamPrice= 279;
    int ricePuddingPrice= 299;
    int cheeseCakePrice =429;
    int dollars;
    int cents=dollars % 100;
    //cents will hold the modulus from dollars
    Label entete=new Label("Diner Menu");
    Label intro=new Label("Please select one item from each category");
    Label intro2=new Label("your total will be displayed below");
    Label soupsTrait=new Label("Soups---------------------------");
    Label entreesTrait=new Label("Entrees---------------------------");
    Label dessertsTrait=new Label("Desserts---------------------------");
      *When the user makes his or her first choice, the running
         total (i.e. dollars) at the bottom of the applet should show the price of
         that item. As each additional item is selected, the running
         total should change to reflect the new total cost.
    Label theDinnerPriceIs=new Label("Dinner Price is $ "+dollars +"."+cents);
      *Crating face, using 28-point, regular face Arial for the title �Dinner Menu.�
         Using 16-point, bold face Arial for the dinner menu group titles
         and the total at the bottom of the applet & using 14-point regular
         face Arial for individual menu items and their prices.
    Font bigFont = new Font ("Arial", Font.PLAIN,28);
    Font bigFont2 = new Font ("Arial", Font.BOLD,16);
    Font itemFont = new Font ("Arial", Font.PLAIN,14);
    //Here are the radiobutton on the applet...
    CheckboxGroup soupsG = new CheckboxGroup();
        Checkbox cb1Soups = new Checkbox("Clam Chowder", soupsG, false);
        Checkbox cb2Soups = new Checkbox("Vegetable Soup", soupsG, true);
        Checkbox cb3Soups = new Checkbox("Peppered Chicken Broth", soupsG, false);
    CheckboxGroup entreesG = new CheckboxGroup();
        Checkbox cb1Entrees= new Checkbox("Chicken", entreesG, false);
        Checkbox cb2Entrees = new Checkbox("Fish", entreesG, true);
        Checkbox cb3Entrees = new Checkbox("Beef", entreesG, false);
    CheckboxGroup dessertsG = new CheckboxGroup();
        Checkbox cb1Desserts= new Checkbox("Vanilla Ice Cream", dessertsG, false);
        Checkbox cb2Desserts = new Checkbox("Pudding Rice", dessertsG, true);
        Checkbox cb3Desserts = new Checkbox("Cheese Cake", dessertsG, false);
        public void init() {
            entete.setFont(bigFont);
            add(entete);
            intro.setFont(itemFont);
            add(intro);
            intro2.setFont(itemFont);
            add(intro2);
            soupsTrait.setFont(bigFont2);
            add(soupsTrait);
            cb1Soups.setFont(itemFont);cb2Soups.setFont(itemFont);cb3Soups.setFont(itemFont);
            add(cb1Soups); add(cb2Soups); add(cb3Soups);
            cb1Soups.addItemListener(this);cb2Soups.addItemListener(this);cb2Soups.addItemListener(this);
            entreesTrait.setFont(bigFont2);
            add(entreesTrait);
            cb1Entrees.setFont(itemFont);cb2Entrees.setFont(itemFont);cb3Entrees.setFont(itemFont);
            add(cb1Entrees); add(cb2Entrees); add(cb3Entrees);
            cb1Entrees.addItemListener(this);cb2Entrees.addItemListener(this);cb2Entrees.addItemListener(this);
            dessertsTrait.setFont(bigFont2);
            add(dessertsTrait);
            cb1Desserts.setFont(itemFont);cb2Desserts.setFont(itemFont);cb3Desserts.setFont(itemFont);
            add(cb1Desserts); add(cb2Desserts); add(cb3Desserts);
            cb1Desserts.addItemListener(this);cb2Desserts.addItemListener(this);cb2Desserts.addItemListener(this);
            theDinnerPriceIs.setFont(bigFont2);
            add(theDinnerPriceIs);
           public void itemStateChanged(ItemEvent check)
               Checkbox soupsSelection=soupsG.getSelectedCheckbox();
               if(soupsSelection==cb1Soups)
                   dollars +=clamChowderPrice;
               if(soupsSelection==cb2Soups)
                   dollars +=vegetableSoupPrice;
               else
                   cb3Soups.setState(true);
               Checkbox entreesSelection=entreesG.getSelectedCheckbox();
               if(entreesSelection==cb1Entrees)
                   dollars +=chickenPrice;
               if(entreesSelection==cb2Entrees)
                   dollars +=fishPrice;
               else
                   cb3Entrees.setState(true);
               Checkbox dessertsSelection=dessertsG.getSelectedCheckbox();
               if(dessertsSelection==cb1Desserts)
                   dollars +=vanillaIceCreamPrice;
               if(dessertsSelection==cb2Desserts)
                   dollars +=ricePuddingPrice;
               else
                   cb3Desserts.setState(true);
                repaint();
        }

    The specific problem is that when I load he applet, the radio buttons do not work properly and any calculation is made.OK.
    I had a look at the soup radio buttons. I guess the others are similar.
    (a) First, a typo.
    cb1Soups.addItemListener(this);cb2Soups.addItemListener(this);cb2Soups.addItemListener(this);That last one should be "cb3Soups.addItemListener(this)". The peppered chicken broth was never responding to a click. It might be a good idea to write methods that remove such duplicated code.
    (b) Now down where you respond to user click you have:
    Checkbox soupsSelection=soupsG.getSelectedCheckbox();
    if(soupsSelection==cb1Soups)
        dollars +=clamChowderPrice;
    if(soupsSelection==cb2Soups)
        dollars +=vegetableSoupPrice;
    else
        cb3Soups.setState(true);What is that last bit all about? And why aren't they charged for the broth? Perhaps it should be:
    Checkbox soupsSelection=soupsG.getSelectedCheckbox();
    if(soupsSelection==cb1Soups) {
        dollars +=clamChowderPrice;
    } else if(soupsSelection==cb2Soups) {
        dollars +=vegetableSoupPrice;
    } else if(soupsSelection==cb3Soups) {
        dollars +=pepperedChickenBrothPrice;
    }Now dollars (the meal price in cents) will have the price of the soup added to it every time.
    (c) It's not enough to just calculate dollars, you also have to display it to the user. Up near the start of your code you have
    Label theDinnerPriceIs=new Label("Dinner Price is $ "+dollars +"."+cents);It's important to realise that theDinnerPriceIs will not automatically update itself to reflect changes in the dollars and cents variables. You have to do this yourself. One way would be to use the Label setText() method at the end of the itemStateChanged() method.
    (d) Finally, the way you have written itemStateChanged() you are continually adding things to dollars. Don't forget to make dollars zero at the start of this method otherwise the price will go on and on accumulating which is not what you intend.
    A general point: If you have any say in it use Swing (JApplet) rather than AWT. And remember that both Swing and AWT have forums of their own which may be where you get the best help for layout problems.

  • Partial Get via   IE Browser/applet failing ... need help !?

    Partial Get via IE Browser/applet failing ... need help !?
    I recall someone saying that IE client would not receive a partial get initiated by http URL with setRequestProperty("range","bytes=2-");
    Can anyone elaborate on why the client seems to balk at the returned result and the getinputStream seems to result in a FileNotFoundException
    Do I have to use sockets ??????

    Partial Get via IE Browser/applet failing ... need help !?
    I recall someone saying that IE client would not receive a partial get initiated by http URL with setRequestProperty("range","bytes=2-");
    Can anyone elaborate on why the client seems to balk at the returned result and the getinputStream seems to result in a FileNotFoundException
    Do I have to use sockets ??????

  • Need help with applet servlet communication .. not able to get OutputStream

    i am facing problem with applet and servlet communication. i need to send few image files from my applet to the servlet to save those images in DB.
    i need help with sending image data to my servlet.
    below is my sample program which i am trying.
    java source code which i am using in my applet ..
    public class Test {
        public static void main(String argv[]) {
            try {
                    URL serverURL = new URL("http://localhost:8084/uploadApp/TestServlet");
                    URLConnection connection = serverURL.openConnection();
                    Intermediate value=new Intermediate();
                    value.setUserId("user123");
                    connection.setDoInput(true);
                    connection.setDoOutput(true);
                    connection.setUseCaches(false);
                    connection.setDefaultUseCaches(false);
                    // Specify the content type that we will send binary data
                    connection.setRequestProperty ("Content-Type", "application/octet-stream");
                    ObjectOutputStream outputStream = new ObjectOutputStream(connection.getOutputStream());
                    outputStream.writeObject(value);
                    outputStream.flush();
                    outputStream.close();
                } catch (MalformedURLException ex) {
                    System.out.println(ex.getMessage());
                }  catch (IOException ex) {
                        System.out.println(ex.getMessage());
    }servlet code here ..
    public class TestServlet extends HttpServlet {
         * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
        protected void processRequest(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
             System.out.println(" in servlet -----------");
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            ObjectInputStream inputFromApplet = null;
            Intermediate aStudent = null;
            BufferedReader inTest = null;
            try {         
                // get an input stream from the applet
                inputFromApplet = new ObjectInputStream(request.getInputStream());
                // read the serialized object data from applet
                data = (Intermediate) inputFromApplet.readObject();
                System.out.println("userid in servlet -----------"+ data.getUserId());
                inputFromApplet.close();
            } catch (Exception e) {
                e.printStackTrace();
                System.err.println("WARNING! filename.path JNDI not found");
            } finally {
                out.close();
        @Override
        protected void doGet(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            System.out.println(" in foGet -----------");
            processRequest(request, response);
         * Handles the HTTP <code>POST</code> method.
         * @param request servlet request
         * @param response servlet response
         * @throws ServletException if a servlet-specific error occurs
         * @throws IOException if an I/O error occurs
        @Override
        protected void doPost(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            System.out.println(" in doPost -----------");
            processRequest(request, response);
         * Returns a short description of the servlet.
         * @return a String containing servlet description
        @Override
        public String getServletInfo() {
            return "Short description";
        }// </editor-fold>
    }the Intermediate class ..
    import java.io.Serializable;
    public class Intermediate implements Serializable{
    String userId;
        public String getUserId() {
            return userId;
        public void setUserId(String userId) {
            this.userId = userId;
    }

    Hi,
    well i am not able to get any value from connection.getOutputStream() and i doubt my applet is not able to hit the servlet. could you review my code and tell me if it has some bug somewhere. and more over i want to know how to send multiple file data from applet to servlet . i want some sample or example if possible.
    do share if you have any experience of this sort..
    Thanks.

  • Need Help!  Applet Servlet Portlet Communication

    Hi
    My applet need to send a keyWord to let a portlet to do some operations. I know an applet can communicate with a servlet by URLConnection.But how can portlet? Can I consider a portlet as a servlet and let the applet communicate with the portlet like servlet by URLConnection? could you tell me whether this is possible?
    Thanks for your help.

    Hi
    You have a white-space in the codebase, remove it.
    If that doesn't help, make a static html page, test the Applet with it.
    /Tobias - hopes this helps

  • Need help with Applet: Images

    DUKESTARS HERE, YOU KNOW YOU WANNA
    Hi,
    I'm designing an applet for some extra credit and I need help.
    This game that i have designed is called "Digit Place Game", but there is no need for me to explain the rules.
    The problem is with images.
    When I start the game using 'appletviewer', it goes to the main menu:
    http://img243.imageshack.us/img243/946/menuhy0.png
    Which is all good.
    But I decided that when you hover your cursor over one of the options such as: Two-Digits or Three-Digits, that the words that are hovered on turn green.
    http://img131.imageshack.us/img131/6231/select1ch3.png
    So i use the mouseMoved(MouseEvent e) from awt.event;
    The problem is that when i move the mouse around the applet has thick line blotches of gray/silver demonstrated below (note: these are not exact because my print screen doesn't take a picture of the blotches)
    http://img395.imageshack.us/img395/4974/annoyingmt1.png
    It also lags a little bit.
    I have 4 images in my image folder that's in the folder of the source code
    The first one has all text blue. The second one has the first option, Two-Digits green but rest blue. The third one has the second option, Three-Digits green but rest blue, etc.
    this is my code
    import java.applet.Applet;
    import java.awt.Graphics;
    import java.awt.event.*;
    import java.awt.*;
    public class DigitPlaceGame extends Applet implements MouseListener, MouseMotionListener {
         public boolean load = false;
         public boolean showStartUp = false;
         public boolean[] hoverButton = new boolean[3];
         Image load1;
         Image showStartUp1;
         Image showStartUp2;
         Image showStartUp3;
         Image showStartUp4;
         public void init() {
              load = true;
              this.resize(501, 501);
                   try {
                        load1 = getImage(getCodeBase(), "images/load1.gif");
                        repaint();
                   } catch (Exception e) {}
              load();
         public void start() {
         public void stop() {
         public void destroy() {
         public void paint(Graphics g) {
              if(load == true) {
                   g.drawImage(load1, 0, 0, null, this);
              } else if(showStartUp == true) {
                   if(hoverButton[0] == true) {
                        g.drawImage(showStartUp2, 0, 0, null, this);
                   } else if(hoverButton[1] == true) {
                        g.drawImage(showStartUp3, 0, 0, null, this);
                   } else if(hoverButton[2] == true) {
                        g.drawImage(showStartUp4, 0, 0, null, this);
                   } else {
                        g.drawImage(showStartUp1, 0, 0, null, this);
                        for(int i = 0; i < 3; i++) {
                             hoverButton[i] = false;
         public void load() {
              addMouseListener(this);
              addMouseMotionListener(this);
              showStartUp1 = getImage(getCodeBase(), "images/showStartUp1.gif");
              showStartUp2 = getImage(getCodeBase(), "images/showStartUp2.gif");
              showStartUp3 = getImage(getCodeBase(), "images/showStartUp3.gif");
              showStartUp4 = getImage(getCodeBase(), "images/showStartUp4.gif");
              showStartUp();
         public void showStartUp() {
              load = false;
              showStartUp = true;
         public void mouseClicked(MouseEvent e) {
              System.out.println("test");
         public void mouseMoved(MouseEvent e) {
              int x = e.getX();
              int y = e.getY();
              if(x >= 175 && x <= 330 && y >= 200 && y <= 235) {
                   hoverButton[0] = true;
                   repaint();
              } else if(x >= 175 && x <= 330 && y >= 250 && y <= 280) {
                   hoverButton[1] = true;
                   repaint();
              } else if(x >= 175 && x <= 330 && y >= 305 && y <= 335) {
                   hoverButton[2] = true;
                   repaint();
              } else {
                        for(int i = 0; i < 3; i++) {
                             hoverButton[i] = false;
                        repaint();
         public void mouseEntered(MouseEvent e) {
         public void mouseExited(MouseEvent e) {
         public void mousePressed(MouseEvent e) {
         public void mouseReleased(MouseEvent e) {
         public void mouseDragged(MouseEvent e) {
    }plox help me ploz, i need the extra credit for an A
    can you help me demolish the lag and stop the screen from flickering? thanks!!!!!
    BTW THIS IS EXTRA CREDIT NOT HOMework
    DUKESTARS HERE, YOU KNOW YOU WANNA
    Edited by: snoy on Nov 7, 2008 10:51 PM
    Edited by: snoy on Nov 7, 2008 10:53 PM

    Oh yes, I knew there could be some problem.......
    Now try this:
    boolean a,b,c;
    if((a=(x >= 175 && x <= 330 && y >= 200 && y <= 235)) && !hoverButton[0]) {
                   hoverButton[0] = true;
                   repaint();
              } else if((b=(x >= 175 && x <= 330 && y >= 250 && y <= 280)) && !hoverButton[1]) {
                   hoverButton[1] = true;
                   repaint();
              } else if((c=(x >= 175 && x <= 330 && y >= 305 && y <= 335)) && !hoverButton[2]) {
                   hoverButton[2] = true;
                   repaint();
              } else if ((!a && !b && !c)&&(hoverButton[0] || hoverButton[1] || hoverButton[2]){
                        for(int i = 0; i < 3; i++) {
                             hoverButton[i] = false;
                        repaint();
              }hope it works........
    Edited by: T.B.M on Nov 8, 2008 10:41 PM

  • Need help to develop Pythagoras theorem-

    Hi i need help to develop proofs 2,3,4
    of pythagoras theorems in java as demonstrations
    These are applets can anyone help me with it or give me an idea of how to go about developing it -
    the site is the following
    http://www.uni-koeln.de/ew-fak/Mathe/Projekte/VisuPro/pythagoras/pythagoras.html
    then double click on the screen to make it start

    Pardon my ASCII art, but I've always liked the following, simple, geometric proof:
         a                   b
    ---------------------------------------+
    |       |                                |
    a|   I   |              II                |
    |       |                                |
    ---------------------------------------+
    |       |                                |
    |       |                                |
    |       |                                |
    |       |                                |
    |       |                                |
    b|  IV   |              III               |
    |       |                                |
    |       |                                |
    |       |                                |
    |       |                                |
    |       |                                |
    |       |                                |
    ---------------------------------------+It almost goes without saying that I+II+III+IV == (a+b)^2, and II == IV == a*b,
    I == a*a and III == b*b, showing that (a+b)^2 == a^2+a*b+a*b+b^2.
    I hope the following sketch makes sense, stand back, ASCII art alert again:     a                   b
    ---------------------------------------+
    |               .             VI         |
    |     .                 .                |a
    | V                               .      |
    |                                        +
    |                                        |
    |   .                                    |
    b|                                     .  |
    |                                        |
    |                  IX                    |
    | .                                      |
    |                                    .   |b
    |                                        |
    +                                        |
    |      .                                 |
    a|               .                  . VII |
    |  VIII                   .              |
    ---------------------------------------+
                     a                    bThe total area equals (a+b)^2 again and equals the sum of the smaller areas:
    (a+b)^2 == V+VI+VII+VIII+IX. Let area IX be c^2 for whatever c may be.
    V+VII == VI+VIII == a*b, so a^2+b^2+2*ab= c^2+2*a*b; IOW a^2+b^2 == c^2
    Given this fundamental result, the others can easily be derived from this one,
    or did I answer a question you didn't ask?
    kind regards,
    Jos

Maybe you are looking for

  • How can I stop emails deleting on my hotmail account

    Hi My iphone 4 is set up to deliver my hotmail emails to my phone.  The actions I take on my phone (e.g., deleting an email) are being replicated in my hotmail account on the server.  I appreciate this is no bad thing except that both myself and my w

  • Installing 8.1 Drivers in Embedded 8 Standard for latest Atom chipsets

    We have been successfully using Windows Embedded 7 and then 8 successfully on various Dell, ASUS and MSI hardware platforms for the last several years. However, with the latest round of Tablets that have come out since Windows 8.1 was released, we ca

  • Junk Characters in file

    Hi Experts, I am using  GUI_DOWNLOAD to download a file on my local server, In debugging the file seems to be having perfect data but once the file gets downloaded it shows certain junk characters in the file.

  • Third party RAM for my Mac Pro

    I have a 1st generation Dual-Core 2.66GHz/4GB Mac Pro desktop. I want to install 16 GB total, from a third party. I'm not very computer savvy... and I'm not sure which third party offers the ram most suitable for my particular machine, or which pairs

  • How to set Border in the Excel using UTL_FILE ?

    Hi all, Any one aware of How to set Border in the Excel using UTL_FILE ? Am doing excel creation from a stored procedure. Thanks Dora