Awt question

i want to develop app in awt.i want to know how to disable certain feature when the application is running in full screen mode. also if i want to run the application in windows and mac will it work for both. how to develop a common code and determine which os it is?

hi db, you kept on referring it to as same topic but in my own limited knowledge, i know that both swing and awt are not same one is lightweight another is heavyweight. let me not go into it. but you may wish to refer to the following post:
http://forum.java.sun.com/thread.jspa?threadID=271579&messageID=1044844
hello morgalr,
thanks for the reply. i am sorry if i have not been able to make my specific
query clear:-
1> I wish to develop an application in awt, in that app based on the fact that if the app is running in full screen, i want to disable certain menu option. my question is how to determine that my application is now running in full screen mode.
2> i wish to develop a common code which runs on both mac and windows. based on the fact that which os is it running, i want to add/remove certain menu options.i want to know the value of constants/ways of doing it.
i hope things are now clear. please help me as quickly as possible.

Similar Messages

  • Is there AWT questions in SCJP 1.5 exam?

    Is there AWT questions in SCJP 1.5 exam?
    In official exam description there is no mentioned about AWT.
    In Sybex certification guide, 5th edition, AWT also plased out of SCJP section.
    but some mock exams contains quite a lot of AWT questions.
    e.g. http://www.jchq.net/mockexams/exam1.htm
    Could people who passed the SCJP test tell me the real facts about AWT ?

    Is there AWT questions in SCJP 1.5 exam?
    In official exam description there is no mentioned
    about AWT.I don't think AWT is an issue, either. I'm not even sure whether Swing is a part. AWT is outdated ever since Swing was integrated in 1.2.

  • Swing Vs. Awt question

    this link http://www.jguru.com/faq/view.jsp?EID=106026
    mentions on feature at the end of the article that
    "If you're not very careful when programming, it can be slower than AWT (all components are drawn) "
    What is means. I mean what kind of carefulness he is talking about?
    I have JApplet and Jframe used heavily and looks like it's kind of slow.
    I am thinking to change it to awt based.
    Any advise
    thnks

    I don't know what that means either. But I do notice that it was written nearly seven years ago. Things that were said seven years ago about Java performance are totally useless today, so don't pay any attention to that.

  • 2 very easy AWT questions, please help

    Hello, hopefully one of you AWT Pros can help me out, im pretty new to AWT (i cannot use swing since my awt doesnt support it)
    (1) I have a center panel that display a pic "map.gif". It is currently on the upper left hand corner, how can i properly Center this pic?
    (2)I have a bottom panel that is a label to display a status bar. How do I change the background color from white/black text --> black/white text?
    I tried using something like:
    Label statusBar = new Label();
    statusBar.setBackground(color.black);  //and I also tried .....(black)
    statusBar.setForground(color.white);     //and I also tried ....(white)but i just get errors that say: <identifier> expected, and "cannot resolve symbol"
    any help would be great, thanks!!

    (1) You have to center the Image manually, for example:
    public class ImagePanel extends Panel
    { Image image=null;
    int imgWidth=0,imgHeight=0;
    public ImagePanel(Image img)
    { super(); 
    image=img;
    imgWidth=image.getWidth(this);
    imgHeight=image.getHeight(this);
    public void paint(Graphics g)
    { Dimension d=getSize();
    int x=(int)(d.width-imgWidth)/2;
    int y=(int)(d.height-imgHeight)/2;
    g.drawImage(image,x,y,this);
    (2) Label lb=new Label("Blah");
    lb.setForeground(Color.black);
    lb.setBackground(Color.white);

  • Can't get a class to display properly (TabPanel awt)

    Hi, thank you checking this out.
    I have renewed my interest for Java but need to start at the very beginning again. I have actuallu read up on AWT. Yes yes, I will follow up with Swing but for now I am just testing the waters again.
    However, I cant manage even the simplest of tasks. I want to display a TabPanel and do see something in the created Frame but something is not correct (it certainly is not a TabPanel). Would you have a clue as to what I am doing wrong? The TabPanel is an OpenSource example and I actually do not expect anything wrong with it. It does work with getMinimumSize so I might skip a beat there. Any comment is appreciated.
    This is what I build:
    import java.awt.Frame;
    import java.util.*;
    public class TabPaneltest {
        public static void main (String args[]) {
              Frame f = new Frame();
              f.reshape(176,10,800,600);
            TabPanel T = new TabPanel();
              f.add(T);
              T.setVisible(true);
              f.show();
    //                  (Still have to exit properly etc)// This is the TabPanel class as I found it, I am sure this is a usable error free component:
    // Free to use, can't redistribute for profit
    // Original by Pete Yared.
    // Modified by Jean-Guy Speton ([email protected]).
    //   Version 1.0.
    //   * Changed name to TabPanel to differentiate modification tree
    //     from original.
    //   * JDK 1.1 API compliant.
    //   * CardLayout used to simplify implementation.
    //   * Added getMinimumSize() and getPreferredSize().
    //   * Tab Font stored in state and created only once.
    //   * Tab in index 0 now default selected.
    //   * No longer repaints when user reselects selected tab.
    // Still free to use, still can't redistribute for profit.
    import java.awt.*;
    import java.awt.event.*;
    import java.util.Vector;
    public class TabPanel extends Panel implements MouseListener
         protected Vector labels = new Vector();
         protected Vector panels = new Vector();
         protected Panel cardPanel = new Panel();
         protected int[] tabWidths;
         protected String selectedPanel;
         protected Font tabFont = new Font("Dialog", 12, Font.PLAIN);
         protected Insets insets;
         protected int tabHeight = 21;
         protected int tabWidthBuffer = 13;
         protected int insetPadding = 14;
         public TabPanel()
              insets = new Insets(insetPadding + tabHeight, insetPadding,
                                       insetPadding, insetPadding);
              setLayout(null);
              addMouseListener(this);
              cardPanel.setLayout(new CardLayout());
              add(cardPanel);
    //  Sorry, can't put in full class because of a limit on the characters in the message.
    //  Full code at: http://www2.blaze.ca/~jspeton/java/tabpanel/TabPanel.java     // As said, I'd love to have this thing working as to (start) give me back some 'feel' for java. (It would // look so much better than 'Hello World':) Your remarks are appreciated.
    // Wim

    EsbachW wrote:
    Hi, thank you checking this out.
    I have renewed my interest for Java but need to start at the very beginning again. I have actuallu read up on AWT. Yes yes, I will follow up with Swing but for now I am just testing the waters again.It is a bad idea, in this day and age, to ask AWT questions. The reason is that AWT coding is so distant (in time) for GUI programmers of this millennium, that they forget the details!
    Besides that..
    However, I cant manage even the simplest of tasks. ...Using an Open Source class is not 'the simplest of tasks'. Note also that:
    a) We generally don't support 3rd party APIs on the forums. ..and..
    b) Most people will absolutely refuse to..
    ... // Sorry, can't put in full class because of a limit on the characters in the message.
    // Full code at: http://www2.blaze.ca/~jspeton/java/tabpanel/TabPanel.java
    .....follow a link to 'other code'. It is generally considered that if code is short enough to constitute 'an SSCCE' *(<- link),* then it is something short enough for them to look at. Any longer, and you've lost them.
    An SSCCE is not only a short form of code, but very specific. I recommend you read up on the SSCCE, and post code in that specific form.
    If you want some beginner projects to get you going again in Java, I recommend you put GUIs aside for a while do stuff intended to run from the command line. Use the Scanner class if you need interaction. When you get back to GUIs, launch directly into Swing, because that is the toolkit about which best help is to be had (and also includes a JTabbedPane supported by Sun!).

  • Change text size in Button

    How do I change the size of the text that is on a button?
    I can make the button size bigger or smaller with xysize but the text remains the same. Id like to make
    the text "SEND" bigger.
    Button sendButton = new Button(" SEND ");
    sendButton.addActionListener(this);
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    setLayout(gridbag);
    c.fill = c.BOTH;
    xysize = 3;
    c.gridx = 1;
    c.gridy = 5;
    c.weightx = xysize*2;
    c.weighty = xysize;
    gridbag.setConstraints(sendButton,c);
    add(sendButton);

    Developer Forums
    Forum: Abstract Window Toolkit (AWT)
    I guess, should be a better place to be asking AWT questions ;-)
    Rasmeet.

  • Custom mouselook  behavior problems

    I am trying to write a custom behavior for mouselook (I know there is one but I want the challenge and the custom levels). I can't seem to get it to move...
    Interaction1 class (JFrame):
    import javax.swing.JFrame;
    import java.awt.event.*;
    import javax.swing.Timer;
    import java.awt.GraphicsConfiguration;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import javax.media.j3d.*;
    import java.awt.Container;
    import java.awt.FlowLayout;
    import javax.vecmath.*;
    import java.awt.Image;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import javax.swing.ImageIcon;
    import java.awt.Polygon;
    import com.sun.j3d.utils.geometry.GeometryInfo;
    import com.sun.j3d.utils.geometry.Triangulator;
    import com.sun.j3d.utils.geometry.Stripifier;
    import com.sun.j3d.utils.universe.ViewingPlatform;
    import com.sun.j3d.utils.universe.Viewer;
    public class Interaction1 extends JFrame implements ActionListener, KeyListener
        public static final long serialVersionUID=1;
        private Timer t;
        private Canvas3D canvas;
        public Interaction1()
            super("Interaction1");
            setSize(700,530);
            setVisible(true);
            Container c = getContentPane();
            c.setLayout(new FlowLayout());
            GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
            canvas = new Canvas3D(config);
            canvas.setSize(640,480);
            canvas.setVisible(true);
            c.add(canvas);
            ViewingPlatform vp = new ViewingPlatform();
            vp.setNominalViewingTransform();
            vp.getViewPlatformTransform().setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
            vp.setViewPlatformBehavior( new MouseLookBehavior(vp.getViewPlatformTransform(),this,5f) );
            vp.getViewPlatformBehavior().setSchedulingBounds(new BoundingSphere());
            SimpleUniverse univ = new SimpleUniverse(vp, new Viewer(canvas));
            BranchGroup scene = createSceneGraph();
            scene.compile();
            univ.addBranchGraph(scene);
            addKeyListener(this);
            t=new Timer(10,this);
        private BranchGroup createSceneGraph()
            BranchGroup i = new BranchGroup();
            Background bg = new Background();
            bg.setColor(.75f,1f,1f);
            bg.setApplicationBounds(new BoundingSphere(new Point3d(),500.0));
            Shape3D side1 = new Shape3D();
            QuadArray abgeom = new QuadArray(4,QuadArray.COORDINATES|QuadArray.TEXTURE_COORDINATE_2);
            //order TL,BL,BR,TR
            abgeom.setCoordinate(0,new Point3f(-3f,4f,0f));//Front
            abgeom.setCoordinate(1,new Point3f(-3f,0f,0f));
            abgeom.setCoordinate(2,new Point3f(3f,0f,0f));
            abgeom.setCoordinate(3,new Point3f(3f,4f,0f));
            abgeom.setTextureCoordinate(0,0,new TexCoord2f(0f,0f));//Front
            abgeom.setTextureCoordinate(0,1,new TexCoord2f(0f,1f));
            abgeom.setTextureCoordinate(0,2,new TexCoord2f(1f,1f));
            abgeom.setTextureCoordinate(0,3,new TexCoord2f(1f,0f));
            side1.setGeometry(abgeom);
            Appearance abapp = new Appearance();
            Texture2D abtex = new Texture2D(Texture.BASE_LEVEL,Texture.RGB,64,64);
            abtex.setImage(0,new ImageComponent2D(ImageComponent.FORMAT_RGB,toBufferedImage((new ImageIcon("buildingside.jpg")).getImage())));
            abapp.setTexture(abtex);
            side1.setAppearance(abapp);
            i.addChild(bg);
            i.addChild(side1);
            return i;
        public void keyPressed(KeyEvent e)
            if(e.getKeyCode()==KeyEvent.VK_ESCAPE)
              System.exit(0);
        public void keyReleased(KeyEvent e)
        public void keyTyped(KeyEvent e)
        private BufferedImage toBufferedImage(Image a)
            BufferedImage b = new BufferedImage(64,64,BufferedImage.TYPE_INT_RGB);
            Graphics g = b.getGraphics();
            g.drawImage(a,0,0,null);
            return b;
        public void actionPerformed(ActionEvent e)
            repaint();
        public void paint(Graphics g)
            canvas.repaint();
        public static void main(String args[])
            JFrame a = new Interaction1();
    }MouseLookBehavior class (ViewPlatformBehavior):
    import java.util.Enumeration;
    import javax.media.j3d.*;
    import java.awt.event.MouseEvent;
    import java.awt.Robot;
    import java.awt.Window;
    import java.awt.Point;
    import java.awt.Dimension;
    import com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior;
    public class MouseLookBehavior extends ViewPlatformBehavior
        private TransformGroup target;
        private Transform3D yaw;
        private double yawTheta=0.0;
        private Robot robot;
        private Window window;
        private float sensitivity;
        public MouseLookBehavior(TransformGroup ooc, Window a, float senstvty)
            target=ooc;
            window = a;
            try{robot = new Robot();}catch(Exception e){}
            sensitivity=senstvty;
            yaw = new Transform3D();
        public MouseLookBehavior(TransformGroup ooc, Window a)
            target=ooc;
            window = a;
            try{robot = new Robot();}catch(Exception e){}
            sensitivity=2f;
            yaw = new Transform3D();
        public void initialize()
            wakeupOn(new WakeupOnAWTEvent(MouseEvent.MOUSE_MOVED));
        public void processStimulus(Enumeration e)
            MouseEvent a = (MouseEvent)(((WakeupOnAWTEvent)e.nextElement()).getAWTEvent()[0]);
            Point winloc = window.getLocation(null);
            Dimension windim = window.getSize(null);
            winloc.translate((int)windim.getWidth()/2,(int)windim.getHeight()/2);
            int difx=a.getX()-(int)(windim.getWidth()/2),dify=a.getY()-(int)(windim.getWidth()/2);
            difx*=sensitivity;
            dify*=sensitivity;
            yawTheta+=difx;
            yaw.rotY(yawTheta);
            wakeupOn(new WakeupOnAWTEvent(MouseEvent.MOUSE_MOVED));
            robot.mouseMove((int)windim.getWidth()/2,(int)windim.getHeight()/2);
    PLEASE NOTE: I have been trying to get an exit command in there but it hasn't worked, so if you decide to run this, you will have to ctrl-alt-dlt it and alt-e it to end the task which brings up an AWT question... why wont it exit?
    ALSO NOTE: I am aware of some extra useless variables in the processStimulus method. This is for future versions once I get this one to work. Ignore it.

    Perfect! Thanks. I've got a new problem now. whenever I try to use the mouselook, the object disappears. And so I tryed turning to find it and it still isn't there...
    Main class
    import javax.swing.JFrame;
    import java.awt.event.*;
    import javax.swing.Timer;
    import java.awt.GraphicsConfiguration;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import javax.media.j3d.*;
    import java.awt.Container;
    import java.awt.FlowLayout;
    import javax.vecmath.*;
    import java.awt.Image;
    import java.awt.Graphics;
    import java.awt.image.BufferedImage;
    import javax.swing.ImageIcon;
    import java.awt.Polygon;
    import com.sun.j3d.utils.geometry.GeometryInfo;
    import com.sun.j3d.utils.geometry.Triangulator;
    import com.sun.j3d.utils.geometry.Stripifier;
    import com.sun.j3d.utils.universe.ViewingPlatform;
    import com.sun.j3d.utils.universe.Viewer;
    import com.sun.j3d.utils.behaviors.mouse.MouseRotate;
    public class Interaction1 extends JFrame implements KeyListener
        public static final long serialVersionUID=1;
        private Canvas3D canvas;
        public Interaction1()
            super("Interaction1");
            setSize(700,530);
            setVisible(true);
            Container c = getContentPane();
            c.setLayout(new FlowLayout());
            GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
            canvas = new Canvas3D(config);
            canvas.setSize(640,480);
            canvas.setVisible(true);
            c.add(canvas);
            ViewingPlatform vp = new ViewingPlatform();
            vp.setNominalViewingTransform();
            vp.getViewPlatformTransform().setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
            vp.setViewPlatformBehavior( new MouseLookBehavior(vp.getViewPlatformTransform(),this,10f));
            vp.getViewPlatformBehavior().setSchedulingBounds(new BoundingSphere());
            SimpleUniverse univ = new SimpleUniverse(vp, new Viewer(canvas));
            BranchGroup scene = createSceneGraph();
            scene.compile();
            univ.addBranchGraph(scene);
            addKeyListener(this);
        private BranchGroup createSceneGraph()
            BranchGroup i = new BranchGroup();
            Background bg = new Background();
            bg.setColor(.75f,1f,1f);
            bg.setApplicationBounds(new BoundingSphere(new Point3d(),500.0));
            Shape3D side1 = new Shape3D();
            QuadArray abgeom = new QuadArray(4,QuadArray.COORDINATES|QuadArray.TEXTURE_COORDINATE_2);
            //order TL,BL,BR,TR
            abgeom.setCoordinate(0,new Point3f(-3f,4f,0f));//Front
            abgeom.setCoordinate(1,new Point3f(-3f,0f,0f));
            abgeom.setCoordinate(2,new Point3f(3f,0f,0f));
            abgeom.setCoordinate(3,new Point3f(3f,4f,0f));
            abgeom.setTextureCoordinate(0,0,new TexCoord2f(0f,0f));//Front
            abgeom.setTextureCoordinate(0,1,new TexCoord2f(0f,1f));
            abgeom.setTextureCoordinate(0,2,new TexCoord2f(1f,1f));
            abgeom.setTextureCoordinate(0,3,new TexCoord2f(1f,0f));
            side1.setGeometry(abgeom);
            Appearance abapp = new Appearance();
            Texture2D abtex = new Texture2D(Texture.BASE_LEVEL,Texture.RGB,64,64);
            abtex.setImage(0,new ImageComponent2D(ImageComponent.FORMAT_RGB,toBufferedImage((new ImageIcon("buildingside.jpg")).getImage())));
            abapp.setTexture(abtex);
            side1.setAppearance(abapp);
            i.addChild(bg);
            i.addChild(side1);
            return i;
        public void keyPressed(KeyEvent e)
            if(e.getKeyCode()==KeyEvent.VK_ESCAPE)
              System.exit(0);
        public void keyReleased(KeyEvent e)
        public void keyTyped(KeyEvent e)
        private BufferedImage toBufferedImage(Image a)
            BufferedImage b = new BufferedImage(64,64,BufferedImage.TYPE_INT_RGB);
            Graphics g = b.getGraphics();
            g.drawImage(a,0,0,null);
            return b;
        public static void main(String args[])
            JFrame a = new Interaction1();
    }MouseLookBehavior:
    import java.util.Enumeration;
    import javax.media.j3d.*;
    import java.awt.event.MouseEvent;
    import java.awt.Robot;
    import java.awt.Window;
    import java.awt.Point;
    import java.awt.Dimension;
    import com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior;
    public class MouseLookBehavior extends ViewPlatformBehavior
        private TransformGroup target;
        private Transform3D yaw;
        private double yawTheta=0.0;
        private Robot robot;
        private Window window;
        private float sensitivity;
        public MouseLookBehavior(TransformGroup ooc, Window a, float senstvty)
            target=ooc;
            window = a;
            try{robot = new Robot();}catch(Exception e){}
            sensitivity=senstvty;
            yaw = new Transform3D();
        public MouseLookBehavior(TransformGroup ooc, Window a)
            target=ooc;
            window = a;
            try{robot = new Robot();}catch(Exception e){}
            sensitivity=2f;
            yaw = new Transform3D();
        public void initialize()
            wakeupOn(new WakeupOnAWTEvent(MouseEvent.MOUSE_MOVED));
        public void processStimulus(Enumeration e)
            MouseEvent a = (MouseEvent)(((WakeupOnAWTEvent)e.nextElement()).getAWTEvent()[0]);
            Point winloc = window.getLocation(null);
            Dimension windim = window.getSize(null);
            winloc.translate((int)windim.getWidth()/2,(int)windim.getHeight()/2);
            int difx=a.getX()-(int)(windim.getWidth()/2),dify=a.getY()-(int)(windim.getWidth()/2);
            difx*=sensitivity;
            dify*=sensitivity;
            yawTheta+=difx;
            yaw.rotY(yawTheta/180*Math.PI);
            target.setTransform(yaw);
            robot.mouseMove((int)windim.getWidth()/2,(int)windim.getHeight()/2);
            wakeupOn(new WakeupOnAWTEvent(MouseEvent.MOUSE_MOVED));
    }

  • MAKING FUN WITH JUNIORS

    Hello to everybody reading this !
    A few comments to your grievance about the seniors.
    1. NEVER ask for sourcecode or solutions
    2. NEVER ask for a good explanation of provided sources
    3. NEVER say you are a newbie and then ask questions about difficult java-structures
    4. NEVER be frightened about bad answers or fun about you, the seniors started as juniors too
    5. ALWAYS think first then ask
    6. ALWAYS search databases at first (most times an equal topic exists)
    7. ALWAYS post in the right forum (no AWT-questions in the advanced-language-topics)
    8. ALWAYS it helps to read java-doc before asking
    9. ALWAYS think about the source, when it is provided to you, before asking again
    regards

    I mostly agree, except....
    1. NEVER ask for sourcecode or solutionsAsking for a few lines of source to demonstrate the steps to do a particular thing--as in "What are the steps to open a connection with JDBC. I've got database X, driver Y, and I've tried such-and-such, but it doesn't work"--is fine. Just don't ask for complete source to solve your homework problem. Big difference.
    2. NEVER ask for a good explanation of provided
    sourcesIf someone provides source or prose or whatever and you don't understand it, by all means DO ask for an explanation. Just try to be as specific as possible about what part you don't understand. And please, exercise your brain, and try--hard--to understand first.
    3. NEVER say you are a newbie and then ask questions
    about difficult java-structuresWhy not? Ask questions about whatever you want. BUT if you are a newbie and you ask about something that requires more advanced understanding, you may be told that you need to firm up your base knowledge before venturing into that area.
    4. NEVER be frightened about bad answers or fun about
    you, the seniors started as juniors tooAgree 100%
    5. ALWAYS think first then askAgree 2000%
    6. ALWAYS search databases at first (most times an
    equal topic exists)Yep. Do these forums have a FAQ? I haven't seen one, but then I haven't looked that hard. If there isn't one, there should be, and it should be prominently displayed.
    7. ALWAYS post in the right forum (no AWT-questions in
    the advanced-language-topics)Yeah, but, some questions could be valid in any of several forums. And as somebody pointed out elsewhere recently, what one person considers advanced, another may not. I would just modify this to say, "Use good judgement and common sense to pick a forum that seems appropriate."
    8. ALWAYS it helps to read java-doc before askingYep. But not all newbies know about the existence of API javadocs. In another forum, I proposed a modified TOS, I guess one thing to add there would be to make it clear that these docs exist and where to find them.
    9. ALWAYS think about the source, when it is provided
    to you, before asking againYep.

  • Question : Save AWT Image Class to File..

    I Have a Question.. @.@a
    I'm doing AWT transform now..
    Well...
    I have a problem..
    I want to save AWT Image class to file..
    But.. I don't now that..
    Input Image Class same below..
    Image imageContent = (Image)attachment.getContent();
    How does it save imageContent Image class to file..?

    I had the same problem... convert it to a BufferedImage (http://forum.java.sun.com/thread.jspa?threadID=665744&tstart=15), then use javax.imageio.ImageIO.write to save it to a file.

  • Difference between awt ang Swing Interview Question n other Question

    hi every one i use to think that i know java atlest so much that i can crack a lolcal comp interview but ........................
    i ansered few Question but was speachlees when was asked few of this i do not remember all of them
    1] difference between awt and swing.
    2]System.out.println();
    System is a class out is a variable so who come a variable calling a method.
    3]are constractor inherateed in java.

    1] difference between awt and swing.AWT is based on an abstraction of platform-specific, heavy-weight components. Swing is written entirely in java.
    >
    2]System.out.println();
    System is a class out is a variable so who come a
    variable calling a method.Do you mean how come?
    In that case, the answer is simple: Because out is a variable, it can be redirected/compared against, etc much easier
    3]are constractor inherateed in java.Kind of a trick question, as the answer is yes and no. Constructors are not inherited, but every constructor in the subclass must call one and exactly one constructor of the superclass

  • Very simple Java AWT Frame resize question

    In the following code, I create an awt Frame. Unfortunately, when I run the resulting Java application (on Windows) and use the mouse to resize the window, none of the Frame's resize/setSize methods get called. Can anyone explain why this is?
    Thanks
    Greg
    import java.awt.* ;
    public class Junk extends Frame {
    public static void main (String args[])
    Junk j = new Junk ();
    j.show ();
    public void resize(Dimension arg0)
    super.resize(arg0);
    public void resize(int arg0, int arg1)
    super.resize(arg0, arg1);
    public void setSize(Dimension arg0)
    super.setSize(arg0);
    public void setSize(int arg0, int arg1)
    super.setSize(arg0, arg1);
    }

    When the user resizes the frame with the mouse, the resizing action probably happens entirely on the Frame's peer, without the java.awt.Frame getting involved at all. setSize() and [deprecated] resize() allow an application to programmatically change the size of a Frame, but the Frame just passes the new size to its peer.
    If you want to detect when your Frame has been resized, use addComponentListener to register a component listener on the Frame, and then put your code in the componentResized method of the listener.

  • AWT/thread question, please help

    Hi,
    Can someone help me with this problem I've been struggling over. Basically I have 2 classes.
    Class1: Frame1.java
    Class2: MyProgram.java
    Frame1 class is basically my GUI in AWT.
    MyProgram class is a basic program.
    I'm trying to give my program a interface and that is why I created Frame1 class. The problem I'm having is I don't know how to do text outputs to the GUI.
    I have system.out.println in MyProgram class and I'm trying to have these printouts go to the GUI (specially to a textArea control that I have set up in the Frame1 class) while the program is running.
    MyProgram extends thread so that when I run the GUI program and click on a button the MyProgram class runs in a separate thread. Thus I have two threads, one that is watching for events (mouse clicks, etc) in the GUI program and the other thread which is running in MyProgram class.
    If anyone can help me out, I would really appreciate it. Thanks in advance,
    Erick

    Thanks Dalzhim,
    Unfortunately I've tried that and it doesn't work. I can't just put JTestArea.append(String str) in MyProgram class. It will give me a variable not exists error. If I put this code in the Frame1 class then it works. But what I want to happen is on every System.out.println statement I have in MyProgram class, I want that print statement to go to the textArea. How do I set up my classes to allow this communication? Thanks.
    Erick

  • Awt.KeyEvents, advanced question.

    How do you capture KeyEvents system- wide?
    Some cool java 1.2 (or later) code:
    Toolkit.getDefaultToolkit().addAWTEventListener (this, AWTEvent.KEY_EVENT_MASK);
    public void eventDispatched(AWTEvent event)
       //...event captured! I can react on it here!
    }This nice piece of code is java 1.2 and hence can�t be used by my applet. (My users are stuck with a browser that only supports java 1.1.8, and they don�t want to download any plug-in)
    How do I do this in java 1.1.8?
    My approach so far has been to use addKeyListener() recursively on the applet and all its awt.Component�s. It works ok but it is a little messy, especially when components are added or removed (Then I have to detect it and perform the recursive adding of KeyListeners again.). Is there any other way?

    I suggest you use single ContainerListener and KeyListener instance to handle the add and remove component and key event.

  • Quick practical question: swing vs. awt

    Hi,
    I have an app/applet w/ a fairly simple calculator-type gui. But I want it to run well even on old Pentiums. How much will it matter if I use swing or awt, in terms of performance of the app, ie. user response to gui input? Is it really noticeable?
    Does the system resource usage differ as well even while there is no user input?
    TIA,
    Reggie

    In my experience swing often performs better than awt does, as far as memory and speed...
    Swing can't run in IE without a plugin tho, so consider that before you start switching

  • Question about AWT vs. Swing

    Say I'm building an applet. Which I am. Why should I choose AWT components over Swing? Or vise-versa? Swing seems "cooler" but I read somewhere that they're non-standard or harder to install/setup. Something like that.
    Any advice before I begin hard work on my UI?

    No version of ANY browser supports Swing without using the JRE. In most cases the page has to be converted to call the Java Plugin (which will be installed if the user has the JRE) before the JRE will be used to execute an applet. All the majority of users have is the VM that comes with their browser, which is stuck at something like JDK 1.1.6, which does not include Swing.
    I would develop simple applets using only the AWT so that users can use the browser's VM. However if you have something more complex to do, I would require the user to have the Java Plugin, and then you can use Swing unto your Heart's Content.
    Just some general thoughts about this issue:
    I would like to move away from applets, and onto signed applications, which are downloaded and run from the user's machine. They can be kept up to date with the new Java WebStart (I believe), and will benefit from a newer VM, and more sophisticated language features. In addition it would lead to more users downloading the JRE, and the general spread of Java onto the client. I don't believe applets have a future beyond their current state, and let's face it, that state is quite lame.
    Does anybody else have any thoughts on this issue?

Maybe you are looking for