shepp_it
asked on
Applet not displaying properly
Hi,
I built an applet that used to work fine, but recently for some users the applet's GUI is not displaying properly. I attached applet1.jpg which is how it should appear and works for most people, and applet2.jpg is what few people see on their screen.
So far I found that
1. This happens whether applet runs internally or from the web
2. It happens on all browsers (tried on IE, Chrome), regardless of versions.
3. Complete uninstallation of JRE and reinstallation didn't fix.
4. Uninstallation/reinstallat ion of graphic driver, changing resolution didn't fix
Do you know what can possibly cause this problem? Any help would be appreciated.
Thanks
applet1.jpg
applet2.jpg
I built an applet that used to work fine, but recently for some users the applet's GUI is not displaying properly. I attached applet1.jpg which is how it should appear and works for most people, and applet2.jpg is what few people see on their screen.
So far I found that
1. This happens whether applet runs internally or from the web
2. It happens on all browsers (tried on IE, Chrome), regardless of versions.
3. Complete uninstallation of JRE and reinstallation didn't fix.
4. Uninstallation/reinstallat
Do you know what can possibly cause this problem? Any help would be appreciated.
Thanks
applet1.jpg
applet2.jpg
>applet runs internally
what do you mean by this ?
what do you mean by this ?
ASKER
Yes, I specified the width as a part of HTML code (in JSP) <applet width="893" height="588" code="org.shepp.advmdr.Jav aApplet" archive="ADVMDRApplet.jar" >
"applet runs internally" I mean this happens for both when the applet is loaded from the web server or local internal test server
"applet runs internally" I mean this happens for both when the applet is loaded from the web server or local internal test server
I would check if it is a certificate related issue where you would have to resign the jar file -- just a guess.
Maybe you could try to sepcify width and height in % - maybe it would help
DO you emeann it used to open fine on the same machine, same browser - and now opens ion smaller window suddenly?
DO you emeann it used to open fine on the same machine, same browser - and now opens ion smaller window suddenly?
You may try to use Object elmenet instead of Applet as applet is mopre and more consideerd deprectaed, maybe that would help
check this:
http://docs.oracle.com/javase/1.4.2/docs/guide/plugin/developer_guide/using_tags.html
you probably want to run some investigation to understand what specific situations cause
these incorrect display and if it is browser independent (this is of course first thing which would come to mind when you think of the causes of such situation) then to try to understand at what point it suddenly starts happening
If you could post just GUI part of your code, I could try to run it in y browsers and see how it looks
http://docs.oracle.com/javase/1.4.2/docs/guide/plugin/developer_guide/using_tags.html
you probably want to run some investigation to understand what specific situations cause
these incorrect display and if it is browser independent (this is of course first thing which would come to mind when you think of the causes of such situation) then to try to understand at what point it suddenly starts happening
If you could post just GUI part of your code, I could try to run it in y browsers and see how it looks
ASKER
I use NetBeans IDE to built the applet, and if I use
UIManager.setLookAndFeel(U IManager.g etSystemLo okAndFeelC lassName() );
for the window theme. I have another example that causes the same problem. here is the snippet of code:
package org.me.hello;
import java.io.*;
import java.net.MalformedURLExcep tion;
import java.net.URL;
import java.net.URLConnection;
import javax.swing.UIManager;
/**
*
* @author spark
*/
public class MyApplet extends javax.swing.JApplet {
/** Initializes the applet MyApplet */
public void init() {
try {
UIManager.setLookAndFeel(U IManager.g etSystemLo okAndFeelC lassName() );
//UIManager.setLookAndFeel ("com.sun. java.swing .plaf.wind ows.Window sLookAndFe el");
} catch (Exception e) {
// Just accept the default L&F
}
try {
java.awt.EventQueue.invoke AndWait(ne w Runnable() {
public void run() {
initComponents();
//getContentPane().setBack ground(Col or.white);
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
...
and uses followings html
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Applet and Servlet Communication</h1>
<applet width="500" height="350" code="org.me.hello.MyApple t" archive="JavaApplet.jar"/>
</body>
</html>
UIManager.setLookAndFeel(U
for the window theme. I have another example that causes the same problem. here is the snippet of code:
package org.me.hello;
import java.io.*;
import java.net.MalformedURLExcep
import java.net.URL;
import java.net.URLConnection;
import javax.swing.UIManager;
/**
*
* @author spark
*/
public class MyApplet extends javax.swing.JApplet {
/** Initializes the applet MyApplet */
public void init() {
try {
UIManager.setLookAndFeel(U
//UIManager.setLookAndFeel
} catch (Exception e) {
// Just accept the default L&F
}
try {
java.awt.EventQueue.invoke
public void run() {
initComponents();
//getContentPane().setBack
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
...
and uses followings html
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Applet and Servlet Communication</h1>
<applet width="500" height="350" code="org.me.hello.MyApple
</body>
</html>
I will still need the actual UI contents
if I want to play with it
if I want to play with it
ASKER
Ok here is the entire java code for applet part. I also attched a screenshot on my computer which displays properly and another computer where it doesn't. Applet width is around 500px.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* MyApplet.java
*
* Created on May 21, 2010, 11:20:52 AM
*/
package org.me.hello;
import java.io.*;
import java.net.MalformedURLExcep tion;
import java.net.URL;
import java.net.URLConnection;
import java.util.Vector;
import javax.swing.UIManager;
/**
*
* @author spark
*/
public class MyApplet extends javax.swing.JApplet {
/** Initializes the applet MyApplet */
public void init() {
try {
UIManager.setLookAndFeel(U IManager.g etSystemLo okAndFeelC lassName() );
} catch (Exception e) {
// Just accept the default L&F
}
try {
java.awt.EventQueue.invoke AndWait(ne w Runnable() {
public void run() {
initComponents();
//getContentPane().setBack ground(Col or.white);
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("uncheck ed")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
myTF = new javax.swing.JTextField();
btSubmit = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
myTA = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jLabel1.setText("What is your name?");
btSubmit.setText("Submit") ;
btSubmit.addActionListener (new java.awt.event.ActionListe ner() {
public void actionPerformed(java.awt.e vent.Actio nEvent evt) {
btSubmitActionPerformed(ev t);
}
});
myTA.setColumns(20);
myTA.setRows(5);
jScrollPane1.setViewportVi ew(myTA);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jP anel1);
jPanel1.setLayout(jPanel1L ayout);
jPanel1Layout.setHorizonta lGroup(
jPanel1Layout.createParall elGroup(ja vax.swing. GroupLayou t.Alignmen t.LEADING)
.addGroup(jPanel1Layout.cr eateSequen tialGroup( )
.addContainerGap()
.addGroup(jPanel1Layout.cr eateParall elGroup(ja vax.swing. GroupLayou t.Alignmen t.LEADING)
.addGroup(javax.swing.Grou pLayout.Al ignment.TR AILING, jPanel1Layout.createSequen tialGroup( )
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(myTF, javax.swing.GroupLayout.PR EFERRED_SI ZE, 129, javax.swing.GroupLayout.PR EFERRED_SI ZE)
.addPreferredGap(javax.swi ng.LayoutS tyle.Compo nentPlacem ent.RELATE D)
.addComponent(btSubmit))
.addComponent(jScrollPane1 , javax.swing.GroupLayout.DE FAULT_SIZE , 313, Short.MAX_VALUE))
.addContainerGap())
);
jPanel1Layout.setVerticalG roup(
jPanel1Layout.createParall elGroup(ja vax.swing. GroupLayou t.Alignmen t.LEADING)
.addGroup(jPanel1Layout.cr eateSequen tialGroup( )
.addContainerGap()
.addGroup(jPanel1Layout.cr eateParall elGroup(ja vax.swing. GroupLayou t.Alignmen t.BASELINE )
.addComponent(jLabel1)
.addComponent(myTF, javax.swing.GroupLayout.PR EFERRED_SI ZE, javax.swing.GroupLayout.DE FAULT_SIZE , javax.swing.GroupLayout.PR EFERRED_SI ZE)
.addComponent(btSubmit))
.addPreferredGap(javax.swi ng.LayoutS tyle.Compo nentPlacem ent.RELATE D)
.addComponent(jScrollPane1 , javax.swing.GroupLayout.PR EFERRED_SI ZE, 179, javax.swing.GroupLayout.PR EFERRED_SI ZE)
.addContainerGap(107, Short.MAX_VALUE))
);
jButton1.setText("jButton1 ");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jP anel2);
jPanel2.setLayout(jPanel2L ayout);
jPanel2Layout.setHorizonta lGroup(
jPanel2Layout.createParall elGroup(ja vax.swing. GroupLayou t.Alignmen t.LEADING)
.addGroup(jPanel2Layout.cr eateSequen tialGroup( )
.addContainerGap()
.addComponent(jButton1, javax.swing.GroupLayout.DE FAULT_SIZE , 109, Short.MAX_VALUE)
.addContainerGap())
);
jPanel2Layout.setVerticalG roup(
jPanel2Layout.createParall elGroup(ja vax.swing. GroupLayou t.Alignmen t.LEADING)
.addGroup(jPanel2Layout.cr eateSequen tialGroup( )
.addContainerGap()
.addComponent(jButton1)
.addContainerGap(292, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(ge tContentPa ne());
getContentPane().setLayout (layout);
layout.setHorizontalGroup(
layout.createParallelGroup (javax.swi ng.GroupLa yout.Align ment.LEADI NG)
.addGroup(layout.createSeq uentialGro up()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PR EFERRED_SI ZE, javax.swing.GroupLayout.DE FAULT_SIZE , javax.swing.GroupLayout.PR EFERRED_SI ZE)
.addPreferredGap(javax.swi ng.LayoutS tyle.Compo nentPlacem ent.UNRELA TED)
.addComponent(jPanel1, javax.swing.GroupLayout.PR EFERRED_SI ZE, javax.swing.GroupLayout.DE FAULT_SIZE , javax.swing.GroupLayout.PR EFERRED_SI ZE)
.addContainerGap(javax.swi ng.GroupLa yout.DEFAU LT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup (javax.swi ng.GroupLa yout.Align ment.LEADI NG)
.addGroup(layout.createSeq uentialGro up()
.addContainerGap()
.addGroup(layout.createPar allelGroup (javax.swi ng.GroupLa yout.Align ment.LEADI NG)
.addComponent(jPanel2, javax.swing.GroupLayout.DE FAULT_SIZE , javax.swing.GroupLayout.DE FAULT_SIZE , Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.PR EFERRED_SI ZE, javax.swing.GroupLayout.DE FAULT_SIZE , javax.swing.GroupLayout.PR EFERRED_SI ZE))
.addContainerGap())
);
}// </editor-fold>
private void btSubmitActionPerformed(ja va.awt.eve nt.ActionE vent evt) {
// TODO add your handling code here:
}
// Variables declaration - do not modify
private javax.swing.JButton btSubmit;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea myTA;
private javax.swing.JTextField myTF;
// End of variables declaration
}
applet4.jpg
applet5.jpg
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* MyApplet.java
*
* Created on May 21, 2010, 11:20:52 AM
*/
package org.me.hello;
import java.io.*;
import java.net.MalformedURLExcep
import java.net.URL;
import java.net.URLConnection;
import java.util.Vector;
import javax.swing.UIManager;
/**
*
* @author spark
*/
public class MyApplet extends javax.swing.JApplet {
/** Initializes the applet MyApplet */
public void init() {
try {
UIManager.setLookAndFeel(U
} catch (Exception e) {
// Just accept the default L&F
}
try {
java.awt.EventQueue.invoke
public void run() {
initComponents();
//getContentPane().setBack
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
/** This method is called from within the init() method to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("uncheck
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
myTF = new javax.swing.JTextField();
btSubmit = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
myTA = new javax.swing.JTextArea();
jPanel2 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jLabel1.setText("What is your name?");
btSubmit.setText("Submit")
btSubmit.addActionListener
public void actionPerformed(java.awt.e
btSubmitActionPerformed(ev
}
});
myTA.setColumns(20);
myTA.setRows(5);
jScrollPane1.setViewportVi
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jP
jPanel1.setLayout(jPanel1L
jPanel1Layout.setHorizonta
jPanel1Layout.createParall
.addGroup(jPanel1Layout.cr
.addContainerGap()
.addGroup(jPanel1Layout.cr
.addGroup(javax.swing.Grou
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addComponent(myTF, javax.swing.GroupLayout.PR
.addPreferredGap(javax.swi
.addComponent(btSubmit))
.addComponent(jScrollPane1
.addContainerGap())
);
jPanel1Layout.setVerticalG
jPanel1Layout.createParall
.addGroup(jPanel1Layout.cr
.addContainerGap()
.addGroup(jPanel1Layout.cr
.addComponent(jLabel1)
.addComponent(myTF, javax.swing.GroupLayout.PR
.addComponent(btSubmit))
.addPreferredGap(javax.swi
.addComponent(jScrollPane1
.addContainerGap(107, Short.MAX_VALUE))
);
jButton1.setText("jButton1
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jP
jPanel2.setLayout(jPanel2L
jPanel2Layout.setHorizonta
jPanel2Layout.createParall
.addGroup(jPanel2Layout.cr
.addContainerGap()
.addComponent(jButton1, javax.swing.GroupLayout.DE
.addContainerGap())
);
jPanel2Layout.setVerticalG
jPanel2Layout.createParall
.addGroup(jPanel2Layout.cr
.addContainerGap()
.addComponent(jButton1)
.addContainerGap(292, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(ge
getContentPane().setLayout
layout.setHorizontalGroup(
layout.createParallelGroup
.addGroup(layout.createSeq
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PR
.addPreferredGap(javax.swi
.addComponent(jPanel1, javax.swing.GroupLayout.PR
.addContainerGap(javax.swi
);
layout.setVerticalGroup(
layout.createParallelGroup
.addGroup(layout.createSeq
.addContainerGap()
.addGroup(layout.createPar
.addComponent(jPanel2, javax.swing.GroupLayout.DE
.addComponent(jPanel1, javax.swing.GroupLayout.PR
.addContainerGap())
);
}// </editor-fold>
private void btSubmitActionPerformed(ja
// TODO add your handling code here:
}
// Variables declaration - do not modify
private javax.swing.JButton btSubmit;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea myTA;
private javax.swing.JTextField myTF;
// End of variables declaration
}
applet4.jpg
applet5.jpg
But you didn't provide any 500x100 picture and I didn't seem to see provision for it in the code. Other than that, when I make sure I have sufficiently wide window, say:
I have no problems with the applet - it shows both in IE and Firefox with full view.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Applet and Servlet Communication</h1>
<applet width="500" height="500" code="MyApplet" />
</body>
</html>
I have no problems with the applet - it shows both in IE and Firefox with full view.
ASKER
I don't have this problem either. Most people don't. But for some people it doesn't display correctly.
Still, I would increase the height and width values on your HTML page with the applet
and ask those people who experonce it if they see any difference
and ask those people who experonce it if they see any difference
ASKER
Increasing the height and width didn't work. I think this is a problem with the computer not the applet. I found that it doesn't display GUI component correctly even when I try to run a standard java desktop application. it works fine on other computers.
so you mean it does not resize JFrame when you specify dimensions in Java application ?
Maybe yyou need to reinstall java there ?
Maybe yyou need to reinstall java there ?
ASKER
I reinstalled java but it didn't fix the problem. I'm wondering if this is something to do with hardware now, maybe raphic card or RAM. Still searching for an answer...
If you are saying that this affects not only applets but any java applications, one thing I would create a simple java application-test which illustrates the issue
application is a much better test, as it is not related to any browser, etc.
Then really compare if all those cases where it runs incorrectly have the same graphics card.
This seems strange to me, as I never herad anything of the kind, but there are so many werd things.
But I'd start with having the simplese possible application which couild illustrate the difference.
application is a much better test, as it is not related to any browser, etc.
Then really compare if all those cases where it runs incorrectly have the same graphics card.
This seems strange to me, as I never herad anything of the kind, but there are so many werd things.
But I'd start with having the simplese possible application which couild illustrate the difference.
ASKER
I can't narrow down the problem any further. One thing I noticed is though, two people who are having this problem use browser with higher zoom setting than 100%. Maybe this affected GUI resolution or calibration of pixel size? I know it makes no sense but anything can happen in Windows I think.
Another possible reason I can think of is, maybe java code generated by GUI builder in NetBeans aren't stable or this conflicts with other setting.
Have you ever heard of any issue with above two situation?
Another possible reason I can think of is, maybe java code generated by GUI builder in NetBeans aren't stable or this conflicts with other setting.
Have you ever heard of any issue with above two situation?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It looks like the difference is in the heiwght width alliocated to te appleat - do you specify it directly in the HTML ?