the ftp credentials in the code here work and files are uploaded to http://www.scottymedia.com/apptest
the library I am using is org.apache.commons.net.ftp (http://commons.apache.org/downloads/download_fileupload.cgi)
the uploading is done in uploadPhotos() in the view -- and I am using MVC
smapplication.java
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.UIManager;
public class smapplication extends JFrame{
smview view;
smapplication( ){
super( "test app" );
//Make sure we have nice window decorations.
JFrame.setDefaultLookAndFeelDecorated( true );
try {
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" );
//"javax.swing.plaf.metal.MetalLookAndFeel" );
} catch ( Exception e ) {
System.err.print( "Warning! could not set the Look and Feel. " );
System.err.println( "Using the default." );
}
this.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
//Create and set up the content pane.
view = new smview();
this.setJMenuBar(view.buildMenuBar());
view.setOpaque( true ); //content panes must be opaque
this.setContentPane( view );
//Display the window.
// By default, frame objects do not have an initial size, and
// are not visible.
// You, the programmer, must tell the frame its initial size.
this.pack();
// set the frame's size before centering
this.setSize( 600, 400 );
// center the frame on the screen
Dimension frameSize = this.getSize();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation( Math.max(0,(screenSize.width - frameSize.width)/2),
Math.max(0,(screenSize.height - frameSize.height)/2));
}
public static void main( String[ ] args ){
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
new smapplication().setVisible( true );
}
});
}
}
smmodel.java
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Observable;
public class smmodel extends Observable {
// Version format is as follows
// First number - Feature Added
// Second number - Problem fixed
// Third Number - Minor Tweak
private static final String VERSION = "1.0.0";
int position;
int lock;
private int currentphoto;
private String procphoto;
private String pgalleryname;
private int totalphotos;
private int uploaded;
private int waiting;
//public panels panel;
smmodel(){
position = 0; // on the welcome page
lock = 0;
currentphoto = 0;
procphoto = "<< no file currently >>";
totalphotos = 0;
uploaded = 0;
waiting = 0;
pgalleryname = "";
//panel = new panels();
}
//checks for connection to the internet through dummy request
public boolean isInternetReachable(){
try {
//make a URL to a known source
URL url = new URL("http://www.google.com");
//open a connection to that source
HttpURLConnection urlConnect = (HttpURLConnection)url.openConnection();
//trying to retrieve data from the source. If there
//is no connection, this line will fail
Object objData = urlConnect.getContent();
}catch (Exception e) {
// TODO Auto-generated catch block
//e.printStackTrace();
return false;
}
return true; // internet is good
}
public void setUploaded(){
this.uploaded++; // increase by one
this.updateObservers();
}
public int getUploaded(){
return this.uploaded;
}
public void setWaiting(int i){
this.waiting = i;
}
public int getWaiting(){
return this.waiting;
}
public void setGalleryName(String gallery){
this.pgalleryname = gallery;
this.updateObservers();
}
public String getGalleryName(){
return this.pgalleryname;
}
public void setTotal(int total){
this.totalphotos = total;
this.updateObservers();
}
public int getTotal(){
return this.totalphotos;
}
public void setLock(){
lock = 1;
}
public int getLock(){
return lock;
}
public void removeLock(){
lock = 0;
}
public int getPosition(){
return position;
}
public String getProgramVersion(){
return VERSION;
}
public void back(){
position--;
this.updateObservers();
}
public void next(){
position++;
this.updateObservers();
}
public void setCurrentPhoto(int photo){
this.currentphoto = photo;
this.updateObservers();
}
public int getCurrentPhoto(){
return this.currentphoto;
}
public void setProcPhoto(String photo){
this.procphoto = photo;
this.updateObservers();
}
public String getProcessedPhoto(){
return this.procphoto;
}
private void updateObservers(){
this.setChanged();
this.notifyObservers();
}
}
doesn't all fix in one....so....smview.java is in the file attached called smview.txt
I would be SOO greatful if somebody could help me out
Attached File(s)
-
smview.txt (27.51K)
Number of downloads: 178
This post has been edited by scottyadam: 16 December 2009 - 11:03 PM

New Topic/Question
Reply



MultiQuote




|