Showing PDF File on Swing Application.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   RamBabu_Maddineni
Posted On:   Wednesday, December 12, 2001 10:59 AM

Hi, I want show a PDF file on swing Application.I want get the acrobat reader to area difined for it on UI. If i open a PDF file using the code below it opens in seperate window. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class FrameDemo { public static void main(String s[]) throws Exception{ JFrame frame = new JFrame("FrameDemo"); frame.getContentPane().add(new TestComponent("Test.pdf")); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); JLabel emptyLabel = new JLabel("&   More>>

Hi,
I want show a PDF file on swing Application.I want get the acrobat reader to area difined for it on UI.
If i open a PDF file using the code below it opens in seperate window.


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class FrameDemo {
public static void main(String s[]) throws Exception{


JFrame frame = new JFrame("FrameDemo");


frame.getContentPane().add(new TestComponent("Test.pdf"));


frame.addWindowListener(new WindowAdapter() {


public void windowClosing(WindowEvent e) {
System.exit(0);
}
});

JLabel emptyLabel = new JLabel("");
emptyLabel.setPreferredSize(new Dimension(500, 500));
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);

frame.pack();
frame.setVisible(true);
}

}


class TestComponent extends VBean {
public TestComponent() {
}


public TestComponent(String url) {
try {


String command = "cmd.exe /c " + "start "+url;
Runtime.getRuntime().exec(command);
}


catch(Exception ee){
ee.printStackTrace();
}


}
}


Please help me.
Thanks,
Ram.

   <<Less
About | Sitemap | Contact