I have troubles with my application. The concept is that i want to creat a window which display the progress of java commands. Here is the code of this:
import java.awt.*;
import javax.swing.*;
class DosCommandsWindow extends JFrame{
JLabel firstMsg, progressMsg, enFolderMsg, dbMsg, shortcutMsg, finishedMsg;//koina JLabel.Etiketes host, port, dbName, user kai password
public DosCommandsWindow()//arxikh dhmiourgia tou frame
{
super("Endocrino Installation");
this.setSize(400,200);
this.setMinimumSize(new Dimension(400,200));
this.setMaximumSize(new Dimension(400,200));
this.setResizable(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}//constractor
public void createForm(int rows,int columns,int vgap,int hgap)//orizei sto panel tou frame topothethsh sumfwna me to GridLayout
{
JPanel panel=new JPanel();
GridLayout g=new GridLayout(rows,columns,vgap,hgap);
panel.setLayout(g);
this.setContentPane(panel);
this.addElements();
}//createForm
public void addProgressMsg()//prosthetei to minima "Plese wait.."
{
Container c=this.getContentPane();
this.progressMsg=new JLabel("Progress");
c.add(this.progressMsg);
}
public void addFirstMsg()//prosthetei to minima "Plese wait.."
{
Container c=this.getContentPane();
this.firstMsg=new JLabel("Please wait...");
c.add(this.firstMsg);
}//addFirstMsg
public void addEnFolderMsg()//prosthetei to label gia tin dimiourgia tou fakelou C:/Endocrino
{
Container c=this.getContentPane();
this.enFolderMsg=new JLabel("jju");
c.add(this.enFolderMsg);
}//addEnFolderMsg
public void addDBMsg()//prosthetei to label gia tin dimiourgia tis basis
{
Container c=this.getContentPane();
this.dbMsg=new JLabel("jbj");
c.add(this.dbMsg);
}//addDBMsg
public void addShortcutMsg()//prosthetei to label gia tin dimiourgia tou shortcut sto Desktop
{
Container c=this.getContentPane();
this.shortcutMsg=new JLabel("jbgj");
c.add(this.shortcutMsg);
}//addShortcutMsg
public void addFinishedMsg()//prosthetei to label gia tin dimiourgia tou minimatos "finished"
{
Container c=this.getContentPane();
this.finishedMsg=new JLabel("jg");
c.add(this.finishedMsg);
}//addFinishedMsg
public void showForm()//emfanizei to frame
{
this.setVisible(true);
}//showFrame
public void addElements(){
this.addProgressMsg();
this.addFirstMsg();
this.addEnFolderMsg();
this.addDBMsg();
this.addShortcutMsg();
this.addFinishedMsg();
}//addElements
public void close(){
this.dispose();
System.exit(0);
}
public void dosCommands(){
this.enFolderMsg.setText("Creating Endocrino Folder...");
java.lang.Thread.sleep(1000);
revalidate();repaint();
this.dbMsg.setText("Creating Data Base...");
java.lang.Thread.sleep(1000);
revalidate();repaint();
this.shortcutMsg.setText("Creating shortcut...");
java.lang.Thread.sleep(1000);
revalidate();repaint();
this.finishedMsg.setText("Finished");
JOptionPane.showMessageDialog(null,"Now you can delete the Endocrino folder from your Desktop");
close();
}//dosCommands
}//DosCOmmandsWindow
The problem is that when i run this class it goes well but when call it from another jframe it doesn't. This is the frame which call the DosCommandsWindow
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileNotFoundException;
class SettingsForm extends JFrame{
JButton submit,defaultOption;//koumpia kataxwrhshs-akurwshs
JLabel host;//koina JLabel.Etiketes host, port, dbName, user kai password
JTextField hostT;//koina JTextField.perioxh egrafhs twn host, port, dbName, user kai password
public SettingsForm()//arxikh dhmiourgia tou frame
{
super("Data Base Information");
this.setSize(300,300);
this.setMinimumSize(new Dimension(300,300));
this.setMaximumSize(new Dimension(300,300));
this.setResizable(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
}//constractor
public void createForm(int rows,int columns,int vgap,int hgap)//orizei sto panel tou frame topothethsh sumfwna me to GridLayout
{
JPanel panel=new JPanel();
GridLayout g=new GridLayout(rows,columns,vgap,hgap);
panel.setLayout(g);
this.setContentPane(panel);
this.addElements();
submit.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if (hostT.getText().length()!=0)
{
try {
CreateSettings s = new CreateSettings("Endocrino\\settings.txt");
s.write(hostT.getText());
close();
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
else{
JOptionPane.showMessageDialog(null,"All items must be filled","Warning",JOptionPane.ERROR_MESSAGE);
}
}
});
defaultOption.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{ hostT.setText("localhost");
}
});
}//createForm
public void addButtons()//prosthetei to koumpi kataxwrhshs sto panel
{
Container c=this.getContentPane();
this.submit=new JButton("OK");
this.defaultOption=new JButton("Set Default");
c.add(submit);
c.add(defaultOption);
}//addButtons
public void addHost()//prosthetei to label kai text field gia egrafh tou host apo ton xrhsth
{
Container c=this.getContentPane();
this.host=new JLabel("Host");
this.hostT=new JTextField();
c.add(host);
c.add(hostT);
}//addHost
public void showForm()//emfanizei to frame
{
this.setVisible(true);
}//showFrame
public void addElements(){
this.addHost();
this.addButtons();
}//addElements
public void close(){
this.dispose();
DosCommandsWindow d=new DosCommandsWindow();
d.createForm(6,1,3,3);
d.showForm();
d.dosCommands();
}//close
}//SettingsForm