0
btnLogin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
    JLabel mes = new JLabel("Please wait .. initializing");
    mes.setBounds(268, 249, 221, 14);
    frame.getContentPane().add(mes);
    JDialog d = new JDialog(frame, "Please wait .. initializing", true);
    ImageIcon loading = new ImageIcon("ajax-loader.gif");
    frame.add(new JLabel("loading... ", loading, JLabel.CENTER));
    JDialog d = new JDialog(frame, "Please wait .. initializing", true);
    d.setVisible(true);
    d.setBounds(268, 249, 221, 14);
    d.setLocationRelativeTo(frame);
    d.setVisible(true);
}

}

JLabel is not shown,but jdialog is seen on addActionListener

  • `mes.setBounds(268, 249, 221, 14);` suggests you're using a `null layout`, use a proper [layout manager](https://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html). See [null layout is evil](http://www.fredosaurus.com/notes-java/GUI/layouts/nulllayout.html) and the answers in [this question](http://stackoverflow.com/questions/6592468/why-is-it-frowned-upon-to-use-a-null-layout-in-swing) for more information on why you should avoid it. Also, for better help sooner post a valid [mcve], also I think you need to call `revalidate()` and `repaint()` methods... – Frakcool Mar 20 '17 at 16:25
  • Most likely the button is overlapped by the label –  Mar 20 '17 at 16:25
  • 1
    You're adding a new `JLabel` on the `frame`. This will add it to the default position of the default manager of the `JFrame`, which is: `BorderLayout#CENTER`... Pixel perfect applications are an illusion, see what happens [here](http://stackoverflow.com/questions/42520492/jtable-not-showing-up-on-jframe-java/42521097#42521097) if you use them like you're using them... – Frakcool Mar 20 '17 at 16:29

0 Answers0