Extending the Dialog Class

Hey, I'm trying to extend the Dialog class into something called a DialogErrorBox, which is just what it sounds like: a dialog box specifically for telling the user about errors it encounters. Here's the code:
import java.awt.*;
import java.awt.event.*;
class DialogErrorBox extends Dialog implements ActionListener {
     public DialogErrorBox (Frame parent) {
    ...//modified to give a vague error message
     }//end constructor
public DialogErrorBox (Frame parent, String title, String message) {
    ...//worked as a function in my program
     }//end constructor
public void actionPerformed (ActionEvent evt) {
          this.dispose();
}The compiling error I recieve at both constructors is:
...cannot resolve symbol
symbol  : constructor Dialog  ()
location: class java.awt.Dialog
        public DialogErrorBox2 (Frame parent, String title, String message) {I can't figure out why this error would happen. I've made a class extending Frame(Frame and Dialog both extend Window) that looks almost exactly the same and it has no errors.
Help would be much appreciated.

A: Extending the Dialog Class

This is a short and spotty explanation, to get the full skinny you might read pages 69 and 70 of The Java Programming Language 3rd Edition, Gosling, et. al.
If you don't use the superclass's constructor or one your own as the first executable statement , the superclass's no arg constructor gets called. This means that super() will get called automagically! I don't believe that Dialog has a no arg constructor, so you are forced to do something.
You could also do something like this:
public DialogErrorBox(Frame frame, String title) {
   this(frame, title, true);
}Now the two argument constructor invokes the three arument constructor with a default value of true.
Do you see why this must happen?

This is a short and spotty explanation, to get the full skinny you might read pages 69 and 70 of The Java Programming Language 3rd Edition, Gosling, et. al.
If you don't use the superclass's constructor or one your own as the first executable statement , the superclass's no arg constructor gets called. This means that super() will get called automagically! I don't believe that Dialog has a no arg constructor, so you are forced to do something.
You could also do something like this:
public DialogErrorBox(Frame frame, String title) {
   this(frame, title, true);
}Now the two argument constructor invokes the three arument constructor with a default value of true.
Do you see why this must happen?

Similar Messages

  • EXTENDING the string class

    ok, i know extending the string class is illegal because it's final, but i want to make an advanced string class that basically "extends" the string class and i've seen online this can be done through wrapper classes and/or composition, but i'm lost
    here is my sample code that is coming up with numerous compile time errors due to the fact that when i declare a new AdvString object, it doesn't inherit the basic string features (note: Add is a method that can add a character to a specified location in a string)
    class AdvString
         private String s;
         public AdvString(String s)
              this.s = s;
         public void Add(int pos, char ch)
              int this_len = (this.length()) + 1;
              int i;
              for(i=0;i<(this_len);i++)
                   if(pos == i)
                        this = this + ch;
                   else if(pos < i)
                        this = this + this.charAt(i-1);
                   else
                        this = this + this.charAt(i);
         public static void main(String[] args)
              AdvString s1;
              s1 = new AdvString("hello");
              char c = 'x';
              int i = 3;
              s1.Add(i,c);
              //s2 = Add(s1,i,c);
              //String s2_reversed = Reverse(s2);     
              System.out.println("s1 is: " + s1);
    any tips?

    see REString at,
    http://www.geocities.com/rmlchan/mt.html
    you will have to replicate all the String methods you are interested in, and just forward it to the String instance stored in REString or the like. it is like a conduit class and just passes most processing to the 'real' string. maybe a facade pattern.

  • Confused about extending the Sprite class

    Howdy --
    I'm learning object oriented programming with ActionScript and am confused about the Sprite class and OO in general.
    My understanding is that the Sprite class allows you to group a set of objects together so that you can manipulate all of the objects simultaneously.
    I've been exploring the Open Flash Chart code and notice that the main class extends the Sprite class:
    public class Base extends Sprite {
    What does this enable you to do?
    Also, on a related note, how do I draw, say, a line once I've extended it?
    Without extending Sprite I could write:
    var graphContainer:Sprite = new Sprite();
    var newLine:Graphics = graphContainer.graphics;
    And it would work fine. Once I extend the Sprite class, I'm lost. How do I modify that code so that it still draws a line? I tried:
    var newLine:Graphics = this.graphics;
    My understanding is that since I'm extending the Sprite class, I should still be able to call its graphics method (or property? I have no idea). But, it yells at me, saying "1046: Type was not found or was not a compile-time constant: Graphics.

    Thanks -- that helped get rid of the error, I really appreciate it.
    Alas, I am still confused about the extended Sprite class.
    Here's my code so far. I want to draw an x-axis:
    package charts {
        import flash.display.Sprite;
        import flash.display.Graphics;
        public class Chart extends Sprite {
            // Attributes
            public var chartName:String;
            // Constructor
            public function Chart(width:Number, height:Number) {
                this.width = width;
                this.height = height;
            // Methods
            public function render() {
                drawAxis();
            public function drawAxis() {
                var newLine:Graphics = this.graphics;
                newLine.lineStyle(1, 0x000000);
                newLine.moveTo(0, 100);
                newLine.lineTo(100, 100);
    I instantiate Chart by saying var myChart:Chart = new Chart(); then I say myChart.render(); hoping that it will draw the axis, but nothing happens.
    I know I need the addChild method somewhere in here but I can't figure out where or what the parameter is, which goes back to my confusion regarding the extended Sprite class.
    I'll get this eventually =)

  • Can we extend the Throwable class instead of Exception Class??

    Hi all..
    Can we extend the Throwable class instead of Exception Class while creating our own custom Exception?If not Why?
    Please give your valuble advices..
    Ramesh.

    I don't want to hijack the thread here, but in a conversational tone...on a related note.. I've thought about this too a bit and wondered if there are some recommended practices about catching and handling Throwable in certain applications. Like the other day I was debugging a web application that was triggering a 500. The only way I could find the problem in an error stack was to write code to catch Throwable, log the stack, and then re-throw it. I considered it "debug" code, and once I solved the problem I took the code out because, my understanding is, we don't want to be handling runtime problems... or do we? Should I have a catch clause for Throwable in my servlet and then pass the message to ServletException?
    So along with the OP question, are there separate defined occasions when we should or should not handle Throwable? Or does it just all depend on circumstance?

  • How can I extend the Vector class?

    Hi All,
    I'm trying to extend the Vector class so I can get add a .remove(item:T) method to the class.  I've tried this:
    public class VectorCollection extends Vector.<T>
    That gives me the compile error "1017: The definition of base class Vector was not found"
    So then I tried:
    public class VectorCollection extends Vector
    Which gives me the compile error "1016: Base class is final."
    There must be some way to extend the Vector class, though, as on the Vector's official docs page it says:
    Note: To override this method in a subclass of Vector, use ...args for the parameters, as this example shows:
         public override function splice(...args) {
           // your statements here
    So there must be a way to extend the Vector class.  What am I doing wrong?

    No. AS3 doesn't currently have full support for generic types; Vector.<T> was added in an ad-hoc ("ad-hack"?) way. We are considering adding full support in a future version of ActionScript.
    Gordon Smith
    Adobe Flex SDK Team

  • Extending the Thread class

    i would like to do that
    1) One thread displays "ABC" every 2 second;
    2) The other thread displays DEF every 5 seconds;
    i need to create the threads by extending the Thread class ...
    thank you for your help ,
                public class Thread1 extends Thread {
              public Thread1(String s ) {
                   super (s);
              public void run() {
                   for ( int i=0; i<5; i++ ) {
                        System.out.println(getName());
                        try {
                           sleep ((long) 5000);
                        } catch (InterruptedException e ) {
                           /* do nothing */
              public static void main (String args[]) {
                   new Thread1 ("ABC").start();
                   new Thread1 ("DEF").start();
         }     

    I think he has been told to use the Thread class by the sounds of it.
    public class Thread1 extends Thread {
         public Thread1(String s ) {
              super (s);
         public void run() {
              for ( int i=0; i<5; i++ ) {
                   System.out.println(getName());
                   try {
                      sleep (getName().equals("ABC")? 5000 : 2000); //If you don't understand this then Google for "Java ternary operator"
                   } catch (InterruptedException e ) {
                      /* do nothing */
         public static void main (String args[]) {
              new Thread1 ("ABC").start();
              new Thread1 ("DEF").start();
    }

  • Explicitly extending the Object class

    Hi Everyone,
    I am aware that every object that is running inside a JVM inherits from class Object implicitly. Recently I have come across some code that explicitly extends the Object class, is there any advantage in doing this, please see the code snippet below:
    public class MyClass extends Object{}Thanks heaps for your assistance.
    Regards
    Davo

    I've even seen a
    method that was declared "throws NullPointerException"shouldn't it have been "throws java.lang.NullPointerException" ...
    - I almost cried. Yes, thats truly a terrible habit :(
    a distant cousin of that habit is one I have noticed where the developer
    is totally unable to name anything appropriately..
    to print some things to the screen: "loadData"
    to print things to screen again: "getInformation" *(note: did not 'return' anything).
    ... :(

  • Extend the String Class

    Is there a way to extend the string class? I know it's final, if i make my class final too would that work? I want to add some functionality to the string class, but I wanna be able to do concatination with the + operator and stuff like that. That's special to the String class.
    Any help would be great.
    Thanks.
    Joe

    Well, put your mind at easy with the fact that being
    able to use the '+' operator on Strings is a design
    flaw in Java. At least from a purist point of view...And from a pragmatist's point of view, it's a reasonable compromise, the benefit of which outweighs the downside. This is consistent with Java's goal as a good general-purpose language. It's not intended to be pure OO or pure anything else.

  • I need help extending the MovieClip class

    I want to add a property to the MovieClip class. I just have a bunch of MovieClips that are placed on the stage by reading an XML file and creating lots of clips according to the information in them. Now, I need to know which MovieClips were created below previous clips, and I figure that the easiest way to do so would be by extending the MovieClip class and add an order property.
    I have some problems though: I don't know how to set or get this order property within the main clip, I don't know how to place this clip within my movie, and I don't know how to create them dynamically (do I just do something like var myNewObjectOfExtendedClass : myExtendedClassName = new myExtendedClassName?)
    This is the code I have on my extended class, called Expando.as:
    class Expando extends MovieClip {
    private var _order:Number;
    public function get order():Number {
    return _order;
    public function set order(nOrder:Number):Void {
    _order = nOrder;

    You mean the Tree component?
    My concern with the Tree component (at least the AS2 version) is that I don't see a way to have each node in the Tree have different hit areas with different outcomes.
    The tree that I build must have up to 7 levels within each main branch, and not all of them behave the same way. In some branches, clicking the icon next to the label will have a completely different outcome than clicking on the label, which may or may not return a function. Each of those sublevels also need to support different icons, depending on what information is represented by it.
    Sample:
    • Reminders
    My Reminders
    Manual Reminders
    Escalated Reminders
    • Cases
    Name Actions < ---- this is where the problem begins. Clicking on the icon where the bullet should be should do something different than clicking on the name, which should do something different than clicking on the word ActionsThis is information about that referral that includes who referred them, the date of the referral, their full address. This information usually takes up 2 lines, sometimes 3
    Assignment   <------- you can only open see these leaves if you click on the bullet icon for the previous node; you can't open this by clicking on the text.
    Eligibility
    Etc., depending on what information has been appended
    • Suppliers
    Anyway, if the Tree Component can indeed support these features, I'd like to know where to find information about it please
    In my search for that information, I concluded that I'd probably be better served by building my own MovieClip that can handle these requirements. I did have a working Tree component pretty quickly as I started this project, but then I got more familiar with the app that I'm building the training for and noticed these requirements.
    Of course, maybe all these features are supported by the AS3 Tree component. The problem is that I'm a lot worse with AS3 than I am with AS2 heh.

  • Problem Extending the  Dialog component from Flex

    I'm trying to extend the flex Dialog component () for usage in Xcelcius, I can package my component successfully and add it to the add-ons in Xcelsius. The problem is that if I try to drag and drop the component to the Xcelsius workspace, the component appears blank and halts the IDE a bit. Does anyone have an idea what I might be doing wrong?
    my code is as follows:
    package com.component.xcelsius.component
         import flash.text.TextFormatAlign;
         import mx.containers.TitleWindow;
         import mx.controls.Label;
         import mx.core.ScrollPolicy;
         [CxInspectableList ("title", "showTitle")]
         public class ErrorMessageHandler extends TitleWindow
              private var _titleChanged:Boolean = true;
              private var _valueChanged:Boolean = true;
              private var _titleText:String = "My Own";
              private var _showTitle:Boolean = true;
              private var _visible:Boolean = true;
              public function ErrorMessageHandler()
                   super();
              [Inspectable(defaultValue="Title", type="String")]
              public override function get title():String
                   return _titleText;
              public override function set title(value:String):void
                   if (value == null)  value = "";
                   if (_titleText != value)
                        _titleText = value;
                        _titleChanged = true;
                        invalidateProperties();
              override protected function createChildren():void
                   super.createChildren();
                   // Allow the user to make this component very small.
                   this.minWidth = 200;
                   this.minHeight= 25;
                   // turn off the scroll bars
                   this.horizontalScrollPolicy = ScrollPolicy.OFF;
                   this.verticalScrollPolicy = ScrollPolicy.OFF;
              override protected function commitProperties():void
                   super.commitProperties();
                   if (this._titleChanged)
                        this.title = _titleText;
                        this.visible = true;
                        this.showCloseButton = true;
                        invalidateDisplayList();  // invalidate in case the titles require more or less room.
                        _titleChanged = false;
                   if (this._valueChanged)
              // Override updateDisplayList() to update the component
            // based on the style setting.
              override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                   super.updateDisplayList(unscaledWidth, unscaledHeight);

    Hi,
    First of all make sure you compile your Flex project with Flex SDK 2.0.1 Hotfix 3?
    In the Add-on Packager carefully check your classname (the full class path + class name) because Xcelsius creates an instance of that class when you drag the add-on onto the canvas, so if it doesn't create anything usually it means your classname is wrong in the packager.
    In your case:   
    com.component.xcelsius.component.ErrorMessageHandler
    If none of that works try extending from VBox as the top-level add-on class instead and see if that works (I have never tried with a TitleWindow).
    Regards
    Matt

  • Extending the core classes of swing.

    Hi all
    I'm fairly new to java programming, and are working on an application based on JTree. I use an advanced cellRenderer extended from JPanel. Everything works fine, and I am a happy man, but I sould like a tiny bit more information for the renderer to do just as I like.
    I got my information from the signature in the method, .getTreeCellRenderComponent, issued by the BasicTreeUI. In adddition to what I get (which is a lot), I shall like to have some informations on the bounds, as I sets the size of my renderer container according to the depth of the tree.
    I can't see any properties for me to set, dealing with my needs.
    My approach is to extend the BasicTreeUI, and overriding the methods I need, among them the .getTreeCellRendererComponent with added bounds information.
    It works fine for some methods, but not for the types in dialog with the LayoutChache or the JTree, as properties I need are set to private in the these classes.
    Is there a runaround for me to access these private properies?
    any experianced java application developers who can give me a hint and recommendation?
    thks and regards
    endref

    one thing there is no runaround for, is to know the classes. And the only way to do that is to spend time looking:)
    Though I was searching, on and off, for four days, I found the solution one hour after posting my question.
    I type it here, if someone is interested:
    in the .getTreeCellRendererComponent(tree, ..etc.)
    method in the rendering class,
    I gets the depth of the node from
    javax.swing.tree.TreePath path = tree.getPathForRow(row);
    int x=0;
    if(path!=null){
    x = path.getPathCount();
    from the level, pretty easy to calculate the needed size of the container, as in default JTree indent 20 pixels pr. level.
    Anyhow, for this, I now does not need to extend the BasicTreeUI, but if anyone has a wiev on the subject, it would be nice to here.
    thks and regards

  • Error Extending the OAEntityImpl class when creating a BC4J  Entity Object

    I have created an EO based on an Oracle Apps table and extended the OAEntityDefImpl, OAEntityCache and OAEntityImpl classes as specified in the OA Framework Developers Guide when creating EO's via the BC4J wizard.
    When I build my Business Components package I recive an error stating that the Impl class should be declared abstract.
    Error(14,8): class oracle.apps.xxtpc.arinvoices.schema.TpcApInvoicesEO2Impl should be declared abstract; it does not define method setLastUpdateLogin(oracle.jbo.domain.Number) in class oracle.apps.fnd.framework.server.OAEntityImpl
    When I modify this class to declare it abstract and then try to test (via the AM test function) the VO that I created based on this EO - I receive an oracle.jbo.RowCreateException: JBO-25017.
    Do you think that this has anything to do with modifying the Impl class to make it abstract? I can create another VO against the same table by creating a SQL statement against it and not basing it off of the EO and this VO will run correctly via the AM tester.
    Thanks,
    Chris
    oracle.jbo.RowCreateException: JBO-25017: Error while creating a new entity row for TpcApInvoicesEO.
         at oracle.jbo.server.EntityDefImpl.createBlankInstance(EntityDefImpl.java:1054)
         at oracle.jbo.server.ViewRowImpl.createMissingEntities(ViewRowImpl.java:1532)
         at oracle.jbo.server.ViewRowImpl.init(ViewRowImpl.java:236)
         at oracle.jbo.server.ViewDefImpl.createBlankInstance(ViewDefImpl.java:1050)
         at oracle.jbo.server.ViewDefImpl.createInstanceFromResultSet(ViewDefImpl.java:1007)
         at oracle.jbo.server.ViewObjectImpl.createRowFromResultSet(ViewObjectImpl.java:2643)

    The problem was that there were no audit columns in the table that I was querying.

  • Extending the  JButton class

    Hello,
    I'm trying to create a new Java object that extends JButton , and I want it to look like a regular rectangle , be able to change color, and have an action listener . This new Object is supposed to be used in tables so that any elemnt of that table may be clicked on in order to make certain onformation appear in an Applet....
    I'd just like to know if that's possible and a little bit how I could do it if it is ...Thanks..
    Cri

    everything you describe is certainly possible. You ought to be able to do the things you described without actually overridign the JButton class itself (perhaps consider implementing a factory instead). In any case, you'll want to be sure to look at the JTable tutorial for help with getting Buttons to work correctly in a JTable. Everything you need should be in there.

  • Inner Class extending the outer class

    Could anyone explain this code to me? It can compile and run. Could anyone tell me what the class Main.Inner.Inner is? What members does it consists of? How the compiler manage to build such a class?
    public class Main {
        public static class Inner extends Main {
        public static void main(String[] args) {
            System.out.println("Hello, world.");
    }

    By the way, it's not really an inner class, because it's static. It's just a nested class.
    You might want to have a nested class extend its enclosing class if, maybe, you wanted to delegate to subclasses and didn't want to create a lot of extra source code files, which might make sense if the nested subclasses were really small.
    public abstract class Animal {
      public abstract void makeSound();
      private Animal() {} // can't be directly instantiated
      private static class Dog extends Animal {
        public void makeSound() { System.out.println("woof"); }
      private static class Cat extends Animal {
        public void makeSound() { System.out.println("meow"); }
      private static class Zebra extends Animal {
        public void makeSound() { System.out.println("i am a zebra"); }
      public static Animal get(String desc) {
        if ("fetches sticks".equals(desc)) {
          return new Dog();
        if ("hunts mice".equals(desc)) {
          return new Cat();
        if ("stripey horse".equals(desc)) {
          return new Zebra();
        return null;
    public class AnimalTest {
      public static void main(String... argv) {
        Animal a = Animal.get("fetches sticks");
        a.makeSound();
    }

  • Extending the Sprite class

    Hello,
    I don't understand why the Sprite class cannot be extended and still directly displayed with addChild(). As is clearly exposed in the doc:
    http://livedocs.adobe.com/flex/3/langref/flash/display/Sprite.html
      public class SpriteExample extends Sprite {
            private var size:uint    = 100;
            private var bgColor:uint = 0xFFCC00;
            public function SpriteExample() {
                var child:Sprite = new Sprite();
                child.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
                child.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
                draw(child);
                addChild(child);
    The SpriteExample class constructor will create a new Sprite, and this Sprite is the one added to the UI. I have tried to directly add the SpriteExample object to the UI but it will not display. Is there a reason for that or am I doing something wrong?
    Thank you in advance,
    Pierre

    thanks for your answer.
    It is right I have been trying to do this with a FlexSprite rather than a Sprite. Where could i find details about the required interface to implement in a FlexSprite derivate to make it a  IUIComponents?
    Reguarding the draw() method, do you mean this method is actually called each time the Sprite in redrawn?
    Best,
    Pierre

Maybe you are looking for

  • Need help in updating a hierarchy

    I have a table T1 which has the following columns: Emp_ID - varchar Mgr_ID - varchar One EmpID can have only one Mgr ID, One MgrId can have multiple EmpID. Emp_ID can be Mgr_ID for some other Emp_ID. I need to write a code in which I have to edit all

  • Adobe Spry validation : Remove Field

    I have use Adobe spry validation . I have the following situation where i want to remove some fields from validation depending on the choice. like on one radio button click i have 5 fields and on submit button press i validate the fields. now i switc

  • Rebate Agreement output

    Hi, I have two issues in printing data using a smartform. First one is: I am developing a rebate agreement using smartforms. I took all the data in an internal table and passed it the smartform. While i am trying to display them looping in main table

  • Synch with iPhone

    How can I synch my iphone with Lightroom rather than iphoto

  • Adobe premier element disk pile up

    It seems like som working files i premier element gets left on the c disk even after deleting projekts. I can´t find those files on my c disk and I dont know what file ending they have. Need help. Laursen77