We have a problem similar to this
Clean boot doesn't help and the unchecking of services doesn't help ether.
We have a Java applet that's working correctly on xp but isn't working correctly on win 7.
The applet runs and the browser asks you to accept the certifiket but the buttons are hidden and appears onley on mouse rollover.
It doesen't work in browser safe mode but it works in windows safe mode.
So its functioning but it simply isnt shown correctly.
Here is the Java code:

import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.awt.image.RescaleOp;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.StringTokenizer;
import javax.imageio.ImageIO;
import javax.imageio.ImageWriteParam;
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageOutputStream;
import javax.imageio.stream.MemoryCacheImageOutputStream;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class AppletEE extends JApplet {
	private JTextField tf = new JTextField("", 15);
	private JTextArea ta = new JTextArea( "",8,40);
	private JButton button1 = new JButton("Preview");
	private JButton button2 = new JButton("Generate Image");
	Font font1;
	Font font2;
	BufferedImage bgImage;
	BufferedImage fgImage;
	BufferedImage overlayedImage;
	final int xc=170;
	public void init() {
		this.setSize(450, 550);
		Container cp = getContentPane();
		font1= new Font("Arial", Font.PLAIN,  50);
		font2= new Font("Arial", Font.PLAIN,  30);
	    cp.setLayout(new FlowLayout());
	    cp.add(tf);
	    cp.add(ta);
	    cp.add(button1);
	    cp.add(button2);
	    button1.addActionListener(new ActionListener() {
		    public void actionPerformed(ActionEvent e) {
				try {
			        // Read from a URL
			        URL url = new URL("http://192.168.1.2/bg.png");
			        bgImage = imageToBufferedImage(ImageIO.read(url));
			    } catch (IOException e1) {
			    	System.out.println("url error");
			    }
			    overlayedImage=bgImage;	
		    	generate();	
		    	repaint();
		    }
		});
	    button2.addActionListener(new ActionListener() {
		    public void actionPerformed(ActionEvent e) {
				try {
			        // Read from a URL
			        URL url = new URL("http://192.168.1.2/bg.png");
			        bgImage = imageToBufferedImage(ImageIO.read(url));
			    } catch (IOException e1) {
			    	System.out.println("url error");
			    }
			    overlayedImage=bgImage;
		    	generate();
		    	save();
		        tf.setText("");
		        ta.setText("");
		    }
		});
	}
	public void paint(Graphics g){
		g.drawImage(overlayedImage,0,200,450,337,this);

	}
	public void generate(){
    	
    	if(tf.getText().length()==0){
    		tf.setText("  ");
    	}
    	FontMetrics fm = this.getFontMetrics(font1); 
		BufferedImage imageA = new BufferedImage(fm.stringWidth(tf.getText()), (int) (fm.getHeight()*1.5), BufferedImage.OPAQUE);
		Graphics2D g = imageA.createGraphics();
		g.setFont(font1);
		g.drawString(tf.getText(), 0, fm.getHeight());
		g.dispose();
		RescaleOp op=new RescaleOp(-1.0f, 255f,null);
		imageA=op.filter(imageA, null);
		int lines=ta.getLineCount();
        if(lines>8){
        	lines=8;
        }
		int z=(int) ((bgImage.getHeight()-(font1.getSize()*1.5+font2.getSize()*1.5*lines))/2-font2.getSize());
        overlayedImage=overlayImages(bgImage, imageA, ((bgImage.getWidth())/2-(imageA.getWidth())/2), z);		       
        int enter=0;
        char[] temp0=new char[ta.getText().length()];
        ta.getText().getChars(0, ta.getText().length(), temp0, 0);
        if(ta.getText().length()>4){	     	
        	for(int t=0; t<ta.getText().length()-1; t++){
        		if(temp0[t]=='\n'&&temp0[t+1]=='\n'){
        			enter++;
        		}
        	}
        	if(enter!=0){
        		temp0=new char[ta.getText().length()+enter];
        		ta.getText().getChars(0, ta.getText().length(), temp0, 0);
        		for(int t=0; t<ta.getText().length()-1; t++){
            		if(temp0[t]=='\n'&&temp0[t+1]=='\n'){
            			for(int u=temp0.length-1; u>t; u--){
            				temp0[u]=temp0[u-1];
            			}
            			temp0[t+1]=' ';
            		}
            	}
        	}
        } 
        String s[] = new String[10];
        StringTokenizer st=new StringTokenizer(new String(temp0),"\n");
        int r=0;
        boolean done=false;
        while(st.hasMoreTokens()&&done==false){
        	s[r]=st.nextToken();
        	while(s[r].length()>47&&done==false){
        		char[] temp1=new char[s[r].length()-47];
        		char[] temp2=new char[47];
        		s[r].getChars(47, s[r].length(), temp1, 0);
        		s[r].getChars(0, 47, temp2, 0);
        		s[r]=new String(temp2);    		
        		s[r+1]=new String(temp1);	
        		r++;
        		if(r>=8){
        			done=true;
        		}
        	}
        	r++;
        	System.out.print(r);
        	if(r>=8){
    			done=true;
    		}
        }    
        fm = this.getFontMetrics(font2); 
        BufferedImage textImage;
        for(int v=0; v<r; v++){      		
        	textImage = new BufferedImage(fm.stringWidth(ta.getText()), (int) (fm.getHeight()*1.5), BufferedImage.OPAQUE);
        	g = textImage.createGraphics();
        	g.setFont(font2);
        	g.drawString(s[v], 0, fm.getHeight());
        	g.dispose();
        	z=(int) ((bgImage.getHeight()-(font1.getSize()*1.5+font2.getSize()*1.5*lines))/2+font1.getSize()*1.5+font2.getSize()*1.5*v);
			textImage=op.filter(textImage, null);
			overlayedImage=overlayImages(overlayedImage, textImage, xc, z);
        }
	}
	public static BufferedImage imageToBufferedImage(Image im) {
		BufferedImage bi = new BufferedImage(im.getWidth(null),im.getHeight(null),BufferedImage.TYPE_INT_RGB);
		Graphics bg = bi.getGraphics();
		bg.drawImage(im, 0, 0, null);
		bg.dispose();
		return bi;
	}
	public void save(){
		if(overlayedImage!=null){
			int v=0;
			boolean found=false;
			while(found==false){
				try{
					URL url = new URL("http://192.168.1.2/text" + v + ".png");
			        ImageIO.read(url);
					//ImageIO.read(new File(saveFilePath + "text" + v + ".png"));
					v++;
				}catch(Exception e){	
					found=true;
				}
			}
			String s=writeImage(overlayedImage, "http://192.168.1.2/text" + v + ".png", "png");
			ta.setText(s);
			overlayedImage.flush();
		}else
			System.out.print("Problem with overlay...");
	}
	public static BufferedImage overlayImages(BufferedImage bgImage, BufferedImage fgImage, int mr, int nr ){//lägger en bild på en annan
		if(fgImage.getHeight()>bgImage.getHeight()||fgImage.getWidth()>fgImage.getWidth()){
			JOptionPane.showMessageDialog(null, "Use smaller text size");
			return null;
		}
		Graphics2D g=bgImage.createGraphics();
		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g.drawImage(bgImage, 0, 0, null);
		g.drawImage(fgImage, mr, nr, null);
		g.dispose();
		return bgImage;
	}
	public static BufferedImage readImage(String filelocation){
		BufferedImage img=null;
		try{
			img=ImageIO.read(new File(filelocation));
		}catch(IOException e){
			e.printStackTrace();
		}
		return img;
	}
	public static String writeImage(BufferedImage img, String filelocation, String extension){
		DataUpload du = new DataUpload();
		boolean bo = du.UploadImage(filelocation, img);
		int rc = du.GetResponseCode();
	    String feedback = du.GetServerFeedback();
	    return (""+bo+rc+feedback);  
	}  
} 

