Hello Friends
I want to open a Save as File Dialog Window by clicking on a button.
5 21201
Hello Friends
I want to open a Save as File Dialog Window by clicking on a button.
-
import java.awt.*;
-
import java.awt.event.*;
-
import java.io.*;
-
-
public class RunEditor extends java.applet.Applet{
-
public void init(){
-
Editor editor = new Editor();
-
editor.show();
-
}
-
}
-
-
class Editor extends Frame implements ActionListener {
-
TextArea textArea = new TextArea();
-
-
Editor() {
-
super("Editor");
-
setLayout( new BorderLayout() );
-
// Use a TextArea object as the editor tool
-
add("Center", textArea);
-
// Create a menubar with basic commands
-
Menu menu = new Menu ("File");
-
menu.add ( makeMenuItem ("Load") );
-
menu.add ( makeMenuItem ("Save") );
-
menu.add ( makeMenuItem ("Quit") );
-
MenuBar menuBar = new MenuBar();
-
menuBar.add ( menu );
-
setMenuBar( menuBar );
-
pack();
-
}
-
// Item buttons send actions here.
-
public void actionPerformed( ActionEvent e ) {
-
String command = e.getActionCommand();
-
if ( command.equals("Quit") )
-
dispose();
-
else if ( command.equals("Load") )
-
loadFile();
-
else if ( command.equals("Save") )
-
saveFile();
-
}
-
// Use the FileDialog class to load files
-
private void loadFile () {
-
FileDialog fd = new
-
FileDialog(this, "Load File", FileDialog.LOAD );
-
fd.show();
-
String file = fd.getFile();
-
if ( file == null ) // Cancel
-
return;
-
try {
-
FileInputStream fis = new
-
FileInputStream ( fd.getFile() );
-
byte [] data = new byte [ fis.available() ];
-
fis.read( data );
-
textArea.setText( new String( data ) );
-
} catch ( IOException e ) {
-
textArea.setText( "Could not load file..." );
-
}
-
}
-
// Use the FileDialog class to save files
-
private void saveFile() {
-
FileDialog fd = new
-
FileDialog( this, "Save File", FileDialog.SAVE );
-
fd.show();
-
// Save file data...
-
}
-
-
private MenuItem makeMenuItem( String name ) {
-
MenuItem m = new MenuItem( name );
-
m.addActionListener( this );
-
return m;
-
}
-
-
public static void main(String[] s) {
-
new Editor().show();
-
}
-
}
-
Edited by iam_clint -- Reason ("This is Java not javascript")
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class RunEditor extends java.applet.Applet{
public void init(){
Editor editor = new Editor();
editor.show();
}
}
class Editor extends Frame implements ActionListener {
TextArea textArea = new TextArea();
Editor() {
super("Editor");
setLayout( new BorderLayout() );
// Use a TextArea object as the editor tool
add("Center", textArea);
// Create a menubar with basic commands
Menu menu = new Menu ("File");
menu.add ( makeMenuItem ("Load") );
menu.add ( makeMenuItem ("Save") );
menu.add ( makeMenuItem ("Quit") );
MenuBar menuBar = new MenuBar();
menuBar.add ( menu );
setMenuBar( menuBar );
pack();
}
// Item buttons send actions here.
public void actionPerformed( ActionEvent e ) {
String command = e.getActionCommand();
if ( command.equals("Quit") )
dispose();
else if ( command.equals("Load") )
loadFile();
else if ( command.equals("Save") )
saveFile();
}
// Use the FileDialog class to load files
private void loadFile () {
FileDialog fd = new
FileDialog(this, "Load File", FileDialog.LOAD );
fd.show();
String file = fd.getFile();
if ( file == null ) // Cancel
return;
try {
FileInputStream fis = new
FileInputStream ( fd.getFile() );
byte [] data = new byte [ fis.available() ];
fis.read( data );
textArea.setText( new String( data ) );
} catch ( IOException e ) {
textArea.setText( "Could not load file..." );
}
}
// Use the FileDialog class to save files
private void saveFile() {
FileDialog fd = new
FileDialog( this, "Save File", FileDialog.SAVE );
fd.show();
// Save file data...
}
private MenuItem makeMenuItem( String name ) {
MenuItem m = new MenuItem( name );
m.addActionListener( this );
return m;
}
public static void main(String[] s) {
new Editor().show();
}
}
Unfortunately the solution given above is a java solution not a javascript solution
@OP: Here is a link which should give you what you want http://4umi.com/web/javascript/filewrite.htm
Hello Friends
I want to open a Save as File Dialog Window by clicking on a button.
// Show save dialog; this method does not return until the dialog is closed
fc.showSaveDialog(frame);
selFile = fc.getSelectedFile();
Please use code tags when posting code
[code=java] private void jmiOpenActionPerformed(java.awt.event.ActionEvent evt) {
The solution you have provided is a Java solution, not JScript/ActiveX.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bob Murdoch |
last post by:
I've got an intranet application that presents a list of files in sort of a
'central repository' web page. Each file is an href in the form <a
href=file://server/share/path/filename.ext>.
When...
|
by: SK |
last post by:
I am calling an exe thru' href, but when it executes,
I get the message if I want to open the file(exe file).
Is there any way I can suppress this from appearing
and open the program?
Thank...
|
by: Clinton Goff |
last post by:
I am attempting to write a javascript app that will open a second browser
window, load a url, such as www.google.com (foreign url) and perform a
<File-Save As> function on that window. I am able...
|
by: REB |
last post by:
Can someone help me with adding some javascript functionality to a button?
What would the proper syntax for for (please help with the javascript I am
rusty) for doing this:
...
|
by: Ryan Moore |
last post by:
I'm trying to make a page that, when opened, displays a file save dialog,
then closes itself (essentially just leaving the file save dialog). Is this
possible? I've tried this:
...
|
by: Richard |
last post by:
Hi
I'm new to ASP/Web programming so any help would be appreciated...
Situation: On my web page I would like to present a link {or button} that would allow the user to download a large file. ...
|
by: Satya |
last post by:
I am trying to display a PDF file (which I am being passed from a web
service as a binary stream) in a browser, but I am being prompted to
save the file instead. I don't want the user to be...
|
by: Neil Rossi |
last post by:
I have an issue with a particular ASP page on two web servers. Let's
call these servers Dev1 and Beta1. Both Servers are running IIS 5,
Windows 2000 SP4 with "almost" all of the latest patches.
...
|
by: aarthiraaj |
last post by:
In my user screen I have view link, if I click this link it will go to servlet and open one word document. It is opening properly, but while opening the attachment it generate one dialog box like...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |