olhha o fiz esse programa , ele ta compilando mas naum ta executando…tipo…ele nao mostra a janela…se alguem pode me ajudar ficarei muito feliz…eu nao sei aonde eu estou errando…esse programa e um visualizador de imagens …por favor me ajudem…
esse e o codigo:
import java.io.;
import java.awt.;
import java.awt.event.;
import javax.swing.;
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 || fileName.getName().equals(""))
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!!!