class DataUpload{
	  /** The field name as expected by the PHP script, equivalent to the name in the tag input type="file"
	   * in an HTML upload form.
	   */
	  private static final String FIELD_NAME = "image";
	  /** PHP script name. */
	  // I hard-code it here, I suppose there is no need for several scripts per applet...
	  private static final String SCRIPT_NAME = "Upload.php";
	  /** URL path to the PHP script. */
	  private static final String BASE_URL = "http://192.168.1.2/EE";
	  private String boundary;
	  private String uploadURL;
	  /** The connection to the server. */
	  private HttpURLConnection connection;
	  /** The output stream to write the binary data. */
	  private DataOutputStream output;

	  DataUpload(){
	    // Mime boundary of the various parts of the message.
	    boundary = "-----DataUploadClass-----PhiLhoSoft-----" + System.currentTimeMillis();
	    // We can add a optional parameters, eg. a string given by the user, parameters used, etc.
	    uploadURL = BASE_URL + "/" + SCRIPT_NAME;// + "?optionalParam=value&foo=bar";
	  }

	  /** Pushes image to server. */
	  boolean UploadImage(String fileName, BufferedImage image)
	  {
	    String imageType = null, imageMimeType = null;
	    boolean bUseOtherMethod = false;
	    if (fileName.endsWith("png"))
	    {
	      imageType = "png";
	      imageMimeType = "image/png";
	    }
	    else if (fileName.endsWith("jpg"))
	    {
	      imageType = "jpg";
	      imageMimeType = "image/jpeg";
	    }
	    else if (fileName.endsWith("jpeg"))
	    {
	      imageType = "jpeg";
	      imageMimeType = "image/jpeg";
	      bUseOtherMethod = true;
	    }
	    else
	    {
	      return false; // Unsupported image format
	    }

	    try
	    {
	      boolean isOK = StartPOSTRequest(fileName, imageMimeType);
	      if (!isOK)
	        return false;

	      // Output the encoded image data
	      if (!bUseOtherMethod)
	      {
	        // Uses the default method
	        ImageIO.write(image, imageType, output);
	      }
	      else
	      {
	        // Alternative for better Jpeg quality control
	        ByteArrayOutputStream baos = new ByteArrayOutputStream();

	        java.util.Iterator iter = ImageIO.getImageWritersByFormatName(imageType);
	        if (iter.hasNext())
	        {
	          ImageWriter writer = (ImageWriter) iter.next();
	          ImageWriteParam iwp = writer.getDefaultWriteParam();
	          iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
	          iwp.setCompressionQuality(1.0f);

	          ImageOutputStream ios = new MemoryCacheImageOutputStream(baos);
	          writer.setOutput(ios);
	          writer.write(image);
	          byte[] b = baos.toByteArray();
	          output.write(b, 0, b.length);
	        }
	      }

	      // And actually do the send (flush output and close it)
	      EndPOSTRequest();
	    }
	    catch (Exception e)
	    {
	      e.printStackTrace();
	      return false; // Problem
	    }
	    finally
	    {
	      if (output != null)
	      {
	        try { output.close(); } catch (IOException ioe) {}
	      }
	    }

	    return true;  // OK
	  }

