新しいウィンドウを開くボタンが付いた JDialog があります。私がやりたいことは、他のウィンドウが開くたびにこの JDialog をブロックすることです。ブロックとは、ユーザーがブロックを操作したり、移動したり、最大化したりできないことを意味します。
ところで、ボタンとテーブルのあるウィンドウには JDialog を使用することをお勧めしますか? どのフレームを使用する必要があるのか 、まだわかりません!
これは私が持っているものです:
public class Platos extends JDialog {
private final JPanel contentPanel = new JPanel();
public static void main(String[] args) {
try {
Platos dialog = new Platos();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public Platos() {
setBounds(100, 100, 450, 300);
getContentPane().setLayout(new BorderLayout());
contentPanel.setLayout(new FlowLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
{
JButton btnAgregarPlato = new JButton("Agregar Plato");
btnAgregarPlato.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
AgregarPlato ap = new AgregarPlato();
ap.setVisible(true);
}
});
btnAgregarPlato.setFont(new Font("Tahoma", Font.PLAIN, 11));
contentPanel.add(btnAgregarPlato);
}
}
}