I can't show the correct event .

I have check again . I had written Oval, Rectangle and Line JButton.
However, I just show circle.
I think this parts of the code has problem :but I don't clear
And the following has this all code(2 file) , thx a lot !
'************************************************I'm sure problem . I guess
clear.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e){
repaint();
System.out.println("Clear button is clicked");
public void itemStateChanged(ItemEvent event){
if (event.getSource() == oval)
p3 = new Painter(0);
else if (event.getSource() == oval && event.getSource() == filled)
p3 = new Painter(1);
else if (event.getSource() == line)
p3 = new Painter(2);
else if (event.getSource() == rectangle)
p3 = new Painter(3);
else if (event.getSource() == rectangle && event.getSource() == filled)
p3 = new Painter(4);
This is the following my code : thx .
'*************************************************JavaAss2.java
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class JavaAss2 extends JFrame implements ItemListener {
private JCheckBox filled = new JCheckBox("filled");
private JRadioButton oval = new JRadioButton("Oval");
private JRadioButton line = new JRadioButton("Line");
private JRadioButton rectangle = new JRadioButton("Rectangle");
private JButton clear = new JButton("Clear");
private Painter p3;
public JavaAss2() {
setBackground(Color.gray);
Container c = getContentPane();
c.setLayout(new BorderLayout());
JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(5, 1));
c.add(p1, BorderLayout.EAST);
Painter p2 = new Painter();
p2.setLayout(new BorderLayout());
c.add(p2, BorderLayout.CENTER);
clear.setSize(30, 15);
ButtonGroup btngp = new ButtonGroup();
btngp.add(oval);
btngp.add(line);
btngp.add(rectangle);
p1.add(oval);
p1.add(line);
p1.add(rectangle);
p1.add(filled);
p1.add(clear);
oval.addItemListener(this);
line.addItemListener(this);
rectangle.addItemListener(this);
filled.addItemListener(this);
clear.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e){
repaint();
System.out.println("Clear button is clicked");
public void itemStateChanged(ItemEvent event){
if (event.getSource() == oval)
p3 = new Painter(0);
else if (event.getSource() == oval && event.getSource() == filled)
p3 = new Painter(1);
else if (event.getSource() == line)
p3 = new Painter(2);
else if (event.getSource() == rectangle)
p3 = new Painter(3);
else if (event.getSource() == rectangle && event.getSource() == filled)
p3 = new Painter(4);
if (oval.isSelected())
new Painter(0);
else if (oval.isSelected() && filled.isSelected())
new Painter(1);
else if (line.isSelected())
new Painter(2);
else if (rectangle.isSelected())
new Painter(3);
else if (rectangle.isSelected() && filled.isSelected())
new Painter(4); */
public static void main (String args[]){
JavaAss2 javaAss2 = new JavaAss2();
javaAss2.setTitle("Painter");
javaAss2.setSize(500, 500);
//javaAss2.pack();
javaAss2.setVisible(true);
javaAss2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
'******************************************Painter.java
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
public class Painter extends JPanel{
private int Oid;
public Painter() {
setBackground(Color.white);
setSize(500, 500);
public Painter(int id){
Oid = id;
public void paintComponent(Graphics g){
super.paintComponent(g);
switch(Oid) {
case 0: g.drawOval(20, 20, 50, 50);
System.out.println("You have chosen Oval !!!");
break;
case 1: g.fillOval(20, 20, 50, 50);
System.out.println("You have chosen Oval with fill colour !!!");
break;
case 2: g.drawLine(100, 100, 150, 150);
System.out.println("You have chosen Line !!!");
break;
case 3: g.drawRect(30, 120, 150, 75);
System.out.println("You have chosen Rectangle !!!");
break;
case 4: g.fillRect(30, 120, 150, 75);
System.out.println("You have chosen Rectangle with fill colour !!!");
break;
}

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class test extends JFrame implements ItemListener {
  private JCheckBox filled = new JCheckBox("filled");
  private JRadioButton oval = new JRadioButton("Oval");
  private JRadioButton line = new JRadioButton("Line");
  private JRadioButton rectangle = new JRadioButton("Rectangle");
  private JButton clear = new JButton("Clear");
  // we need these references in itemStateChanged()
  private Painter p3;
  Container c;
  public test() {
    setBackground(Color.gray);
//    Container c = getContentPane();
    c = getContentPane();
    c.setLayout(new BorderLayout());
    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(5, 1));
    c.add(p1, BorderLayout.EAST);
    // so we can use p3 in itemStateChanged()
//    Painter p2 = new Painter();
    p3 = new Painter();
//    p2.setLayout(new BorderLayout());
    p3.setLayout(new BorderLayout());
//    c.add(p2, BorderLayout.CENTER);
    c.add(p3, BorderLayout.CENTER);
    clear.setSize(30, 15);
    ButtonGroup btngp = new ButtonGroup();
    btngp.add(oval);
    btngp.add(line);
    btngp.add(rectangle);
    p1.add(oval);
    p1.add(line);
    p1.add(rectangle);
    p1.add(filled);
    p1.add(clear);
    oval.addItemListener(this);
    line.addItemListener(this);
    rectangle.addItemListener(this);
    // line below >> class cast exception - because
    // in itemStateChanged we cast all events to JRadioButton
    // we really don't need a listener for the check box
    // we'll check to see if it is selected in our
    // itemStateChanged method
    //filled.addItemListener(this);
    clear.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e){
        System.out.println("Clear button is clicked");
    setLocation(300,25);
  public void itemStateChanged(ItemEvent event){
    JRadioButton button = (JRadioButton)event.getSource();
    String id = button.toString().substring(
                 button.toString().indexOf("text=") + 5,
                 button.toString().lastIndexOf("]"));
    System.out.println("id = " + id);
    c.remove(p3);
    if (button == oval) {
      if(filled.isSelected())
        p3 = new Painter(1); // fill
      else
        p3 = new Painter(0); // draw
    if (button == line)
      p3 = new Painter(2);
    if (button == rectangle) {
      if(filled.isSelected())
        p3 = new Painter(4); // fill
      else
        p3 = new Painter(3); // draw
    c.add(p3, BorderLayout.CENTER);
    c.repaint();
    c.validate();
  public class Painter extends JPanel{
    private int Oid;
    public Painter() {
      setBackground(Color.white);
      setSize(500, 500);
    public Painter(int id){
      Oid = id;
    public void paintComponent(Graphics g){
      super.paintComponent(g);
      System.out.println("Oid = " + Oid);
      switch(Oid) {
        case 0:
          g.drawOval(20, 20, 50, 50);
          System.out.println("You have chosen Oval !!!");
          break;
        case 1:
          g.fillOval(20, 20, 50, 50);
          System.out.println("You have chosen Oval with " +
                             "fill colour !!!");
          break;
        case 2:
          g.drawLine(100, 100, 150, 150);
          System.out.println("You have chosen Line !!!");
          break;
        case 3:
          g.drawRect(30, 120, 150, 75);
          System.out.println("You have chosen Rectangle !!!");
          break;
        case 4:
          g.fillRect(30, 120, 150, 75);
          System.out.println("You have chosen Rectangle " +
                             "with fill colour !!!");
  public static void main(String[] args) {
    test javaAss2 = new test();
//    JavaAss2 javaAss2 = new JavaAss2();
    javaAss2.setTitle("Painter");
    javaAss2.setSize(500, 500);
    //javaAss2.pack();
    javaAss2.setVisible(true);
    javaAss2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

Similar Messages

  • How can I show the correct answers in a quiz on Adobe Presenter 10?

    Hi all.
    I'm newer on Adobe Presenter.
    I've finished all questions on the quiz, but I like to show the correct answer after the user select a wrong answer and submit it.
    I've tried many thing and the correct answer isn't displayed.
    Thanks.
    Rafael.

    The correct answers are displayed after the quiz is completed and the user Reviews the quiz. If you want the correct answer to be revealed to the user in the quiz, then you will need to customize the feedback messages to state the correct answer. They are just text boxes on the slides, so you should be able to easily add text to them.

  • How can I show the correct word?

    I run this script.
    create table a (c1 nvarchar2(10));
    insert into a values ('aaaa');
    Then I make data block about table a,then query it in a base form. But when I execute,the result is "####" instead of "aaaa".
    Does anybody can tell me why and how to resolve? Thanks so much.
    My environment is:
    Oracle 9i Database 9.2.0.1.0
    Form builder 6.0.8.11.3
    WIN2K Advanced Server English Version
    System Default Language is: simplified Chinese
    Database Character set is default when setup.

    Thanks Carlos Gongora
    I have try to make canvas->frame->item->property->data->Maximun length The same as the length of the column in table. But it doesn't work.
    See this.
    create table t2 (c1 char(1), c2 char(2), c3 nchar(1), c4 nchar(2));
    insert into t2 values ('a', 'bb', 'c', 'dd');
    then the query result is "a, bb, #, ##"
    maybe the problem is in unicode.
    But I still can't correct it.

  • Can't find the correct event handler

    In the following code, I create 5 canvases where each canvas behaves like a button. Each canvas contains a text field and each canvas is draggable. I want to trigger an event when the user drags off the side of the canvas, but instead it is triggered as soon as I roll off the text field. You'll see what I mean if you click on the text, then drag off the text on the side. It will trigger a trace.
    It's very important that I only trigger an event when I drag off the canvas, not the text. Is there an event handler that will do thios for me?
    Thank you!
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"   creationComplete="init()">
        <mx:Script>
            <![CDATA[
                import mx.controls.Button;
                import mx.controls.Image;
                import mx.controls.Text;
                private var canvas2:Canvas;
                private var imageText:Text;
                [Bindable] private var thisButtonNumber:Number
                [Bindable] private var dragRectangle:Rectangle= new Rectangle(0, 0, 0, 300 )
                private function init():void{
                    for(var i:int=0;i<5;i++){               
                        canvas2=new Canvas;
                        canvas2.addEventListener(MouseEvent.MOUSE_DOWN, allowDrag)
                        canvas2.width=300;
                        canvas2.y=i*30;
                        imageText=new Text;
                        imageText.selectable=false;
                        imageText.text="Button "+String(i);
                        imageText.x=130
                        imageText.y=5;
                        canvas2.addChild(imageText);
                        canvas1.addChild(canvas2);
                    function allowDrag(e:MouseEvent):void {
                        canvas1.addChild(DisplayObject(e.currentTarget));
                        e.currentTarget.startDrag(false, dragRectangle);
                        e.currentTarget.addEventListener(MouseEvent.MOUSE_MOVE, checkPosition)
                    function ROLL_OUTtest(e:MouseEvent):void{
                        trace("ROLL_OUTtest="+e.currentTarget)
                        e.currentTarget.stopDrag();
                    function checkPosition(e:MouseEvent):void{
                        e.currentTarget.addEventListener(MouseEvent.MOUSE_OUT, ROLL_OUTtest)
            ]]>
        </mx:Script>
            <mx:Canvas   id="canvas1" x="400" y="25"   backgroundColor="0xdddddd"  buttonMode="true"  useHandCursor="true" />
    </mx:Application>

    Try ROLL_OUT, not MOUSE_OUT

  • News feed on my Facebook app doesn't show the correct time. Can the time be set?

    News feed on my Facebook app doesn't show the correct time.  Can the time be set?

    Does your phone show the correct time?
    If not, change the time on your phone, see if it helps.
    If it does, then sign out, sign back in. If that fails, the delete and reinstall. If that fails, then contact Facebook, as they're the developers of the app and will have the proper documentation to help you further.

  • How can i find the original picture in the correct event folder from an album folder picture?

    how can i find the original picture in the correct event folder from an album folder picture? I can find the link to the original event folder, but is there a way to get right to the picture without having to search visually the event folder?

    Depends on whatr you mean
    Deleting from your phone does not delete from anywhere else
    HOWEVER deleting from your Photo stream does delete from the Photostream so anyone looking at the PS from any device will no longer see the photo
    But if your Mac iPhoto is set to automatically impor tphotos form PS or is you have manually imported photos from PS then onc ethey are imported they are on your Mac and change to PS will not affect them
    for more on PS see http://support.apple.com/kb/HT4486?viewlocale=en_US&locale=en_US
    LN

  • Hi, can you help?  My emails that I have received show the date received as either today, yesterday or July 28.  How can I get the correct date received?

    Hi, The emails that I have received show the date received as either today, yesterday or July 28.  How can I get the correct date received?

    That's very scary. They might do it, but I personally have never had Apple contact me re id's except on their site when signing in. I suggest you DO NOT respond until you have a phone conversation with Apple security. They can verify if they sent you the e-mail and why.
    While it's very possible it's true,again, I suggest you not respond until you speak to someone at Apple. I've often read here that when people sign in they are not allowed to because "someone else has used the id" type of statement.
    Also, you should be able to go to the app store and see what apps you have downloaded.
    Though it could have been a free app, have you checked to see if any were bought with your id account?
    I've gotten these types of e-mails from places like USPS and FedEx which look amazingly authentic and were from their website. I also received an odd e-mail from my cousin in Ireland last year that clearly was not from him. It was also sent to others in his family in Ireland. I e-mailed him that I only opened it because it had a .ie, but suggested he change... Days later I received mail from 'him' - same name, but at yahoo.com. 
    Again, I would call Apple. You can also report it at [email protected], but I would not settle for that given your situation. If nothing else, call Apple sales (sales depts. anywhere answer fast) and ask them to transfer you to security. Apple will not want anybody accessing their name, and while it's unlikely, it's not impossible that it is someone phishing.
    Hope this helps and can you let the support community know your results by posting on this thread when you're done? Thank you.
    Hope this helps.

  • I just bought the 5s. It's showing the correct applie ID but the iCloud ID is showing an old email account and I can't change it

    I just bought the 5s. It's showing the correct applie ID but the iCloud ID is showing an old email account and I can't change it

    To change the iCloud ID you have to go to Settings>iCloud, tap Delete Account, provide the password for the old ID when prompted to turn off Find My iPhone, then sign back in with the ID you wish to use.  If you don't know the password for your old ID, or if it isn't accepted, go to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID.  Click edit next to the primary email account, change it back to your old email address and save the change.  Then edit the name of the account to change it back to your old email address.  You can now use your current password to turn off Find My iPhone on your device, even though it prompts you for the password for your old account ID. Then save any photo stream photos that you wish to keep to your camera roll.  When finished go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud).  Next, go back to https://appleid.apple.com and change your primary email address and iCloud ID name back to the way it was.  Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.

  • IPhone 4 app store shows incorrect apple id when I attempt to download updates.  I can log into iTunes ok as it shows the correct ID

    iPhone 4 app store shows incorrect apple id when I attempt to download updates.  I can log into iTunes ok as it shows the correct ID.  How to I change the ID in the ID/password dialog box.

    Sorry, but didn't see anything there that would help me precisely. Thanks for your input.  my apple ID is my email address which ends in .net.  My apple ID listed on the app update ends in .com.  I've confirmed in the settings/store area and it's correct there.  I'm still at a loss.

  • How can I get Messages to show the correct time for read receipts?

    Messages in Mountain Lion shows the wrong time for read receipts. For example, my iPad will show a message was read at 3:37 pm but if I open Messages on my MacBook, the read receipt shows the time that I opened the Messages app as opposed to the time the message was actually read. This is not too much of an issue if my iPad is handy, but really, shouldn't Messages on my MacBook be able to show the correct time the message was read? It syncs all the other infromation with Messages on iOs.
    I should mention that if Messages is running on my MacBook when the recipient reads the message, then it does show the correct time the message was read. It's if Messages was not running and I re-launch it that the read receipt time gets mixed up.

    HI,
    As far as I am aware Messages marks or time stamps an iMessage at the time of receipt rather then the time you got around to reading it.
    I will admit that in most cases reading and receiving as the app opens will be near enough the same time in some conversations.
    Adding Time Stamps to Chat is what iChat has always done particularly with AIM based Chats.
    The "Sync" in Messages is "display on all devices"  and after that each iMessages is dealth with separately on each device.
    There is no syncing of deleting/dimssing an iMessages or having read it on another device.
    8:58 PM      Tuesday; April 16, 2013
      iMac 2.5Ghz 5i 2011 (Mountain Lion 10.8.3)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad
    "Limit the Logs to the Bits above Binary Images."  No, Seriously
    Message was edited by: Ralph Johns (UK)

  • I recently rebuilt my iphoto 09 library and now all the pics are in one folder instead of events.  How do I get 20,000 pics back into the correct events?

    I recently rebuilt my iphoto 09 library and now all the pics are in one folder instead of events.  How do I get 20,000 pics back into the correct events?
    I have a macbook pro Version 8.1.2 and I am using Iphoto 09
    I rebuilt library because many pics were black and now they are in one folder labeled "Recovered"

    Do you have the original iPhoto Library (before you rebuilt it)?
    If so, I suggest you rebuild it using iPhoto Library Manager, a program you can download. It does a better job of rebuilding. It also leaves your original intact and makes the rebuilt Library a new file (package).
    If you don't have the original (say, from a backup), then you should probably first back up the library that you have before trying anything.
    After making a backup of it, look along the left side, you will see Events and Photos. Is there anything in either of those areas?
    If not, it sounds like all your photos were recovered and put in Recovered during the rebuild. iPhoto Library Manager might do a better job with this. In any case, if there are no photos in Events or in Photos, try selecting ~ 5 photos in Recovered and drag them to Photos. Do they then show up there with the correct dates? Do they also show up in Events after doing that? I am suggesting just a few photos before you try it with 20,000.
    If the photos inside your "recovered" area are also in Photos, then don't do the above steps. I'm not sure I can help you if your 20,000 photos are in Photos but not Events. I'd try iPhoto Library Manager instead with its better rebuild.
    If the 5 photos experiment works, then I would try it with ~ 200 photos at a time, going through your entire collection. You'll need to do this about 10 times if you really have 20,000 photos. Remember, don't do this if the "recovered" photos are already in "Photos."

  • My ipad is showing 7gb of storage being used on photos but there's no where near that many pictures! How do i get it to show the correct amount of storage available?

    My ipad is showing 7gb of storage being used on photos but there's no where near that many. I turned off photo stream but nothing has changed yet. How do i get it to display the correct internal usage now that photo stream is off? I also thought that icloud used another form of storage outside of the internal storage for photos, so im not exactly sure why the photos were ever in my internal storage to begin with. Does anyone know how that happens, or how to correct this problem? Im also trying to sync my ipad with my computer hoping that'll help, but nothing so far, its just taking a long time to back up.

    If you are syncing now, that may correct the incorrect storage reading - assuming that it is incorrect.
    You can also try something like this. While the iPad is still connected to iTunes - but after you sync - go into the Photos Tab in iTunes and toggle setting for Sync Photos From. Uncheck the setting and then check it again. See if that affects the capacity bar to show the correct storage amount.

  • Calendar Third Sunday of February doesn't show the correct day in all years

    Calendar Third Sunday of February doesn't show the correct day in all years?
    The day of month repeats the same day as saturday.
    Example: February 20 2010= Saturday. Sunday shows 20 and not 21.
    February 19 2010= Saturday. Sunday shows 19 and not 20...
    I'm in Brasil, where DST begins exactly on the third sunday of February (coincidence?)...But the problem persists even if I deactivate the hour fuse control !

    Yes, it's a DST issue. I've had this problem before at both ends of DST.
    You can submit feedback to Apple: http://www.apple.com/feedback/iphone.html.

  • Print preview and print doesn't show the correct out put result when i connnected with EPSON LX-300+II

    I hava an html webpage with css & print css. The print preview and print doesn't give correct output there is alignment problem when i connected with EPSONLX-300+II. But iam connected with hp laserjet they show the correct output with firefox. Please fix the problem as soon.....

    I have same problem as you, but later I know how to deal with it.
    1. change your print default preferences to
    print quality into (120x144 dpi, or other which suites you)
    mine goes well to 120x144 dpi
    2. Before print enter File->Page setup, set true to option shrink to page width
    in order to fit your page into your desired paper
    (firefox will resize your content to suit the paper you choose).
    If you dont want this you can disable this option.
    3. Still in Page Setup, if checkbox "Print background (color & images)" is unchecked then
    white text will be printed black.
    Set this checked if you want to print white text as it is color.
    I hope it answers your question.
    Steve
    http://www.dailymobilegames.com

  • IPhone World Clock doesn't show the correct times

    How do I get the iPhone to show the correct World Clock times. I have the time zone set to San Diego and the clock time is correct. When I set San Diego as one of the World Clock times it shows a time 7 hours behind. New York is 4 hours behind instead of 3 hours ahead, the same 7 hour bust.

    emr1100 ,
    Have you tried resetting the phone.? Hold down the sleep/wake button and the home button until it restarts. If that doesn't work, try a restore....please back up your data with a sync before you restore the phone. If that doesn't work take it back to the Apple stor and let them take a look at it. They will fix it or give you another phone. Another idea...call AT&T to see if sometining can be "reset" on their end. You never know ...that might work also.
    will2b

Maybe you are looking for