	  /** Reads output from server. */
	  String GetServerFeedback()
	  {
	    if (connection == null)
	    {
	      // ERROR: Can't get server feedback without first uploading data!
	      return null;
	    }
	    BufferedReader input = null;
	    StringBuffer answer = new StringBuffer();
	    try
	    {
	      input = new BufferedReader(new InputStreamReader(connection.getInputStream()));
	      String answerLine = null;
	      do
	      {
	        answerLine = input.readLine();
	        if (answerLine != null)
	        {
	          answer.append(answerLine + "\n");
	        }
	      } while (answerLine != null);
	    }
	    catch (Exception e)
	    {
	      // Can display some feedback to user there, or just ignore the issue
	      e.printStackTrace();
	      return null;  // Problem
	    }
	    finally
	    {
	      if (input != null)
	      {
	        try { input.close(); } catch (IOException ioe) {}
	      }
	    }

	    return answer.toString();
	  }

	  int GetResponseCode()
	  {
	    int responseCode = -1;
	    if (connection == null)
	    {
	      // ERROR: Can't get server response without first uploading data!
	      return -1;
	    }
	    // Note that 200 means OK
	    try
	    {
	      responseCode = connection.getResponseCode();
	    }
	    catch (IOException ioe)
	    {
	    }
	    return responseCode;
	  }

	  /*-- Private section --*/

