trance12
asked on
java web start problem
hi
can someone point to me what i'm doing wrong here..i'm trying to launch a simple applet as an application through web start using a jnlp file locally on my pc..it launches web start and then just dies..i know web start works cause i've launched test applications from the web..all the files are in the C:/java_source directory..i thouhgt i had it working earlier but was mistaken..crmloginapplet has a main class thats the entry point..that calls crmlogin where the applet is painted..if there is a better way to do this please let me know..thank you
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for CRM -->
<jnlp
spec="1.0+"
codebase="file:///C:/java_ source/"
href="crmmodule.jnlp">
<information>
<title>CRM Login</title>
<vendor>Sun Microsystems, Inc.</vendor>
<homepage href="http://www.telk.com.au"/>
<description>CRM Login Application</description>
<description kind="short">CRM login screen.</description>
<icon href="intro.jpg"/>
<icon href="ok.jpg"/>
<icon href="nothanks.jpg"/>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.4"/>
<jar href="crmmodule.jar"/>
</resources>
<application-desc main-class="CRMLoginApplet "/>
</application-desc>
</jnlp>
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import java.util.Vector;
import java.io.*;
import java.net.*;
public class CRMLoginApplet extends Applet {
public void init() {
String customerCareEmail = "at@telk.com.au";
setSize(278, 175);
Image introImage = getImage(getCodeBase(), "intro.jpg");
Image okImage = getImage(getCodeBase(), "ok.jpg");
Image nothanksImage = getImage(getCodeBase(), "nothanks.jpg");
setLayout( new BorderLayout() );
try {
add( "Center",new CRMLogin(this,customerCare Email,intr oImage,okI mage,notha nksImage)) ;
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public void destroy() {
}
static public void main( String args[] ) {
new CRMLoginApplet();
}
}
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.StringTokenizer;
import java.io.*;
import java.net.*;
import java.util.Vector;
public class CRMLogin extends Applet implements Serializable, ActionListener,MouseListen er {
private TextArea ta = new TextArea();
private TextField tf = new TextField();
private Panel PN1;
private final static boolean DEBUG = false;
private java.awt.Button button1;
private java.awt.Button button2;
private java.awt.Button button3;
private java.awt.Label label1;
private java.awt.Panel panel1;
private java.awt.Panel panel3;
private java.awt.Panel panel4;
private java.awt.Panel panel5;
private java.awt.Panel panel2;
private java.awt.TextField textField1;
String t;
private Applet applet;
// Constructor
public CRMLogin(final Applet a, final String customerCareEmail,Image introImage, Image okimage, Image nothanks) {
this.applet = a;
button1 = new java.awt.Button();
panel1 = new java.awt.Panel();
panel2 = new java.awt.Panel();
label1 = new java.awt.Label();
textField1 = new java.awt.TextField();
panel3 = new java.awt.Panel();
panel5 = new java.awt.Panel();
panel4 = new java.awt.Panel();
button1.setLabel("button1" );
setLayout(new java.awt.BorderLayout());
panel1.setLayout(null);
panel1.setBackground(new java.awt.Color(255, 255, 255));
panel1.setForeground(new java.awt.Color(0, 0, 0));
panel2 = new ImagePanel(introImage);
panel2.setBackground(new java.awt.Color(255, 255, 255));
panel1.add(panel2);
panel2.setBounds(10, 10, 510, 160);
label1.setAlignment(java.a wt.Label.C ENTER);
label1.setBackground(new java.awt.Color(255, 255, 255));
label1.setFont(new java.awt.Font("Arial", 1, 14));
label1.setForeground(new java.awt.Color(150, 150, 150));
label1.setText("your name");
panel1.add(label1);
label1.setBounds(10, 180, 80, 21);
textField1.setFont(new java.awt.Font("Arial", 1, 14));
panel1.add(textField1);
textField1.setBounds(100, 180, 400, 21);
panel3 = new ImagePanel(okimage );
panel1.add(panel3);
panel3.setBounds(10, 210, 240, 90);
textField1.setText(custome rCareEmail );
textField1.setForeground(n ew java.awt.Color(247, 68, 111));
panel1.add(panel4);
panel4 = new ImagePanel(nothanks );
panel1.add(panel4);
panel4.setBounds(300, 210, 220, 90);
panel4.addMouseListener(th is);
add(panel1, java.awt.BorderLayout.CENT ER);
}
}
can someone point to me what i'm doing wrong here..i'm trying to launch a simple applet as an application through web start using a jnlp file locally on my pc..it launches web start and then just dies..i know web start works cause i've launched test applications from the web..all the files are in the C:/java_source directory..i thouhgt i had it working earlier but was mistaken..crmloginapplet has a main class thats the entry point..that calls crmlogin where the applet is painted..if there is a better way to do this please let me know..thank you
<?xml version="1.0" encoding="utf-8"?>
<!-- JNLP File for CRM -->
<jnlp
spec="1.0+"
codebase="file:///C:/java_
href="crmmodule.jnlp">
<information>
<title>CRM Login</title>
<vendor>Sun Microsystems, Inc.</vendor>
<homepage href="http://www.telk.com.au"/>
<description>CRM Login Application</description>
<description kind="short">CRM login screen.</description>
<icon href="intro.jpg"/>
<icon href="ok.jpg"/>
<icon href="nothanks.jpg"/>
<offline-allowed/>
</information>
<security>
<all-permissions/>
</security>
<resources>
<j2se version="1.4"/>
<jar href="crmmodule.jar"/>
</resources>
<application-desc main-class="CRMLoginApplet
</application-desc>
</jnlp>
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import java.util.Vector;
import java.io.*;
import java.net.*;
public class CRMLoginApplet extends Applet {
public void init() {
String customerCareEmail = "at@telk.com.au";
setSize(278, 175);
Image introImage = getImage(getCodeBase(), "intro.jpg");
Image okImage = getImage(getCodeBase(), "ok.jpg");
Image nothanksImage = getImage(getCodeBase(), "nothanks.jpg");
setLayout( new BorderLayout() );
try {
add( "Center",new CRMLogin(this,customerCare
}
catch (Exception ex) {
ex.printStackTrace();
}
}
public void destroy() {
}
static public void main( String args[] ) {
new CRMLoginApplet();
}
}
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.util.StringTokenizer;
import java.io.*;
import java.net.*;
import java.util.Vector;
public class CRMLogin extends Applet implements Serializable, ActionListener,MouseListen
private TextArea ta = new TextArea();
private TextField tf = new TextField();
private Panel PN1;
private final static boolean DEBUG = false;
private java.awt.Button button1;
private java.awt.Button button2;
private java.awt.Button button3;
private java.awt.Label label1;
private java.awt.Panel panel1;
private java.awt.Panel panel3;
private java.awt.Panel panel4;
private java.awt.Panel panel5;
private java.awt.Panel panel2;
private java.awt.TextField textField1;
String t;
private Applet applet;
// Constructor
public CRMLogin(final Applet a, final String customerCareEmail,Image introImage, Image okimage, Image nothanks) {
this.applet = a;
button1 = new java.awt.Button();
panel1 = new java.awt.Panel();
panel2 = new java.awt.Panel();
label1 = new java.awt.Label();
textField1 = new java.awt.TextField();
panel3 = new java.awt.Panel();
panel5 = new java.awt.Panel();
panel4 = new java.awt.Panel();
button1.setLabel("button1"
setLayout(new java.awt.BorderLayout());
panel1.setLayout(null);
panel1.setBackground(new java.awt.Color(255, 255, 255));
panel1.setForeground(new java.awt.Color(0, 0, 0));
panel2 = new ImagePanel(introImage);
panel2.setBackground(new java.awt.Color(255, 255, 255));
panel1.add(panel2);
panel2.setBounds(10, 10, 510, 160);
label1.setAlignment(java.a
label1.setBackground(new java.awt.Color(255, 255, 255));
label1.setFont(new java.awt.Font("Arial", 1, 14));
label1.setForeground(new java.awt.Color(150, 150, 150));
label1.setText("your name");
panel1.add(label1);
label1.setBounds(10, 180, 80, 21);
textField1.setFont(new java.awt.Font("Arial", 1, 14));
panel1.add(textField1);
textField1.setBounds(100, 180, 400, 21);
panel3 = new ImagePanel(okimage );
panel1.add(panel3);
panel3.setBounds(10, 210, 240, 90);
textField1.setText(custome
textField1.setForeground(n
panel1.add(panel4);
panel4 = new ImagePanel(nothanks );
panel1.add(panel4);
panel4.setBounds(300, 210, 220, 90);
panel4.addMouseListener(th
add(panel1, java.awt.BorderLayout.CENT
}
}
ASKER
ok..i've changed the main entry class to be
public void start() {
}
public void destroy() {
}
static public void main( String args[] ) {
CRMLoginApplet a = new CRMLoginApplet();
a.init();
a.start();
Frame appletFrame = new Frame("Applet Window");
appletFrame.add("Center", a);
appletFrame.setSize(150,15 0);
appletFrame.setLocation(10 0,100);
appletFrame.show();
}
i've added it to a frame..what do i replace getCodeBase with?
public void start() {
}
public void destroy() {
}
static public void main( String args[] ) {
CRMLoginApplet a = new CRMLoginApplet();
a.init();
a.start();
Frame appletFrame = new Frame("Applet Window");
appletFrame.add("Center", a);
appletFrame.setSize(150,15
appletFrame.setLocation(10
appletFrame.show();
}
i've added it to a frame..what do i replace getCodeBase with?
The URL of the directory on the server to find the images.
Might be better though to include the images in your jar and load them using getResource()
Might be better though to include the images in your jar and load them using getResource()
ASKER
i've tried this
Image introImage = new ImageIcon(this.getClass(). getResourc e("intro.j pg"));
it gives me this erro..what am i missing?
CRMLoginApplet.java [23:1] cannot resolve symbol
symbol : constructor ImageIcon (java.net.URL)
location: class ImageIcon
Image introImage = new ImageIcon(this.getClass(). getResourc e("intro.j pg"));
Image introImage = new ImageIcon(this.getClass().
it gives me this erro..what am i missing?
CRMLoginApplet.java [23:1] cannot resolve symbol
symbol : constructor ImageIcon (java.net.URL)
location: class ImageIcon
Image introImage = new ImageIcon(this.getClass().
ASKER
i've included the images in the jar
ASKER
and this is the imageicon class
import java.awt.*;
import java.awt.image.ImageObserv er;
import java.applet.Applet;
public class ImageIcon extends Applet
{
private Image img;
public ImageIcon(Image i)
{
this.img = i;
}
public void paint(Graphics g)
{
//super.paint(g);
g.drawImage(img, 10, 10, this);
}
}
import java.awt.*;
import java.awt.image.ImageObserv
import java.applet.Applet;
public class ImageIcon extends Applet
{
private Image img;
public ImageIcon(Image i)
{
this.img = i;
}
public void paint(Graphics g)
{
//super.paint(g);
g.drawImage(img, 10, 10, this);
}
}
should be:
ImageIcon introImage = new ImageIcon(this.getClass(). getResourc e("intro.j pg"));
and make sure to import javax.swing.*
ImageIcon introImage = new ImageIcon(this.getClass().
and make sure to import javax.swing.*
Sorry I thought you were using javax.swing.ImageIcon.
> public class ImageIcon extends Applet
Everything does not need to extend Applet, in fact none of them need to :)
> public class ImageIcon extends Applet
Everything does not need to extend Applet, in fact none of them need to :)
I'd also suggest using Swing, it gives you a far richer gui.
ASKER
i tried that too...actually i want to use javax.swing..
import javax.swing.*;
ImageIcon introImage = new ImageIcon(this.getClass(). getResourc e("intro.j pg"));
it still give me the same error?
import javax.swing.*;
ImageIcon introImage = new ImageIcon(this.getClass().
it still give me the same error?
Delete your ImageIcon class, you don't need it.
ASKER
i did ..i just deleted it..it still gives me the error though??
did u also delete the class file?
ASKER
yep
ASKER
this is the init part
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import java.util.Vector;
import java.io.*;
import javax.swing.*;
public class CRMLoginApplet extends Applet {
public void init() {
String customerCareEmail = "akash.hegde@peopletelecom .com.au";
ImageIcon introImage = new ImageIcon(this.getClass(). getResourc e("intro.j pg"));
ImageIcon okImage = new ImageIcon(this.getClass(). getResourc e("ok.jpg" ));
ImageIcon nothanksImage = new ImageIcon(this.getClass(). getResourc e("nothank s.jpg"));
}
import java.applet.*;
import java.awt.*;
import java.io.*;
import java.net.*;
import java.util.Vector;
import java.io.*;
import javax.swing.*;
public class CRMLoginApplet extends Applet {
public void init() {
String customerCareEmail = "akash.hegde@peopletelecom
ImageIcon introImage = new ImageIcon(this.getClass().
ImageIcon okImage = new ImageIcon(this.getClass().
ImageIcon nothanksImage = new ImageIcon(this.getClass().
}
that should be fine, check you don't still have a copy of ImageIcon.class somewhere on your classpath.
You an make it more explicit by doing:
javax.swing.ImageIcon introImage = new javax.swing.ImageIcon(this .getClass( ).getResou rce("intro .jpg"));
Note, that intro.jpg should be in the same place as this class (if that class is inside its packge and the image is in the root
of the jar then you can replace "intro.jpg" with "/intro.jpg")
javax.swing.ImageIcon introImage = new javax.swing.ImageIcon(this
Note, that intro.jpg should be in the same place as this class (if that class is inside its packge and the image is in the root
of the jar then you can replace "intro.jpg" with "/intro.jpg")
ASKER
not sure what i'm doing wrong here
ImageIcon introImage = new ImageIcon(this.getClass(). getResourc e("intro.j pg"));
ImageIcon okImage = new ImageIcon(this.getClass(). getResourc e("ok.jpg" ));
ImageIcon nothanksImage = new ImageIcon(this.getClass(). getResourc e("nothank s.jpg"));
setLayout( new BorderLayout() );
try {
add( "Center",new CRMLogin(this,customerCare Email,intr oImage,okI mage,notha nksImage)) ;
in crmlogin, its compiled fine..
public CRMLogin(final Applet a, final String cust, final String custno,ImageIcon introImage, ImageIcon okimage, ImageIcon nothanks) {
i get this error:
CRMLoginApplet.java [27:1] cannot resolve symbol
symbol : constructor CRMLogin (CRMLoginApplet,java.lang. String,jav ax.swing.I mageIcon,j avax.swing .ImageIcon ,javax.swi ng.ImageIc on)
location: class CRMLogin
add( "Center",new CRMLogin(this,customerCare Email,intr oImage,okI mage,notha nksImage)) ;
ImageIcon introImage = new ImageIcon(this.getClass().
ImageIcon okImage = new ImageIcon(this.getClass().
ImageIcon nothanksImage = new ImageIcon(this.getClass().
setLayout( new BorderLayout() );
try {
add( "Center",new CRMLogin(this,customerCare
in crmlogin, its compiled fine..
public CRMLogin(final Applet a, final String cust, final String custno,ImageIcon introImage, ImageIcon okimage, ImageIcon nothanks) {
i get this error:
CRMLoginApplet.java [27:1] cannot resolve symbol
symbol : constructor CRMLogin (CRMLoginApplet,java.lang.
location: class CRMLogin
add( "Center",new CRMLogin(this,customerCare
> add( "Center",new CRMLogin(this,customerCare Email,intr oImage,okI mage,notha nksImage)) ;
> CRMLogin(final Applet a, final String cust, final String custno,ImageIcon introImage, ImageIcon okimage, ImageIcon nothanks)
It expects two strings, customer and customerNo
> CRMLogin(final Applet a, final String cust, final String custno,ImageIcon introImage, ImageIcon okimage, ImageIcon nothanks)
It expects two strings, customer and customerNo
ASKER
thanks..web start loads it fien without the images..when i include the iamge icons, it just launches and dissapears again..
ImageIcon introImage = new ImageIcon(this.getClass(). getResourc e("intro.j pg"));
ImageIcon okImage = new ImageIcon(this.getClass(). getResourc e("ok.jpg" ));
ImageIcon nothanksImage = new ImageIcon(this.getClass(). getResourc e("nothank s.jpg"));
add( "Center",new CRMLogin(this,customerCare Email,intr oImage,okI mage,notha nksImage)) ;
i'm loading images onto jpanel in CRMLogin
jPanel2 = new CRMImageJPanel(introImage. getImage() );
jPanel2.setBackground(new java.awt.Color(255, 255, 255));
jPanell.add(jPanel2);
jPanel2.setBounds(10, 10, 510, 160);
anything wrong with the above or should i be loading images in a different way?
Thanks
ImageIcon introImage = new ImageIcon(this.getClass().
ImageIcon okImage = new ImageIcon(this.getClass().
ImageIcon nothanksImage = new ImageIcon(this.getClass().
add( "Center",new CRMLogin(this,customerCare
i'm loading images onto jpanel in CRMLogin
jPanel2 = new CRMImageJPanel(introImage.
jPanel2.setBackground(new java.awt.Color(255, 255, 255));
jPanell.add(jPanel2);
jPanel2.setBounds(10, 10, 510, 160);
anything wrong with the above or should i be loading images in a different way?
Thanks
thats fine, where are the images located? They should be in the same directory as the class file.
(You can check the JWS console for any errors)
(You can check the JWS console for any errors)
ASKER
same directory as the class files..no console errors thats the weird thing
> same directory as the class files
in the jar?
> no console errors thats the weird thing
you sure you're not ignoring any exceptions?
in the jar?
> no console errors thats the weird thing
you sure you're not ignoring any exceptions?
ASKER
sorry..dont worry..it worked fine..i forgot to include the iamges in my jnlp file..just one last think how to i control the size of the window that opens up when i lauch web start..currently it just opens it with the min and max buttosn and when i enlarge it, it goes to full screen..is there a away i can set the size of the opening screen?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks..
no worries :)
- create frame and add your applet to that frame
- call init()
- replace the use of getCodeBase() with something else