How to save Image into a package by JButton save?
Good Evening/Morning/ or just Late Night
I have a question I'm trying to load an image into my JLabel and when it's loaded I want to save it. Can you please help me or give me some advices how to do it?
So far I have this:
Code :
JButton OpenIcon = new JButton("Open New map");
OpenIcon.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
JFileChooser chooser = new JFileChooser();
chooser.addChoosableFileFilter(new ImageFileFilter());
int returnVal = chooser.showOpenDialog(null);
if(returnVal ==JFileChooser.APPROVE_OPTION){
File file =chooser.getSelectedFile();
Fpath = file.getPath();
ImageIcon Sicon = new ImageIcon(Fpath);
pic.setIcon(Sicon);
pic.repaint();
}
}
});
For browsing the Ion into my Jlabel, now I want to save it can somebody pls help me?
Re: How to save Image into a package by JButton save?
Back with more code and more questions:
Code :
JButton Save = new JButton("Save New Map");
Save.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFileChooser chooserS = new JFileChooser();
int returnVal = chooserS.showSaveDialog(null);
if(returnVal == JFileChooser.APPROVE_OPTION){
File filr =chooserS.getSelectedFile();
log.append("Saving:" + filr.getName() + "." + "\n");
}else{
log.append("Save command cancelled by user");
}
log.setCaretPosition(log.getDocument().getLength());
}
});
1st question --- Why does sun use JTextArea for log? I dont get it.
2nd question --- log.append("Saving:" + filr.getName() + "." + "\n"); why is here the \n ?? I can't select the extension like this.
So how can I select the extension????