	  private boolean StartPOSTRequest(String fileName, String dataMimeType)
	  {
	    try
	    {
	      URL url = new URL(uploadURL); // throws MalformedURLException
	      connection = (HttpURLConnection) url.openConnection();  // throws IOException
	      // connection is probably of HttpURLConnection  type now

	      connection.setDoOutput(true); // We output stuff
	      connection.setRequestMethod("POST");  // With POST method
	      connection.setDoInput(true);  // We want feedback!
	      connection.setUseCaches(false); // No cache, it is (supposed to be) a new image each time, even if URL is always the same

	      // Post multipart data
	      // Set request headers
	      // Might put something like "Content-Length: 8266"
	      connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
	      // throws IllegalStateException, NullPointerException

	      // Open a stream which can write to the URL
	      output = new DataOutputStream(connection.getOutputStream());
	      // the get throws IOException, UnknownServiceException

	      // Write content to the server, begin with the tag that says a content element is coming
	      output.writeBytes("--" + boundary + "\r\n"); // throws IOException

	      // Describe the content:
	      // filename isn't really important here, it is probably ignored by the upload script, or can be set to user name if logged in
	      output.writeBytes("Content-Disposition: form-data; name=\"" + FIELD_NAME +
	          "\"; filename=\"" + fileName + "\"\r\n");
	      // Mime type of the data, like image/jpeg or image/png
	      // Likely to be ignored by the PHP script (which can't trust such external info) but (might be) mandatory and nice to indicate anyway
	      output.writeBytes("Content-Type: " + dataMimeType + "\r\n");
	      // By default it is Base64 encoding (that's what most browsers use), but here we don't use this,
	      // for simplicity sake and because it is less data to transmit. As long as destination server understands it...
	      // See http://www.freesoft.org/CIE/RFC/1521/5.htm for details
	      output.writeBytes("Content-Transfer-Encoding: binary\r\n\r\n");
	    }
	    catch (Exception e) // Indistinctly catch all kinds of exceptions this code can throw at us
	    {
	      // Can display some feedback to user there, or just ignore the issue
	      e.printStackTrace();
	      return false; // Problem
	    }

	    return true;
	  }
	  private boolean EndPOSTRequest()
	  {
	    try
	    {
	      // Close the multipart form request
	      output.writeBytes("\r\n--" + boundary + "--\r\n\r\n");

	      // And actually do the send (flush output and close it)
	      output.flush(); // throws IOException
	    }
	    catch (Exception e) // Indistinctly catch all kinds of exceptions this code can throw at us
	    {
	      // Can display some feedback to user there, or just ignore the issue
	      e.printStackTrace();
	      return false; // Problem
	    }

	    return true;
	  }
	}

As my school project I, with help, have created a remotely controlled real-time closed circuit TV system for the school so that teachers can post messages on TVs, sort of like an information board system. One way to leave a message is through a website with a java applet.

The applet we made works fine on windows xp, but works curiously on windows 7. It runs in the browser and asks the client to accept the certificate, but when the user clicks on “run” the applet doesn’t come up. It’s there, the buttons come up if you move the mouse pointer over them and the text becomes visible if you press ctrl+a. It works too, all the functions work properly, if you can navigate. It works in windows 7 safe mode though. I’ve tried turning of services, making a “clean boot”, running the browser in safe mode and changing the html tags (applet, object, embed) and nothing’s working. It’s not the firewall or antivirus. It’s just something with windows 7. I need to fix it- half the teachers have windows 7.

I’ve managed to narrow the problem down. The applet apparently works fine in windows 7 with the colors turned down to 16 bits. Doesn’t work in 32 bits mode on windows 7, but works in both modes on xp. Now, it’s not the graphic card – I’ve tested with others OSs on same computers. Firefox I can set to start in XPsp3 compatibility mode in properties and it works even in 32bit color mode on windows 7. But Internet Explorer can’t be set to start in the compatibility mode because “it’s part of this version of windows”… Due to this undesirable problem I will have to configure computers of the entire staff. I’ve even tried tweaking with the graphic card properties hoping there’d be a box to uncheck somewhere. Without positive outcome. Switching all computers to 16-bit mode seems pretty intrusive as it disables Windows Live Thumbnails and Aero Peak. I’m looking for a way to make it work for the teachers without them having to edit advanced settings or decreasing functionality of their computers. If there is an advanced setting to be changed, the schools computer service will do it.

Does anyone have any suggestions?

What does your HTML look like? Are you using the Applet tag (which you shouldn't), or the Object tag (which is better, but still not right) or JNLP?

See this.

What does your HTML look like? Are you using the Applet tag (which you shouldn't), or the Object tag (which is better, but still not right) or JNLP?

See this.

Thanks

After trying everything the only one that worked was jnlp

can you print out your Java version, because from Java 1.6_025 is there some restiction

can you print out your Java version, because from Java 1.6_025 is there some restiction

I have version 1.7.0-b147

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.