Answer the question
In order to leave comments, you need to log in
JDialog not showing in browser?
There is this code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Hello extends JDialog {
public Hello(JFrame jfr) {
super(jfr, true);
JButton ok = new JButton("ok");
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setVisible(false);
}
});
setSize(100,100);
pack();
setVisible(true);
}
}
public class test extends JApplet {
public void init() {
try {
SwingUtilities.invokeAndWait(new Runnable () {
public void run () {
makeGui();
}
});
}
catch (Exception e) {
System.out.println(e);
}
}
public void makeGui () {
setLayout(new FlowLayout());
JButton tb = new JButton("test");
add(tb);
Hello hello = new Hello(null);
setVisible(true);
}
}
<!DOCTYPE html>
<html>
<body>
<applet code="test.class" width = 1000 height = 750>ehwlhewle </applet>
</body>
</html>
Answer the question
In order to leave comments, you need to log in
1. You have not added anything to this dialog. Or rather, in its content pane . And don't forget the LayoutManager.
2. The call to setSize() is ignored because you called pack() after it.
Well, you don't need to call setVisible() in the constructor.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question