我在Java動態應用程序中有以下JForm
,我需要下載一些我不想在GUI中顯示的文件,我希望程序通過命令行運行。我們可以在DOS模式下啓動Java Jframe程序
我們可以使用相同的形式嗎?或者我們需要爲它創建一個單獨的桌面應用程序?
這裏是代碼..
public class LoginForm extends javax.swing.JFrame
{
\\some other code
\\ main function of form
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
try {
if(args.length > 0)
{
setGuiDisplay(1);
for (String s: args) {
System.out.println(s);
}
}
else
{
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LoginForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
public static void setGuiDisplay(int GuiDisplay) {
LoginForm.GuiDisplay = GuiDisplay;
//Start Downloading
FrmMain frm1= new FrmMain();
frm1.StartDownload();
}
問題很好,但我想知道爲什麼你需要在CUI基於GUI的應用程序?如果你明確我的疑問,我會很高興。 – gprathour
@GPRathour我想下載沒有用戶粘貼的文件,你提到XML文件並下載它。 – javadotnetcoder