hlucas
Desculpe consegui executar o seu código mas não consegui usa-lo no meu JFrame, talvez com o código`em mãos possa ser melhor para analisar.
package gestaoarquivos;
import java.io.;
import javax.swing.;
/**
*
public class JFGestaoA extends javax.swing.JFrame {
JFileChooser selecionado = new JFileChooser();
File arquivo;
byte[] bytesImg;
GestaoA editor = new GestaoA();
/**
* Creates new form JFGestaoA
*/
public JFGestaoA() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jSplitPane1 = new javax.swing.JSplitPane();
btnAbrirArquivos = new javax.swing.JButton();
jInternalFrame1 = new javax.swing.JInternalFrame();
jScrollPane1 = new javax.swing.JScrollPane();
txtAreaTexto = new javax.swing.JTextPane();
lblImagem = new javax.swing.JLabel();
btnGuardarImagem = new javax.swing.JButton();
btnGuardarTexto = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
jTextField1 = new javax.swing.JTextField();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu2 = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
btnAbrirArquivos.setText("Carregar Arquivo");
btnAbrirArquivos.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnAbrirArquivosActionPerformed(evt);
}
});
jInternalFrame1.setTitle("Arquivo traduzido");
jInternalFrame1.setVisible(true);
jScrollPane1.setViewportView(txtAreaTexto);
javax.swing.GroupLayout jInternalFrame1Layout = new javax.swing.GroupLayout(jInternalFrame1.getContentPane());
jInternalFrame1.getContentPane().setLayout(jInternalFrame1Layout);
jInternalFrame1Layout.setHorizontalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addComponent(lblImagem)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE))
);
jInternalFrame1Layout.setVerticalGroup(
jInternalFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addGap(144, 144, 144)
.addComponent(lblImagem)
.addGap(0, 421, Short.MAX_VALUE))
.addGroup(jInternalFrame1Layout.createSequentialGroup()
.addComponent(jScrollPane1)
.addContainerGap())
);
btnGuardarImagem.setText("Salvar");
btnGuardarImagem.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGuardarImagemActionPerformed(evt);
}
});
btnGuardarTexto.setText("Salvar Texto");
btnGuardarTexto.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGuardarTextoActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 316, Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
);
jMenu1.setText("File");
jMenuBar1.add(jMenu1);
jMenu2.setText("Edit");
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(btnAbrirArquivos)
.addGap(28, 28, 28)
.addComponent(btnGuardarImagem)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnGuardarTexto))
.addGroup(layout.createSequentialGroup()
.addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(42, 42, 42)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(36, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jInternalFrame1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18))
.addGroup(layout.createSequentialGroup()
.addGap(60, 60, 60)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnAbrirArquivos)
.addComponent(btnGuardarImagem)
.addComponent(btnGuardarTexto))
.addGap(290, 290, 290))
);
pack();
}// </editor-fold>
//Função para abrir um arquivo de texto ou de imagem
private void btnAbrirArquivosActionPerformed(java.awt.event.ActionEvent evt) {
if (selecionado.showDialog(null, "Abrir arquivo") == JFileChooser.APPROVE_OPTION){
arquivo = selecionado.getSelectedFile();
if (arquivo.canRead()){
if (arquivo.getName().endsWith("txt")){
String conteudo = editor.AbrirATexto(arquivo);
txtAreaTexto.setText(conteudo);
}else{
if (arquivo.getName().endsWith ("jpg")||arquivo.getName().endsWith("png")|| arquivo.getName().endsWith("gif")){
bytesImg = editor.AbrirAImagem(arquivo);
lblImagem.setIcon(new ImageIcon(bytesImg));
}else{
JOptionPane.showMessageDialog(null, "Por favor selecione um arquivo de texto");
}
}
}
}
}
//Função para salvar um arquivo de imagem, usado caso necessario
private void btnGuardarImagemActionPerformed(java.awt.event.ActionEvent evt) {
if (selecionado.showDialog(null, "Salvar Imagem") == JFileChooser.APPROVE_OPTION){
arquivo = selecionado.getSelectedFile();
if (arquivo.getName().endsWith("jpg") || arquivo.getName().endsWith("png") || arquivo.getName().endsWith("gif")){
String resposta = editor.SalavarAImagem(arquivo, bytesImg);
if (resposta!=null){
JOptionPane.showMessageDialog(null, resposta);
}else{
JOptionPane.showMessageDialog(null, "Erro ao salvar imagem");
}
}else{
JOptionPane.showMessageDialog(null, "A imagem deve ser salvo em formato de imagem");
}
}
}
// Função para salvar os textos editado:
private void btnGuardarTextoActionPerformed(java.awt.event.ActionEvent evt) {
if (selecionado.showDialog(null, "Salvar Texto") == JFileChooser.APPROVE_OPTION){
arquivo = selecionado.getSelectedFile();
if (arquivo.getName().endsWith("txt")){
String conteudo = txtAreaTexto.getText();
String resposta = editor.SalvarATexto(arquivo, conteudo);
if (resposta!=null){
JOptionPane.showMessageDialog(null, resposta);
}else{
JOptionPane.showMessageDialog(null, "Erro ao salvar arquivo");
}
}else{
JOptionPane.showMessageDialog(null, "O arquivo deve ser salvo em formato de texto");
}
}
/**
* @param args the command line arguments
*/
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new JFGestaoA().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnAbrirArquivos;
private javax.swing.JButton btnGuardarImagem;
private javax.swing.JButton btnGuardarTexto;
private javax.swing.JInternalFrame jInternalFrame1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTextField jTextField1;
private javax.swing.JLabel lblImagem;
private javax.swing.JTextPane txtAreaTexto;
// End of variables declaration
}