Amir Elsaeed Amir Elsaeed - 6 months ago 43
Java Question

cannot find method setModal(boolean)

why I cann't find setModal() Method

I am working on GUI
I have two jframes
the following code is for a button and supposed to open the other frame
but i get error that say:

cannot find method setModal(boolean)

private void jButton3_actionPerformed(ActionEvent e)
HR hr = new HR();
if(f == 1){ // condition
hr.setModal(true); // give me error here ?
jLabel5.setText("You aren't connected...");

import java.awt.Dimension;

import javax.swing.JFrame;

public class HR extends JFrame {
public HR() {
try {
} catch (Exception e) {

private void jbInit() throws Exception {
this.getContentPane().setLayout( null );
this.setSize( new Dimension(400, 300) );



I am working on GUI I have two jframes

An application should only have a single parent JFrame. Other child windows should be a JDialog and you specify the frame as the parent.

A JDialog DOES have the setModal(...) method.

You create a JDialog the same way you create a JFrame.