import
javax.swing.*;
import
java.awt.*;
import
java.awt.event.*;
class
pop1
extends
JFrame
implements
ActionListener {
Popup po;
JFrame f;
JPanel p;
PopupFactory pf;
pop1()
{
f =
new
JFrame(
"pop"
);
f.setSize(
400
,
400
);
pf =
new
PopupFactory();
JLabel l =
new
JLabel(
"This is a popup menu"
);
JButton b19 =
new
JButton(
"OK"
);
b19.addActionListener(
this
);
try
{
UIManager.setLookAndFeel(UIManager.
getSystemLookAndFeelClassName());
}
catch
(Exception e) {
}
p =
new
JPanel();
p.setBackground(Color.blue);
Font fo =
new
Font(
"BOLD"
,
1
,
14
);
l.setFont(fo);
p.add(l);
p.add(b19);
p.setLayout(
new
GridLayout(
2
,
1
));
po = pf.getPopup(f, p,
180
,
100
);
JButton b =
new
JButton(
"click"
);
b.addActionListener(
this
);
JPanel p1 =
new
JPanel();
p1.add(b);
f.add(p1);
f.show();
}
public
void
actionPerformed(ActionEvent e)
{
String d = e.getActionCommand();
if
(d.equals(
"OK"
)) {
po.hide();
po = pf.getPopup(f, p,
180
,
100
);
}
else
po.show();
}
public
static
void
main(String args[])
{
pop1 p =
new
pop1();
}
}