Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j/tools
In directory sc8-pr-cvs1:/tmp/cvs-serv20030/src/org/tn5250j/tools
Added Files:
SendScreenImageToFile.java
Log Message:
Fixed Connect.java, Fixed Gui5250.java, Added SendScreenToImage-Feature.
--- NEW FILE: SendScreenImageToFile.java ---
/**
* Title: tn5250J
* Copyright: Copyright (c) 2001
* Company:
* @author Kenneth J. Pouncey
* @version 0.5
*
* Description:
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
*
*/
package org.tn5250j.tools;
import java.awt.*;
import java.io.*;
import javax.swing.*;
import org.tn5250j.Session;
import org.tn5250j.tools.encoder.EncodeComponent;
import org.tn5250j.tools.filters.XTFRFileFilter;
public class SendScreenImageToFile {
Session session;
public SendScreenImageToFile(Session ses) {
session = ses;
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
void jbInit() throws Exception {
getPCFile();
}
/**
* Get the local file from a file chooser
*/
private void getPCFile() {
String workingDir = System.getProperty("user.dir");
MyFileChooser pcFileChooser = new MyFileChooser(workingDir);
XTFRFileFilter pngFilter = new XTFRFileFilter("png", "Portable Network Graphics");
pcFileChooser.setFileFilter(pngFilter);
int ret = pcFileChooser.showSaveDialog(new JFrame());
// check to see if something was actually chosen
if (ret == JFileChooser.APPROVE_OPTION) {
File file;
try {
if (!pcFileChooser.getSelectedFile().getCanonicalPath().endsWith(".png"))
file = new File(pcFileChooser.getSelectedFile().getCanonicalPath()
+ ".png");
else
file = pcFileChooser.getSelectedFile();
EncodeComponent.encode(EncodeComponent.PNG,session, file);
}
catch (Exception e) {
System.out.println("Error generating PNG exception caught: " + e);
}
}
}
/**
* This is to fix
* Bug Id - 4416982
* Synopsis JFileChooser does not use its resources to size itself initially
*/
class MyFileChooser extends JFileChooser {
MyFileChooser(String dir) {
super(dir);
}
public Dimension getPreferredSize() {
return getLayout().preferredLayoutSize(this);
}
}
}
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.