Mam pewien problem. Otóż do wcześniejszej aplikacji wprowadziłem kilka zmian tj. treść o mnie, tła, czcionki. Jednak w WindowBuilder wygląda to tak jak zaplanowałem, jednak po play'u w eclipsie jest zawartość poprzedniej aplikacji. Mógłby ktoś pomóc?
package prapi;
import javax.swing.*;
import java.awt.event.*;
import java.io.*;
import java.awt.Color;
public class testy extends JFrame implements ActionListener {
public JTextArea textArea;
public testy(){
super();
getContentPane().setBackground(new Color(0, 204, 255));
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){ e.getWindow().dispose(); System.out.println("Aplikacja zakończyła działanie");
}
});
setSize (320, 320); setVisible(true);
setTitle("APLIKACJA PRAPI"); getContentPane().setLayout(null);
JMenuBar menuBar = new JMenuBar();
menuBar.setForeground(new Color(0, 102, 0));
menuBar.setBackground(new Color(51, 255, 51));
//Elementu MenuBar
JMenu menu = new JMenu("Plik");
JMenuItem menu2 = new JMenuItem("Autor");
menu2.addActionListener(this);
menu2.setActionCommand("AAutor");
//Elementy mrnu plik
JMenuItem Open = new JMenuItem("Otwórz");
Open.addActionListener(this);
Open.setActionCommand("AOpen");
JMenuItem Save = new JMenuItem("Zapisz");
Save.addActionListener(this);
Save.setActionCommand("ASave");
JMenuItem Exit = new JMenuItem("Zamknij");
Exit.addActionListener(this);
Exit.setActionCommand("Close");
menu.add(Open);
menu.add(Save);
menu.addSeparator();
menu.add(Exit);
textArea = new JTextArea();
textArea.setBounds(10, 10, 270, 137);
getContentPane().add(textArea);
menuBar.add(menu);
menuBar.add(menu2);
setJMenuBar(menuBar);
JButton btnZapisz = new JButton("ZAPISZ");
btnZapisz.setForeground(new Color(51, 255, 204));
btnZapisz.setBackground(new Color(0, 255, 255));
btnZapisz.setBounds(163, 208, 117, 29);
getContentPane().add(btnZapisz);
}
//metoda main
public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable(){
public void run(){
new Aplikacja1();
}
});
}
//obsługa zdarzeń
public void actionPerformed(ActionEvent e) { String command = e.getActionCommand(); if(command.equals("Close")){
JOptionPane.showMessageDialog(this, "Nastąpi zamknięcie aplikacji", "Informacja", JOptionPane.INFORMATION_MESSAGE);
dispose();
}
else if(command.equals("AOpen")){ JFileChooser fc = new JFileChooser();
if(fc.showOpenDialog(this)== JFileChooser.APPROVE_OPTION){ open(fc.getSelectedFile());
}
}
else if(command.equals("btnZapisz")){ JFileChooser fc = new JFileChooser();
if(fc.showSaveDialog(this)== JFileChooser.APPROVE_OPTION){ save(fc.getSelectedFile());
}
}
else if(command.equals("AZapisz")){ JFileChooser fc = new JFileChooser();
if(fc.showSaveDialog(this)== JFileChooser.APPROVE_OPTION){ save(fc.getSelectedFile());
}
}
else if(command.equals("AAutor")){
JOptionPane.showMessageDialog(this, "Autor Aplikacji: Rafał",
"Informacja", JOptionPane.INFORMATION_MESSAGE);
}
}
//odczyt
public void open(File file){ FileInputStream fin = null;
try{
fin = new FileInputStream(file);
}
catch(FileNotFoundException e){
JOptionPane.showMessageDialog(this, "Błąd przy otiweraniu pliku", "Błąd", JOptionPane.ERROR_MESSAGE);
return;
}
DataInputStream out = new DataInputStream(fin);
BufferedReader inbr = new BufferedReader(new InputStreamReader(fin)); textArea.setText("");
String line = "";
try{
while((line = inbr.readLine()) != null){ textArea.append(line + '\n');
}
}
catch(IOException e){
JOptionPane.showMessageDialog(this, "Błądprzy wejścia wyjścia", "Błąd", JOptionPane.ERROR_MESSAGE);
}
}
//zapis
public void save(File file){ FileOutputStream fout = null; try{
fout = new FileOutputStream(file);
}
catch(FileNotFoundException e){
JOptionPane.showMessageDialog(this, "Błąd przy zapisie pliku", "Błąd", JOptionPane.ERROR_MESSAGE);
return;
}
DataOutputStream out = new DataOutputStream(fout);
try{
String line = textArea.getText(); out.writeBytes(line + '\n');
}
catch(IOException e){
JOptionPane.showMessageDialog(this, "Błądprzy wejścia wyjścia",
"Błąd", JOptionPane.ERROR_MESSAGE);
}
}
}