Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

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

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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]
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 21758
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!