This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help --applet not initialsed error

 
sakshi saw
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please guide for the following error
applet not initialsed.


i have pasted mycode below

package mypack;

import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class NewJApplet extends JApplet {

/**
* Initialization method that will be called after the applet is loaded
* into the browser.
*/
public void init() {
// JFrame MyFrame=new JFrame("COMPONENT DISPLAYER");
Mypanel jp=new Mypanel();
// add(MyFrame);
add(jp);
// TODO start asynchronous download of heavy resources
}

// TODO overwrite start(), stop() and destroy() methods

}
package mypack;

import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.JPanel;

/**
*
* @author
*/
public class Mypanel extends JPanel{

private MyScrollPane scroll;

public Mypanel() {

setBorder(BorderFactory.createLineBorder(Color.BLACK));
scroll=new MyScrollPane();
add(scroll);

}


}

package mypack;
import java.awt.Color;
import javax.swing.*;
/**
*
* @author
*/
public class MyScrollPane extends JScrollPane{

public MyScrollPane() {
super();
// super(VERTICAL_SCROLLBAR_ALWAYS,HORIZONTAL_SCROLLBAR_ALWAYS);
setBackground(Color.BLUE);
}


}


the output is below-

java.lang.IllegalArgumentException: invalid verticalScrollBarPolicy
at javax.swing.JScrollPane.setVerticalScrollBarPolicy(JScrollPane.java:466)
at javax.swing.JScrollPane.<init>(JScrollPane.java:258)
at javax.swing.JScrollPane.<init>(JScrollPane.java:304)
at mypack.MyScrollPane.<init>(MyScrollPane.java:16)
at mypack.Mypanel.<init>(Mypanel.java:23)
at mypack.NewJApplet.init(NewJApplet.java:24)
at sun.applet.AppletPanel.run(AppletPanel.java:380)
at java.lang.Thread.run(Thread.java:595)
BUILD SUCCESSFUL (total time: 2 seconds)
 
Rob Spoor
Sheriff
Pie
Posts: 20667
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Use Code Tags. And please Ease Up.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the code posted does not profduce that error for me

but the error is self-explanatory
java.lang.IllegalArgumentException: invalid verticalScrollBarPolicy
 
sakshi saw
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir please i have not been able to solve the problem i went through JScrollPane constructos i dont think the mistake is here!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you are even told what line the error occurs
at mypack.MyScrollPane.<init>(MyScrollPane.java:16)

and, by counting the lines of what you posted, line 16 is a blank line.
so you haven't posted the real code, meaning you'll have to find the problem for yourself
 
sakshi saw
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sir i have pasted the whole code i even tried to to debug it using watches it gets stuck after
super()

Sir i am new to it and i am seriously confused i have even removed the line add(scroll);
from constructor
btw was it correct to place it there becuse panel has not been constructed fully and i was adding it
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just tried it again (all files in a single .java file) and it compiled and ran without error.

all I can suggest is you try to compile MyScrollPane() on it's own, then read and follow the error message/s
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic