Hello boys and girls.
I want insert in a JMEDesktop a JFrame.
I look and run the TestJMEDesktop class. It's ok. But i want insert in a Desktop a JFrame.
In the code of this class there is a sample code to create a JFrame but it's displayed out the JmeDesktop.
It's possible insert in a JmeDesktop this component???
I'have change the code but when i run the class; it stops.
Can you help meeeee???
JFrame frame = new JFrame();
frame.pack();
frame.setVisible( true );
Toolkit.getDefaultToolkit().addAWTEventListener( new AWTEventListener() {
public void eventDispatched( AWTEvent event ) {
logger.info( "CIao" );
}
}, 0xFFFFFFFFFFFFFFl );
JButton button = new JButton( "test" );
button.setMnemonic( 't' );
frame.getContentPane().add( button );
button.addActionListener( new ActionListener() {
public void actionPerformed( ActionEvent e ) {
logger.info( "now" );
}
[color=red] desktopPane.add(frame);[/color]
} );
sbook
April 30, 2010, 12:50pm
3
JMEDesktop is based on a JDesktopPane. I'm fairly sure that you need to use a JInternalFrame in this case…
Poor me. I'm interested use JFrame for insert in my application a PDF file.
You have any council for me???
Thanks for your reply.
sbook
April 30, 2010, 6:16pm
5
The only difference, functionally, between a JInternalFrame and a standard JFrame is the way in which they are displayed since a JFrame still needs the setVisible(true) call. All use within the frame itself should identical
I have a simple code for load a pdf file with standard JFrame, but if i change JFrame with JInternalFrame i don't display anything.
The simple code if i use is:
package pdfpaneltest;
import com.adobe.acrobat.*;
import java.awt.*;
import java.io.*;
import com.adobe.acrobat.*;
import java.awt.*;
import java.io.*;
public class PDFViewer {
public PDFViewer() throws java.lang.Exception {
}
public void viewPDFDocument() {
try {
Frame frame = new Frame("PDF Viewer");
frame.setLayout(new BorderLayout());
Viewer viewer = new Viewer();
frame.add(viewer, BorderLayout.CENTER);
frame.add(new Label("PDF Document in Adobe Acrobat Viewer",
Label.CENTER), BorderLayout.NORTH);
InputStream input = new FileInputStream(new File( "C:/m.pdf"));
viewer.setDocumentInputStream(input);
viewer.setEnableDebug(true);
viewer.setProperty("Default_Page_Layout", "SinglePage");
viewer.setProperty("Default_Zoom_Type", "FitPage");
viewer.setProperty("Default_Magnification", "100");
System.out.println("Page Count: " + viewer.getPageCount());
System.out.println("Current Page: " + viewer.getCurrentPage());
viewer.zoomTo(1.0);
viewer.activate();
frame.setSize(400, 500);
frame.pack();
frame.show();
OutputStream output=new FileOutputStream(new File("C:/output.txt"));
PrintWriter printWriter=new PrintWriter(output);
printWriter.print(viewer.getTextForPage(1));
printWriter.flush();
printWriter.close();
} catch (java.lang.Exception e) {
}
}
public static void main(String[] argv) {
try {
PDFViewer pdfViewer = new PDFViewer();
pdfViewer.viewPDFDocument();
} catch (java.lang.Exception e) {
}
}
}
sbook
May 1, 2010, 6:46pm
7
If you try to display a JInternalFrame via a main method, you won't get anything. It's meant to be a frame inside of a frame. BTW, you're using the AWT components there, not Swing components
What components of the AWT i must to use??
sbook
May 4, 2010, 11:52pm
9
bircastri said:
What components of the AWT i must to use??
You shouldnt need to use any.. JFrame is swing, you want SWING components. (in the javax.swing package)