Problem "resizing" applet

Can someone please help me with resizing an applet. I can't figure out how to decrease or increase the applet more than once. If the "smaller" button is clicked, the applet decreases in size only once. If the "bigger" button is clicked, the applet increases only once. What I need to accomplish is that everytime the "smaller" button is clicked, the size of the applet (both width and height) should be decreased by 10 pixels and everytime the "bigger" button is click, the size of the applet (both width and height) should be increased by 10 pixels. I have attached the code below. Any help will be appreciated....Thanks in advance.
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class Resizable extends Applet implements ActionListener {
int apWidth = 0;
int apHeight = 0;
private Label myLabel;
private TextField myText;
private Button sButton;
private Button bButton;
public void init() {
apWidth = getSize().width;
apHeight = getSize().height;
myLabel = new Label("Applet Size Is: ");
add(myLabel);
myText = new TextField(8);
myText.setText("200 100");
myText.setEditable(false);
add(myText);
sButton = new Button("smaller");
sButton.addActionListener(this);
add(sButton);
bButton = new Button("bigger");
bButton.addActionListener(this);
add(bButton);
public void actionPerformed(ActionEvent e) {
if (e.getSource() == sButton) {
myText.setText("30 30");
this.setSize((apWidth - 10), (apHeight - 10));
else {
myText.setText("90 90");
this.setSize((apWidth + 10), (apHeight + 10));
}

not sure about this but try this:
public boolean actionPerformed(ActionEvent e) {
if (e.getSource() == sButton) {
myText.setText("30 30");
this.setSize((apWidth - 10), (apHeight - 10));
else {
myText.setText("90 90");
this.setSize((apWidth + 10), (apHeight + 10));
return(true);

Similar Messages

  • Caching problem in Applets - Java Control Panel

    I have a problem of applets being cached in Java Control Panel. Is there a way in Java to stop caching applets programatically in the Java Control Panel.
    There is one way to stop caching files by unchecking "Keep Temporary Files on my Computer" under Java Control Panel --> General --> Settings page.
    But I want to do this programatically using some Java programming/Java Scripting/some parameter in applet tag.
    Some solutions like setting cache_option = No, cache_archive= jar file name in PARAM tag in applet and classloader_cache="false" have been already tried. But noting is seeming to be working out.
    Can somebody please provide a solution.

    Following is the listener status
    STATUS of the LISTENER
    Alias LISTENER
    Version TNSLSNR for 32-bit Windows: Version 10.2.0.1.0 - Produ
    ction
    Start Date 11-APR-2007 11:51:12
    Uptime 0 days 0 hr. 1 min. 28 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File I:\oracle\product\10.2.0\db_1\network\admin\listener.o
    ra
    Listener Log File I:\oracle\product\10.2.0\db_1\network\log\listener.log
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=jbpsouthcbg)(PORT=1521)))
    Services Summary...
    Service "jbpsouth" has 2 instance(s).
    Instance "jbpsouth", status UNKNOWN, has 2 handler(s) for this service...
    Instance "jbpsouth", status READY, has 2 handler(s) for this service...
    Service "jbpsouth_XPT" has 1 instance(s).
    Instance "jbpsouth", status READY, has 2 handler(s) for this service...
    The command completed successfully

  • Problem calling applet method using IE

    I've searched through the forum and can't seem to find anything that can help me fix this. I'm trying to call an applet's method using Javascript. This is working fine under Netscape, but not IE. Everything I've read seems to indicate that I'm doing this right, but I'm getting "Object doesn't support this property or method" when I try to call the applet method from IE.
    In this example method, I'm trying to call the applet's countChars method, which should return the length of the string you pass into it. Works under Netscape 6.2, but not IE 6.0
    Here's my applet code:
    import java.lang.String;
    public class test extends java.applet.Applet {
    public static int countChars(String s) {
    return s.length();
    And my HTML
    <HTML>
    <HEAD>
    <script language="Javascript">
    function refreshApplet()
    /*     i = document.forms.myForm.TestApplet.countChars();
         document.forms.myForm.output.value=i; */
         document.forms.myForm.output.value=document.applets["TestApplet"].countChars(document.forms.myForm.input.value);
    </script>
    </HEAD>
    <BODY>
    <APPLET CODE = "test.class" WIDTH = 400 HEIGHT = 400 ALIGN = middle NAME = "TestApplet" scriptable="true">
    </APPLET>
    <br>
    <form name="myForm">
    <input type="text" name="input">
    <input type="button" value="click me" onClick="refreshApplet();">
    <hr>
    <input type="text" name="output">
    </form>
    </BODY>
    </HTML>
    Thanks in advance!
    Craig Drabik
    Sr. Programmer/Analyst
    University at Buffalo

    I have very similar problem, my applet works OK using Netscape (6.2 and 7.0), but with IE 6.0 It only works with windows XP;
    The reported error is "Object doesn't support this property or method"
    Can someone please help me to solve this problem.
    Cheers
    Horus
    This is my code:
    - I call the applet using javaScript and input the method setData with two strings.
    function graphic()
         var dataZenith;
         var dataManual;
         initVariables();
         dataZenith = graphicZENith(); //Call other Javascript functions
         dataManual = graphicManual(); //Call other Javascript functions
         document.AppletOne.setData(dataZenith,dataManual);
    I run the applet with this HTML code:
    <applet NAME="AppletOne" code="Appl.class" width="450" height="450"
    MAYSCRIPT></applet>
    //Applet code/////////////
    import java.awt.*;
    import java.awt.geom.*;
    import java.applet.*;
    import java.util.*;
    public class Appl extends Applet {
         private int [] myArray1 = new int [156];     
         private int [] myArray2 = new int [156];
         private boolean flag = false;
         // maxDataYAxesNumber es usado para dividir el eje de las Y
    public void init()
              setFont(new Font("SansSerif", Font.BOLD, 12));
              setBackground (Color.white);
              setSize(getSize());     
    // Get data and put in an array
    public void setData(String data1, String data2)
              final String DELIMITER = ",";
              final StringTokenizer theTokens1 =
                   new StringTokenizer(data1, DELIMITER);     
              final StringTokenizer theTokens2 =
                   new StringTokenizer(data2, DELIMITER);
              try
                        String dataX = data1;
                        for (int i = 0; i < 156; i++)
                        myArray1[i] = Integer.parseInt(theTokens1.nextToken().trim());
                        myArray2[i] = Integer.parseInt(theTokens2.nextToken().trim());
              catch (NumberFormatException e) {};
              flag = true; //I get the data OK
              repaint();
    public void paint (Graphics g){
    Graphics2D g2d = (Graphics2D)g;
    setData(data1, data2) ;
    if (flag == true)
                   //Call other functions to process the graphic
    else g2d.drawString(" Sorry I can get Data", 100,80);          

  • Problem downloading applet in W2K with SP4.

    Hi,
    We are using a Security Applet in our web application for validation purposes. We were using W2K Professional / W2K Server with SP3 and Sun JRE 1.3.x. The application was working as expected.
    We are now testing with W2K Server with SP4 (to upgrade to SP4). The current testing environment is W2K Server with SP4 and Sun JRE1.3.x. Now with the setup, we are facing a problem in downloading the applet (Security Applet). The downloading applet fails and the subsequent loading as well.
    Please advice. Does it requires any particular settings to be done at Client?
    The specs are
    Windows 2000 Server, SP4
    IE 6 SP1
    Sun Jre 1.3.x
    Problem:Downloading applet fails.
    PS: When we test with SP3, we can see the applet downloaded (CAB File), with SP4 it was not found.
    Thanks in Advance,
    Prakash

    Does the w2k sp4 server host your pages and applet?
    If yes then why install the SUN JRE 1.3 on the server, doesn't the client need this?
    Is the cab format supported by SUN jre or is it meant for msjvm and if so why is the client trying to open
    the cab with sun jre?
    http://java.sun.com/j2se/1.4.2/docs/guide/deployment/deployment-guide/upgrade-guide/article-02.html
    What's on the server doesn't have anything to do with the applet. The server is
    just serving it. Forcing the client/consumer of the html page with the applet is trying to open an applet
    with sun jre while the applet is ment for msjvm causes the error.
    The client can fix this by opening IE and check under tools -> internet options -> advanced -> UNCHECK
    the use sun jre ... for <applet tag. For the XP machine you might have a problem. Some of the don't have
    the msjvm at all so there is nothing to run the <applet, I tried to download it at microsoft but was unable
    to find it.

  • Problem resizing Viewport with WebDeveloper in WinXP and Vista

    I'm having a problem resizing the Viewport with WebDeveloper running in FF10 & FF11 on my WinXP and Vista machines. Quite simply, I'm trying to resize the Viewport to 320x420pixels (to represent an iPhone) but can't get it to go below 510px.
    There's no problem in FF1 on Win7. I have contacted Chris Pederick, the developer of WebDeveloper, and he says his code is tha same in all cases, and pretty basic JS. So possibly the fault lies in the browser. I've not noticed this problem in earlier versions of FF (i.e around 3.5)

    Try to hide all toolbars or open a second window and hide them there to see if that allows to make the window smaller.

  • Problem resizing objects

    I really think I may have lost it on this one. I am having
    problems resizing any object inside of illustrator. Normally when i
    use my selection tool, There is a box around the whole object that
    I can click and drag to resize. It's not there, and consequently, I
    can resize anything without going to
    Object&gt;Transform&gt; Scale... and that's just too much.
    Is there a setting I somehow messed with that did this? I am
    completely lost. I dont even have a clue what is goin on anymore.
    Any help would be much appreciated!

    You may have hit CTRL+SHIFT+B which hides the bounding box
    around objects. so hit CTRL+SHIFT+B again to see if that fixes the
    issue. You can also find it view/ under &quot;Show
    Rulers&quot;
    Sorry Dreamweaverites for replying to an Illustrator question
    in a Dreamweaver forum.
    I had to help a brother out. You Know,
    Shane

  • Severe Problem in Applets

    I hav problem in Applets by use of threads.The prb. is that i am supposed to create three threads in applets.Thread one will read a file and extract a character array of size 10 from it and Thread 2 will display those characters in Textarea of Applets and after 10 seconds Thread3 will delete those chracters from textarea and next character set of Array of size 10 from Thread one will be assigned to Thread2 and process should go on untill it reads all character from file.Please sort this problem with source code.All are warmly welcome.
    Anuj.

    Thread one will read a file Since applets cannot read from the filesystem you have to use the URL object to read the file and place the
    file in the same location as your applet:
              try {
                   url = new URL(this.getCodeBase(), "yourfile.txt");
                   URLConnection conn = url.openConnection();
                   InputStream in = conn.getInputStream();
                   ByteArrayOutputStream bos = new ByteArrayOutputStream();
                   byte[] buf = new byte[1024];
                   int len;
                   while ((len = in.read(buf)) > 0) {
                        bos.write(buf, 0, len);
                   byte[] data = bos.toByteArray();
    //               String dataString = new String(data,"Shift_JIS"); // depending on your file encoding
              } catch (Exception e) {
                   e.printStackTrace(System.out);
              }How to use threads:
    http://java.sun.com/docs/books/tutorial/essential/threads/index.html

  • Problem in Applet while communicating with Javascript

    Hi,
    I’m facing a problem with applet. Applet calls JavaScript methods and vice versa. Applet works fine with JRE 5 to JRE 6 up to build no 1.6.0._7 but it fails with build no 1.6.0_10.
    The problem description is given below:
    After embedding applet in my HTML page using <OBJECT> tag, I’ve to check either any problem during applet’s execution, I want to get the error reason by calling my defined method getErrorReason() in applet that returns the error reason, I call the getErrorReason() against the applet’s object in JavaScript immediately after embed applet code in my HTML page, a JavaScript errors occurs and my applet fails to perform its execution.
    JavaScript error: Object does not support this property.
    The error points to the HTML page area where I’m calling getErrorReason() against applet object.
    The above JavaScript error occurs after the successful completion of Applet’s init(). I’m facing this problem only in JRE 6 build 1.6.0_10-b33.
    Please suggest me any solution.
    Thanks in advance.
    Regards,
    Israr Ahmed

    Hi Bharath,
    Even i got similar error and i tried deleting the below(Attaching the stack trace is always better way.)
    1) delete the folder ‘workspace’ or rename(including all files and subfolders) in the path D:\Documents and Settings\lzcr8r\Documents\SAP\workspace
    2) delete all .dtr/.dtc/.metadata directories in your personal folder (e.g. C:\Documents and Settings\lzcr8r).
    Restart the IDE once you are done with the above steps.
    Second part to increase the virtual mem
    1) RtClick on the Shortcut of NWDS -->Properties and in the Target put the below
    "C:\Program Files\SAP\IDE\IDE70\eclipse\SapIde.exe" -vmargs -Xms512m -Xmx1536m  "C:\j2sdk1.4.2_08\bin\javaw.exe"
    2) You can also try  Creating a bat file with the complete path of your IDE and start your ide from the bat
       content in the bat eg: "C:\Program Files\netbeans-4.1\bin\netbeans.exe" -vmargs -Xms512m -Xmx1536m
    Here -Xms512m is the min JVM size and -Xmx1024m is the max JVM size.
    You can place this batch file anywhere and double click the batch file.
    It will automatically start your IDE
    3) if you are using Tomcat you can try creating an env variable and assign Value
    Variable Name:  CATALINA_OPTS
    Variable Value:  -server -Xmx800m
    please award points if usefull.
    Regards
    Souza
    Edited by: Souza Aluri on Apr 9, 2008 9:46 AM

  • Problem Resizing Regions

    I'm having a problem resizing regions.
    On some regions, I can make the region shorter, but I cannot lengthen it.
    On other regions, I can make the region longer, but there is not silence in the added length - instead, the first notes of the region repeat (this happens using the little ruler symbol, not the the little circular arrow symbol)
    Does it make any difference if the region is a copied region? Can you only lengthen original regions and not copied regions? I tried changing the resolution as per a prior post about this problem and that did not help.
    Thanks for your suggestions.

    On some regions, I can make the region shorter, but I cannot lengthen it.
    you can not make an audio ("real") region longer then it's total length.
    On other regions, I can make the region longer, {but} the first notes of the region repeat (this happens using the little ruler symbol
    by "ruler" do you mean the Right bracket? something like <]>
    what type of region?

  • Netscape Window Resize/Applet Reload Problem

    Is there anyway to keep a java applet from restarting when a Netscape window is resized? This problem doesn't happen in IE.

    In my case, someone told me to eliminate in applet's HTML this directives:
    <META HTTP-EQUIV="Pragma" CONTENT="No-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <META HTTP-EQUIV="Cache-Control" CONTENT="must-revalidate">
    <META HTTP-EQUIV="Cache-Control" CONTENT="mag-age=0">
    Further, to set in Preferences/Advanced/Cache the option "Once per session" for "Document in cache is compared to document to network"
    Believe me, in my case, it's worked with no aditional changes in the original applet's code. (Don't thank to me, my chilean friend Christian was the magician).

  • Problem with Applets in same page

    Hai to all,
    I am having a problem with GUI in applets
    My first class extends a JPanel named A_a
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    public class A_a extends JPanel
    JButton jb;
    JTextArea text;
    public A_a()
    setLayout(new FlowLayout());
    jb=new JButton("Click me");
    //add(jb);
    text=new JTextArea(5,20);
    add(text);
    public void text_appendText(String aa)
    System.out.println("I AM IN A_a");
    text.append(aa);
    text.revalidate();
    revalidate();
    /*public static void main(String ags[])
    A_a a = new A_a();
    JFrame frame=new JFrame();
    frame.getContentPane().add(a);
    frame.pack();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) { System.exit(0); }
    frame.setSize(200,200);
    frame.show();
    and then I am using other class B_b which is an applet carries a exitsing panel (A_a) inside it .
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class B_b extends JApplet
    public A_a a;
    public void init()
    a=new A_a();
    getContentPane().add(a);
    public void text_appendText(String aa)
    final String aaa =aa;
    new Thread(new Runnable()
         public void run()
              a=new A_a();
              a.setBackground(new java.awt.Color(255,200,200));
              System.out.println("I AM IN B_b");
              a.text.append(aaa);
              a.text.revalidate();
              getContentPane().remove(a);
              resize(500,500);
         }).start();
    and the I am using the second applet C_c in which by performing a button action the old panel A_a should get removed and replace the new panel D_a (which is not here )in the applet B_b with all other components(namely button , text fields etc)
    import javax.swing .*;
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.util.*;
    public class C_c extends JApplet implements ActionListener
    JButton jbt;
    JTextArea jta;
    public void init()
    getContentPane().setLayout(new FlowLayout());
    jbt=new JButton("Click me");
    jbt.addActionListener(this);
    getContentPane().add(jbt);
    jta=new JTextArea(5,20);
    getContentPane().add(jta);
    public void actionPerformed(ActionEvent ae)
    Enumeration e = getAppletContext().getApplets();
    Applet applets = null;
              while(e.hasMoreElements())
                   applets=(Applet)e.nextElement();
                   if ( applets instanceof B_b)
                             System.out.println("I AM CLASS C_c");
                             ((B_b)applets).text_appendText(jta.getText());          
                             ((B_b)applets).remove());
                             ((B_b)applets).getContentPane().add(D_d);
    both the applets C_c and B_b are in same browser page
    How can i achive that pls help .

    please help me its urgent for my project

  • Resize applet within a HTML frame

    Hi,
    I am using an applet to display a tree in a HTML frame of a web page.
    I would like to resize or refresh the applet when the HTML frame is resized. Is there a way for the applet to know when the HTML frame is resized?
    Any help will be appreciated.
    Thanks

    I tried using the componentResized() method to solve this problem but I was unsuccessful.
    Here is what I tried:
    My application consists of using a Java applet to display a tree in a HTML frame. In addition I put the tree in a scroll pane. I tried using addComponentListener(this) to get the componentResized() method to be involked. I tried adding the component listener to the scroll pane:
    JScrollPane treeView = new JScrollPane(tree);
    treeView.addComponentListener(this);
    I tried adding the component listener to the root pane:
    JRootPane root = getRootPane();
    root.addComponentListener(this);
    and I tried adding the comoponent listener to the glass pane and the content pane.
    The componentResized() method was involked when the tree was initially displayed in some of my attempts but I was never able to get the componentResized() method to be involked when I resized the html frame.
    I believe that I am having a problem determining which component to add the addComponentListener to so that the componentResized() method get invoked when I resize the html frame.

  • Swing JComboBox causes scrolling problems in applet

    I have an applet with a JPanel that contains a JComboBox that lists font selections for a JTextPane in a JPanel below it. It contains about 12 items, of which only five are visible at a time. If I choose any of the first five and scroll the page on which the applet is running, there are no issues. However, if I scroll the page after scrolling down the list to the sixth item, regardless of whether or not I actually select it, it causes the graphics in the applet to corrupt. The JComboBox code is:
    private JComboBox getFontFaceCB() {
                   String[] fontNames = new String[fontlist.length];
                   for (int i = 0; i < fontlist.length; i++){
                        fontNames[i] = fontlist.getFamily();
                   if (fontFaceCB == null) {
                        fontFaceCB = new JComboBox(fontNames);
                        fontFaceCB.setBackground(Color.white);
                        fontFaceCB.setPreferredSize(new Dimension(150, 30));
                        fontFaceCB.setMaximumRowCount(5);
                        fontFaceCB.setSelectedIndex(0);
                        fontFaceCB.addItemListener(new java.awt.event.ItemListener() {
                             public void itemStateChanged(java.awt.event.ItemEvent e) {
                                            currentFont = fontlist[fontFaceCB.getSelectedIndex()];
                                            StyleConstants.setFontFamily(textStyles, currentFont.getFamily());
                                            jTextPane.setCharacterAttributes(textStyles, true);
                                            viewWidget.repaint();
                   return fontFaceCB;
              }This also happens if I set the default index to something that one must scroll down to reach (e.g. the sixth index) I was wondering if anyone else has come across this issue and has any idea as to how this may be resolved.
    Also, if the window is minimized, resized, etc. the graphics also corrupt, but only after the aforementioned condition.
    Edited by: BANZ111 on Dec 12, 2007 3:59 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I have found the solution:
    I had lightweight components intertwined with heavyweight ones, which, until now, I never regarded as being a possible source of problems. Apparently, when you scroll down a JComboBox, it changes from light to heavy weight? At any rate, I found this with a lot of other useful tips here:
    http://72.5.124.55/javase/6/webnotes/trouble/TSG-Desktop/html/gchzf.html#gdldq
    Perhaps this can be of use to anyone else who gets a similar problem.

  • Please Help : Big problem with applets

    Hi,
    I have a big problem which I have not been able to figure out. The applet I have enclosed works fine on some computers but not on others .
    I am running :
    java version "1.3.1_02"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02)
    Java HotSpot(TM) Client VM (build 1.3.1_02-b02, mixed mode)
    The applet runs perfectly Ok at university but not on other computers.
    The objective of the applet is to display 3 shapes on the screen once. On the university computer it works, however at home and work the 3 shapes are continuously displayed on the screen ( like they are in some infinite loop). I have been struggling with this for days any help would be greatly appreciated.
    It would help me if some of you could run this applet and let me know if the shapes are displayed once or if the shapes are continuously updated on the screen ( assuming that the applet window is not resized covered over etc. )
    =========================================
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    /*<html><applet code = "stage1.class" height = "600" width="810"></applet></html>*/
    public class stage1 extends JApplet{
    JPanel extraPanel = new JPanel();
    public void init()
    Container c = getContentPane();
    extraPanel.setBackground (Color.white);
    extraPanel.setLayout (new FlowLayout());
    c.add(extraPanel);
    public void paint (Graphics g)
    //super.paint( g ); // call superclass's paint method
    // populate the two dimensional array - store the coordinates for the circle and square shapes
    int circle[][] = { {100,100,200,200}, // display circle in the left hand side of the screen
    {350,100,200,200}, // display circle in the middle of the screen
    {600,100,200,200} }; // display circle in the right hand side of the screen
    int rect[][] = { {100,100,200,200}, // display square in the left hand side of the screen
    {350,100,200,200}, // display square in the middle of the screen
    {600,100,200,200} }; // display square in the right hand side of the screen
    // populate the two dimensional array - store the coordinates for the polygon shapes
    int polyX[][] = { {150,250,300,250,150,100 }, // display polygon in the left hand side of the screen
    {400,500,550,500,400,350 }, // display polygon in the middle of the screen
    {650,750,800,750,650,600} }; // display polygon in the right hand side of the screen
    int polyY[] = { 100,100,200,300,300,200    }; // the "Y" co-ordinates wont change for all three polygons
    int xCoordinates[] = new int[ 6 ];
    int pickAShape
    , pickAColour
    , polygonCount = 0
    , circleCount = 0
    , squareCount = 0
    , redCount = 0
    , greenCount = 0
    , blueCount = 0
    , yellowCount = 0 ;
    for ( int position = 0;position < 3;position++ )
    pickAShape = 1 + ( int )( Math.random() * 3 );
    pickAColour = 10 + ( int )( Math.random() * 4 );
    switch ( pickAShape )
    case 1: // draw a circle
    switch ( pickAColour )
    case 10:
    g.setColor( Color.red );
    redCount++;
    break;
    case 11:
    g.setColor( Color.green );
    greenCount++;
    break;
    case 12:
    g.setColor( Color.blue );
    blueCount++;
    break;
    case 13:
    g.setColor( Color.yellow );
    yellowCount++;
    break;
    g.fillOval( circle[position][0],circle[position][1],circle[position][2],circle[position][3] );
    circleCount++;
    break;
    case 2: // draw a rectangle
    switch ( pickAColour )
    case 10:
    g.setColor( Color.red );
    redCount++;
    break;
    case 11:
    g.setColor( Color.green );
    greenCount++;
    break;
    case 12:
    g.setColor( Color.blue );
    blueCount++;
    break;
    case 13:
    g.setColor( Color.yellow );
    yellowCount++;
    break;
    g.fillRect(rect[position][0],rect[position][1],rect[position][2],rect[position][3] );
    squareCount++;
    break;
    case 3: // draw a polygon
    switch ( pickAColour )
    case 10:
    g.setColor( Color.red );
    redCount++;
    break;
    case 11:
    g.setColor( Color.green );
    greenCount++;
    break;
    case 12:
    g.setColor( Color.blue );
    blueCount++;
    break;
    case 13:
    g.setColor( Color.yellow );
    yellowCount++;
    break;
    xCoordinates[0]=polyX[position][0];
    xCoordinates[1]=polyX[position][1];
    xCoordinates[2]=polyX[position][2];
    xCoordinates[3]=polyX[position][3];
    xCoordinates[4]=polyX[position][4];
    xCoordinates[5]=polyX[position][5];
    Polygon polygonInstance = new Polygon ( xCoordinates, polyY, 6 );
    g.fillPolygon( polygonInstance );
    polygonCount++;
    break;
    // display the results
    setFont(new Font("Serif",Font.BOLD,24));
    g.setColor(Color.black);
    if ((circleCount ==3 || squareCount ==3 || polygonCount==3) && (redCount ==3 || greenCount ==3 || blueCount==3 || yellowCount ==3))
    g.drawString( "YOU WIN !!!!" ,380,400 );
    else
    g.drawString( "YOU LOSE !!!!",380,400 );
    } // end method paint
    } // end class stage4
    =========================================
    Regards and thanks

    O.K. You will not believe this, but the problem will be solved if you change the following line from:
        setFont(new Font("Serif",Font.BOLD,24));to:
        g.setFont(new Font("Serif",Font.BOLD,24));Now, since I am also learning JAVA, the way I went about solving was to create your applet from scratch, using cut and paste, and running it piece by piece till I ran into the flashing display. Took me a while. I am enclosing my version of the program for your comments.
    import java.awt.*;
    import java.applet.*;
    public class Slotto extends Applet {
        int circle[][] = { {100,100,200,200}, // circle in the left hand side of the screen
                           {350,100,200,200}, // circle in the middle of the screen
                           {600,100,200,200} }; // circle in the right hand side of the screen
        int rect[][] = { {100,100,200,200}, // square in the left hand side of the screen
                         {350,100,200,200}, // square in the middle of the screen
                         {600,100,200,200} }; // square in the right hand side of the screen
        int polyX[][] = { {150,250,300,250,150,100 }, // polygon in the left hand side of the screen
                          {400,500,550,500,400,350 }, // polygon in the middle of the screen
                          {650,750,800,750,650,600} }; // polygon in the right hand side of the screen
        int polyY[] = { 100,100,200,300,300,200 }; // the "Y" co-ordinates wont change for all three polygons
        int xCoordinates[] = new int[ 6 ];
        int pickAShape
        , pickAColour
        , polygonCount = 0
        , circleCount = 0
        , squareCount = 0
        , redCount = 0
        , greenCount = 0
        , blueCount = 0
        , yellowCount = 0
        , position ;
        public void paint(Graphics g) {
            for (position = 0; position < 3; position++) {
                chooseColor(g);
                drawTheShape(g);
            declareResults(g);
        public void chooseColor(Graphics g) {
            pickAColour = 10 + ( int )( Math.random() * 4 );
            switch ( pickAColour )
                case 10:
                    g.setColor( Color.red );
                    redCount++;
                    break;
                case 11:
                    g.setColor( Color.green );
                    greenCount++;
                    break;
                case 12:
                    g.setColor( Color.blue );
                    blueCount++;
                    break;
                case 13:
                    g.setColor( Color.yellow );
                    yellowCount++;
                    break;
        public void drawTheShape(Graphics g) {
            pickAShape = 1 + ( int )( Math.random() * 3 );
            switch ( pickAShape )
                case 1: // draw a Circle
                    g.fillOval( circle[position][0],
                                circle[position][1],
                                circle[position][2],
                                circle[position][3] );
                    circleCount++;
                    break;
                case 2: // draw a Square
                    g.fillRect(rect[position][0],
                               rect[position][1],
                               rect[position][2],
                               rect[position][3] );
                    squareCount++;
                    break;
                case 3: // draw a Polygon
                    xCoordinates[0]=polyX[position][0];
                    xCoordinates[1]=polyX[position][1];
                    xCoordinates[2]=polyX[position][2];
                    xCoordinates[3]=polyX[position][3];
                    xCoordinates[4]=polyX[position][4];
                    xCoordinates[5]=polyX[position][5];
                    Polygon polygonInstance = new Polygon ( xCoordinates,
                                                            polyY, 6 );
                    g.fillPolygon( polygonInstance );
                    polygonCount++;
                    break;
        public void declareResults(Graphics g) {
            g.setFont(new Font("Serif",Font.BOLD,24));
            g.setColor(Color.black);
            if ((circleCount ==3 || squareCount ==3 || polygonCount==3)
             && (redCount ==3 || greenCount ==3 || blueCount==3 || yellowCount ==3))
                g.drawString( "YOU WIN !!!!" ,380,400 );
            else
                g.drawString( "YOU LOSE !!!!",380,400 );
    }Regards.

  • Win98 need to resize applet viewer to see forms client

    Is there any work around that will aliviate the problem of needing resize the applet viewr (JInitiator) manually to see the java applet?
    This is consistent bug and it seems to appear on all of our Win98 clients (WinNT works fine) in both IE 5.0 and Netscape 4.0

    There is a work around for this problem by using the resize_window(FORMS_MDI_WINDOW, height, width) you can force the refresh of the applet window. The ability to use the resize_window on the MDI window web deployed was supposedly just made available with patch 5. I had the same problem and this fixed it for me.

Maybe you are looking for

  • Creative cloud subscription without internet access

    Would there be a way to get the creative cloud subscription for my work with out using the internet monthly by paying the year in full. My workstation is not online and can't be, it is part of a internal network.

  • Having problems starting Weblogic Managed Server

    Hi, I am new to WebLogic and I was looking at the webservices examples in samples dir and I took the example and just moved it to one of my currently deployed Web Application folder and changed the dir strutcure instead of the samples dir strutcure,

  • Stuck with my phone :(

    Hell started once I joined Verizon. Joined my sister plan to bundle up and supposed to save money. Went to the store and left happy thinking we got a great service. My sister gave me her Iphone 4 and she upgraded to the Iphone 5 and that was that eve

  • Input field in report output

    HI EXPERTS,                I am taking input from user in my report output then I wil save it to my ztable. For taking input I have used follwing code. WRITE : /1 SY-VLINE,                          (5) ITAB-WERKS CENTERED,                          SY

  • Password Sync from Active Directory Locking Accounts

    Hello, We recently set up Active Directory as a resource and are synching passwords. We are using IDM 7.1.1.11. We are noticing that when actions in IDM push the password out to AD, and they sync comes back to IDM, the sync workflow is locking up the