eu fiz esse programinha … lja me responderam…mas mesmo assim continua dando errado…ele ta copilando mas a janela que ele tinha q aparecer nao ta aparecendo…me ajudem
esse e o codigo:
import <a href="http://java.io">java.io</a>.<em>;
import java.awt.</em>;
import java.awt.event.<em>;
import javax.swing.</em>;
public class Janela extends JFrame {
private JLabel label;
private JButton openButton;
private ObjectInputStream input;
public Janela()
{
super (“Visualizador de Imagens”);
label = new JLabel ();
getContentPane().add(
label,BorderLayout.CENTER);
//openButton = label.getDoTask1Button();
openButton.setText(“Abrir Arquivo”);
openButton.addActionListener(
new ActionListener() {
public void actionPerformed (ActionEvent event)
{
openFile();
}
}
);
addWindowListener (
new WindowAdapter() {
public void windowClosing (WindowEvent event)
{
if(input!=null)
closeFile();
System.exit(0);
}
}
);
pack();
//setSize(500,600);
setVisible(true);
show();
}
private void openFile()
{
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(
JFileChooser.FILES_ONLY);
int result = fileChooser.showOpenDialog(this);
if (result == JFileChooser.CANCEL_OPTION)
return;
File fileName = fileChooser.getSelectedFile();
if(fileName == null || .equals(""))fileName.getName()
JOptionPane.showMessageDialog(this,“Nome de Arquivo Invalido”,“Arquivo Invalido”,JOptionPane.ERROR_MESSAGE);
else{
try{
input = new ObjectInputStream( new FileInputStream(fileName));
openButton.setEnabled(false);
}
catch (IOException ioException) {
JOptionPane.showMessageDialog(this,“Erro ao Abrir o Arquivo”,“Erro”,JOptionPane.ERROR_MESSAGE);
}
}
}
private void closeFile()
{
try{
input.close();
System.exit(0);
}
catch(IOException ioException) {
JOptionPane.showMessageDialog(this,“Error closing file”,“Error”,JOptionPane.ERROR_MESSAGE);
System.exit(1);
}
}
public static void main (String args[])
{
Janela application = new Janela();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
new Janela();
}
}
obrigado!!! Smile