Click here to Skip to main content
15,895,746 members
Home / Discussions / Java
   

Java

 
QuestionHelp mee,,,,, I'm confused,,,, Pin
VANDAWAA25-Nov-08 15:09
VANDAWAA25-Nov-08 15:09 
QuestionJavascript - href - servlet - java Pin
asifhirani78625-Nov-08 14:51
asifhirani78625-Nov-08 14:51 
Questionjava code for creating a unstructered p2p n/w Pin
venkatesh1111121-Nov-08 22:35
venkatesh1111121-Nov-08 22:35 
QuestionJava to COM Bridge Pin
railay2919-Nov-08 4:58
railay2919-Nov-08 4:58 
AnswerRe: Java to COM Bridge Pin
ramesh_rc24-Nov-08 0:21
ramesh_rc24-Nov-08 0:21 
QuestionError Diplaying TIF Image in Applet Pin
alpeshkhunt17-Nov-08 23:45
alpeshkhunt17-Nov-08 23:45 
AnswerRe: Error Diplaying TIF Image in Applet Pin
toxcct18-Nov-08 1:25
toxcct18-Nov-08 1:25 
QuestionError Diplaying TIFF in Applet through JSP Pin
riteshsv17-Nov-08 23:37
riteshsv17-Nov-08 23:37 
Dear All,

I've been trying to display the Tif image into the WebBrowser with the help of Applet embedded into a JSP through NetBeans IDE.

To achieve this goal, I've created 2 projects "NewApplet" which contains the Applet class and "WebApplication1" which has "Index.JSP" which embeds the Applet.

If i execute Only the Applet, it displays the TIF. But if i execute the JSP, it fires the following error:
"URL Scheme is not "file" http://localhost:8084/WebApplication1/alpesh.tif""

Following is the code written NewApplet.Java:

package display;

import javax.swing.JApplet;
import java.awt.BorderLayout;
import java.awt.image.RenderedImage;
import java.io.IOException;
import javax.swing.JDesktopPane;
import javax.swing.JInternalFrame;
import javax.swing.JScrollPane;
import com.sun.media.jai.codec.ImageCodec;
import com.sun.media.jai.codec.ImageDecoder;
import com.sun.media.jai.codec.TIFFDecodeParam;
import com.sun.media.jai.widget.DisplayJAI;
import java.io.File;
import java.io.FileInputStream;
import java.net.URI;
import javax.swing.JOptionPane;

public class NewApplet extends JApplet {

@Override
public void init() {
URI FileName = URI.create(getCodeBase().toString().concat(getParameter("imageSource")));
try
{
File f = new File(FileName);

FileInputStream stream = new FileInputStream(f);

// Create a decoder using that stream.
TIFFDecodeParam tiff = new TIFFDecodeParam();
ImageDecoder dec = ImageCodec.createImageDecoder("tiff", stream, tiff);

// Get the number of pages.
int pages;
pages = dec.getNumPages();

// Set the application title.
setTitle(pages+" pages in "+filename);

// Create a JDesktop to hold the pages in internal frames.

JDesktopPane desktop = new JDesktopPane();
//getContentPane().add(desktop,BorderLayout.CENTER);
desktop.setSize(400,400);
add(desktop,BorderLayout.CENTER);
// Open all images in the TIFF into the desktop pane.
for(int i=0;i<pages;i++)>
{
// Get the image.
RenderedImage ri = dec.decodeAsRenderedImage(i);
// Create and set the user interface of an internal frame.
JInternalFrame jif = new JInternalFrame("Page "+i,true,true,true,true);
jif.getContentPane().add(new JScrollPane(new DisplayJAI(ri)));
jif.setSize(400,400);
jif.pack();
jif.setVisible(true);

// Add the internal frame to the JDesktop.
desktop.add(jif);
}
// Set the application closing behaviour, frame size, and show it.
//setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400,400);
setVisible(true);
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e.getMessage(), "alert", JOptionPane.ERROR_MESSAGE);
}
}
}



Following is the code written Index.JSP:

<applet code="display.NewApplet" archive="NewApplet.jar" width="350" height="200">
<param name="imageSource" value="alpesh.tif" />
</applet>



Any Guesses?

I've added the "dist/NewApplet.jar" in WebApplication1 through the option of "Properties-&gt;Build-&gt;Packaging" in NetBeans.

Please help!

Ritesh
QuestionCreating Vectors Pin
sudany_zool14-Nov-08 23:01
sudany_zool14-Nov-08 23:01 
AnswerRe: Creating Vectors Pin
toxcct16-Nov-08 21:42
toxcct16-Nov-08 21:42 
QuestionHow do i go about doing this Pin
nothingfights13-Nov-08 8:20
nothingfights13-Nov-08 8:20 
AnswerRe: How do i go about doing this Pin
toxcct13-Nov-08 21:46
toxcct13-Nov-08 21:46 
AnswerRe: How do i go about doing this Pin
Naruki3-Dec-08 17:15
Naruki3-Dec-08 17:15 
Question[Message Deleted] Pin
Saturday3AM12-Nov-08 9:47
Saturday3AM12-Nov-08 9:47 
QuestionPolygon Union Pin
bangbangbogi9-Nov-08 19:24
bangbangbogi9-Nov-08 19:24 
Question[Message Deleted] Pin
trump1016-Nov-08 11:47
trump1016-Nov-08 11:47 
AnswerRe: Help with java programming Pin
toxcct6-Nov-08 21:47
toxcct6-Nov-08 21:47 
GeneralRe: Help with java programming Pin
TannerB7-Nov-08 8:40
TannerB7-Nov-08 8:40 
GeneralRe: Help with java programming Pin
toxcct8-Nov-08 0:03
toxcct8-Nov-08 0:03 
GeneralRe: Help with java programming Pin
TannerB8-Nov-08 7:46
TannerB8-Nov-08 7:46 
GeneralRe: Help with java programming Pin
HosamAly19-Nov-08 6:23
HosamAly19-Nov-08 6:23 
QuestionNeed a tad of help [modified] Pin
TannerB3-Nov-08 8:43
TannerB3-Nov-08 8:43 
Questionexe file Pin
sunil_jvfrm1-Nov-08 1:55
sunil_jvfrm1-Nov-08 1:55 
AnswerRe: exe file Pin
toxcct1-Nov-08 3:52
toxcct1-Nov-08 3:52 
AnswerRe: exe file Pin
jrsk1-Nov-08 23:20
jrsk1-Nov-08 23:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.