I've created a frame of this genre:
Butsinceitwastoshowthattheclientwashavingtroubleconnectingtoaserver,itwasbettertoswitchtoJDialog
Problem:IcannotgetJDialogvisible
Code:
publicclassWaitingJoptionextendsJDialog{//seforJFramefuncionadireitopublicWaitingJoption(){initUI();}privatevoidinitUI(){setTitle("Agurde pff...");
setUndecorated(true);
JPanel pane= new JPanel();
JPanel pane1= new JPanel();
pane.setLayout(new GridBagLayout());
pane1 = new Surface();
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.VERTICAL;
c.ipady = 80; //make this component tall
c.ipadx = 80;
c.weightx = 0.0;
c.gridwidth = 3;
c.gridx = 0;
c.gridy = 0;
pane.add(pane1, c);
JLabel labe = new JLabel("O cliente está a tentar connectar com o servidor...");
c.fill = GridBagConstraints.VERTICAL;
c.ipady = 40; //make this component tall
c.weightx = 0.0;
c.gridwidth = 3;
c.gridx = 0;
c.gridy = 1;
pane.add(labe, c);
getContentPane().add(pane);
setSize(300, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
WaitingJoption wt = new WaitingJoption();
wt.setVisible(true);
}
});
}
}