File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes java.lang.Error: Unresolved compilation problem:   	ModalityType cannot be resolved Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "java.lang.Error: Unresolved compilation problem:   	ModalityType cannot be resolved" Watch "java.lang.Error: Unresolved compilation problem:   	ModalityType cannot be resolved" New topic
Author

java.lang.Error: Unresolved compilation problem: ModalityType cannot be resolved

rohan gaur
Greenhorn

Joined: Sep 16, 2010
Posts: 1
[color=darkblue][size=12]package swingdialogs;
import java.awt.Dialog;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;


class AboutDialog extends JDialog {

public AboutDialog() {
setTitle("About Notes");

setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

add(Box.createRigidArea(new Dimension(0, 10)));

ImageIcon icon = new ImageIcon("notes.png");
JLabel label = new JLabel(icon);
label.setAlignmentX(0.5f);
add(label);

add(Box.createRigidArea(new Dimension(0, 10)));

JLabel name = new JLabel("Notes, 1.23");
name.setFont(new Font("Serif", Font.BOLD, 13));
name.setAlignmentX(0.5f);
add(name);

add(Box.createRigidArea(new Dimension(0, 50)));

JButton close = new JButton("Close");
close.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
dispose();
}
});

close.setAlignmentX(0.5f);
add(close);
setModalityType(ModalityType.APPLICATION_MODAL);

setDefaultCloseOperation(DISPOSE_ON_CLOSE);
setLocationRelativeTo(null);
setSize(300, 200);

}

}


public class SimpleDialog extends JFrame {


public SimpleDialog() {

setTitle("Simple Dialog");

JMenuBar menubar = new JMenuBar();

JMenu file = new JMenu("File");
file.setMnemonic(KeyEvent.VK_F);

JMenu help = new JMenu("Help");
help.setMnemonic(KeyEvent.VK_H);

JMenuItem about = new JMenuItem("About");
help.add(about);

about.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
AboutDialog ad = new AboutDialog();
ad.setVisible(true);
}

});

menubar.add(file);
menubar.add(help);
setJMenuBar(menubar);

setSize(300, 200);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}

public static void main(String[] args) {
new SimpleDialog();
}
}





//////////////////////////////// In Class :: AboutDialog, while setting ModalityType ///////////////////////////////
Please, help me out to resolve out this problem ..[/size][/color]


Thanks & Regards,
Rohan Gaur
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Welcome to the forum. UseCodeTags to post code so that it is readable. And to get better help sooner, always post a SSCCE. Your question is about a class that's not found. JMenus and ActionListeners and the like have nothing to do with your question and are just so much clutter when it comes to reading the code.

Dialog.ModalityType. Or import static ...Dialog.*; and you will be able to use the unqualified name in your code.


luck, db
There are no new questions, but there may be new answers.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Dialog.ModalityType has been added in Java 6. Are you perhaps using an older version?

Also, never ever ever ever run code that still has compiler errors in it. Fix those first. Your IDE is showing you exactly what they are.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.Error: Unresolved compilation problem: ModalityType cannot be resolved
 
Similar Threads
modeless JDialog?
Menu Items are not appearing.
Displaying pdf and rtf files
Ultra noob problem
help on reading textfield on 1 class from another class and using it to create a file