Double effect from itemStateChanged

Hi!
I�d like this to happen: when clicking on 3rd alternative a new menu to come along.
But there comes two menus!
This happens only when I call a function (createMine)
that returns a JComboBox OR when i call a public variable
(that is a JComboBox) in another class.
Why is the effect double?
Kind Regards//jF

Thanks!
It seems the itemStateChanged and the if (if (minMeny.getSelectedIndex() == 2))is entered twice. But that�s mysterious. (The new JComboBox has not yet
an itemListener. ) What is the DESELECTED variable for? Do I have to tell
the itemStateChanged somehow that "Now I don�t select this item anymore?"
hmm that can�t be it. :)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
* Write a description of class newGUI here.
* @author (your name)
* @version (a version number or a date)
//denna klass ska ge alt:
//boka
//avboka
//visa biljetter
public class IP implements ActionListener, ItemListener
    // instance variables - replace the example below with your own
    JFrame tfnFrame;
    JPanel tfnPanel;
    JTextField tfnNummer;
    JLabel bekr�ftelseLabel, testLabel;
    JButton skickaKnapp;
    JComboBox minMeny ;
    JComboBox testCombo ;
    String kundnummer ;
    Bio Frasses  ;
     * Constructor for objects of class newGUI
     //Create and set up the window.
    public IP()
        //bara vid test f�r Frasse initieras s� h�r
        //obs �ndra till long
        Frasses = new Bio(new Kund("24")) ;
        tfnFrame = new JFrame("Frasses Bio");
        tfnFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        tfnFrame.setSize(new Dimension(120, 40)); //Create and set up the panel.
        tfnPanel = new JPanel(new GridLayout(2, 2)); //Add the widgets.
        addWidgets(); //Set the default button.
        tfnFrame.getRootPane().setDefaultButton(skickaKnapp); //Add the panel to the window.
        tfnFrame.getContentPane().add(tfnPanel, BorderLayout.CENTER); //Display the window.
        tfnFrame.pack();
        tfnFrame.setVisible(true);
    private void addWidgets()
    { //Create widgets.
        tfnNummer = new JTextField(2);
        testLabel = new JLabel("Test*******", SwingConstants.LEFT);
        skickaKnapp = new JButton("Hall�");
        bekr�ftelseLabel = new JLabel("Resultat", SwingConstants.LEFT);
        //Listen to events from the Convert button.
        skickaKnapp.addActionListener(this);
      minMeny = new JComboBox() ;
       minMeny.addItem("L�gg till Film") ;
       minMeny.addItem("Ta bort Film") ;
       minMeny.addItem("L�gg till F�rest�llning ") ;
       minMeny.addItem("Ta bort F�rest�llning ") ;
       minMeny.addItem("Visa aktuella Filmer") ;
       minMeny.addItem("Visa aktuella F�rest�llningar") ;
       minMeny.addItem("Visa biljetter") ;
       minMeny.addItem("Visa antal lediga platser") ;
      minMeny.addItemListener(this) ; //hmm this intressant
      minMeny.addActionListener(this) ;
        //Add the widgets to the container.
        testCombo = new JComboBox() ;
        testCombo.addItem("Hej!") ;
        tfnPanel.add(tfnNummer);
        tfnPanel.add(testLabel);
        tfnPanel.add(skickaKnapp);
        tfnPanel.add(bekr�ftelseLabel);
        tfnPanel.add(minMeny) ;
        testLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
        testLabel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    public void actionPerformed(ActionEvent event)
        String dittNummer = tfnNummer.getText() ;
        dittNummer = fixaNummer(dittNummer) ;
        if (�rSiffra(dittNummer))
            bekr�ftelseLabel.setText("true");
         else
            bekr�ftelseLabel.setText("false");
            if( event.getSource() == minMeny)
                bekr�ftelseLabel.setText("hallonpaj") ;
              System.out.println("itemlistener11") ;
                //Bokning nu = new Bokning() ;
                 tfnPanel.remove(minMeny) ;
                 tfnPanel.add(createNow()) ;
            //   testLabel.setText("hejhej") ;
               //    tfnFrame.getContentPane().add(tfnPanel, BorderLayout.CENTER); //Display the window.
        tfnFrame.pack();
        tfnFrame.setVisible(true);
                //alt �ndra minMeny till skapaMeny...
               //ide� k�ra create ..
               //m�ste jag addera den en g�ng till
    private static String fixaNummer(String min)
        StringTokenizer st1 = new StringTokenizer(min, "/") ;
        StringTokenizer st2 = new StringTokenizer(f�Ihop(st1) , "-") ;
        StringTokenizer st3 = new StringTokenizer(f�Ihop(st2), " ") ;
        return f�Ihop(st3) ;   
      private static String f�Ihop(StringTokenizer s)
          String temp = "" ;
        while (s.hasMoreElements())
                temp += s.nextToken() ;
        return temp ;
   ///** * Create the GUI and show it. For thread safety, * this method should be invoked from the * event-dispatching thread. */
//changed from private static to -->
    private static void createAndShowGUI()
        { //Make sure we have nice window decorations.
                System.out.println("creatAndShow") ;
            JFrame.setDefaultLookAndFeelDecorated(true);
            IP minTest = new IP();
    private JLabel createMine()
        JLabel nu = new JLabel("Mine", SwingConstants.LEFT);
        return nu ;
    private JComboBox createNow()
        JComboBox temp = new JComboBox() ;
        temp.addItem("Nummer 24") ;
        temp.addItem("Nummer 25") ;
        return temp ;
     public void itemStateChanged(ItemEvent y)
             System.out.println("item") ;
             MenyBoka nu = new MenyBoka(Frasses) ;
        if (y.getSource() == minMeny)
            if (minMeny.getSelectedIndex() == 0)
              System.out.println("itemlistener11") ;
                //Bokning nu = new Bokning() ;
                 tfnPanel.remove(minMeny) ;
                 tfnPanel.add(createNow()) ;
            //   testLabel.setText("hejhej") ;
               //    tfnFrame.getContentPane().add(tfnPanel, BorderLayout.CENTER); //Display the window.
             tfnFrame.pack();
             tfnFrame.setVisible(true);
                //alt �ndra minMeny till skapaMeny...
               //ide� k�ra create ..
               //m�ste jag addera den en g�ng till
             if (minMeny.getSelectedIndex() == 1)
                      System.out.println("select1") ;
               testLabel.setText("snusmumrik") ;
              if (minMeny.getSelectedIndex() == 2)
                    System.out.println("inuti selcted 2") ;
                 tfnPanel.remove(minMeny) ;
                 tfnPanel.add(nu.bokaMeny) ;
                 tfnFrame.pack();
                 tfnFrame.setVisible(true);
     } //itemstatechanged
   public static void main(String[] args)
   { //Schedule a job for the event-dispatching thread: //creating and showing this application's GUI.
    System.out.println("main") ;
    javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } 
    public static boolean �rSiffra(String nr)
         try
            int minTry = Integer.parseInt(nr) ;
            return true ;
         catch (NumberFormatException ne)
          //   ne.printStackTrace()  ;
             return false ;
    }//�rSiffra
             

Similar Messages

  • Weird "double" effect in Safari

    Im running Leopard 10.5.2, have all the current updates, to date. And just recently i've been getting this weird bug in Safari with all pages.
    When viewing a page, esp one with lots of text and verticle scrolling, all the text seems to jumble together and create a doubling effect, almost tripling in some cases. ill post a few screenshots of what I'm experiencing, but hopefully there's a fix for this, reading my daily blogs is becoming a big hassle.
    thanks in adv
    on a side note, this does not happen at all using the most current version of firefox...
    http://img170.imageshack.us/img170/9492/picture2kh3.png
    http://img147.imageshack.us/img147/4400/picture4th9.png
    http://img170.imageshack.us/img170/7681/picture1fb9.png

    Try this, it can't hurt.
    1) Quit all open applications.
    2) Delete your fonts caches with FontNuke or OnyX +(or with whatever utility you normally use)+
    FontNuke <http://www.jamapi.com/pr/fn/>
    OnyX <http://www.titanium.free.fr/pgs/english.html>
    3) Restart your Mac
    4) Open your Font Book->Edit menu 'Select All' fonts - from the File menu select 'Validate Fonts'
    from the Edit menu select 'Resolve Duplicates'
    Good luck,
    Tom

  • How can i print double sided from my macbook? The option is not highlighted., how can i print double sided from my macbook? The option is not highlighted.

    How can I print double sided from my MacBook? The option is not highlighted,
    shazmina2

    This function is related to the printer driver and the printer you use. If you do not give details, nobody can suggest a solution. Usually, the correct driver solves the issue.

  • How to print double sided from my Mac to my Canon MG6350

    I have looked up everywhere on the internet and youtube of how to print double sided from my Mac Book Pro. I am using OSX 10.8.5.
    All of the dicussions I have looked up before have told me to go to System Preferences>Print & Scan>Options & Supplies> Driver and then tick the little box that comes up and it will allow you to print double sided. I have tried doing this but THERE IS NO DRIVER TAB!!!
    I was just wondering if there was a solution to this as I can print double sided from my other appliences, like the PC and iPad, it is just my Mac Book Pro that doesn't work.
    It has become a big problem for me as I'm studying at college and I need to print things double sided quite regularly. I really need this to work.

    The print dialog has several drop-down menus, one of which initially shows the name of the application you're printing from. If the printer supports duplex, you can choose
    Duplex Printing & Margin
    from that menu. You should then see a checkbox marked
    Automatic Duplex Printing

  • How can I copy an audio effect from a clip and paste it to another clip in the same timiline...With FCPro 7 it was all so fast........

    how can I copy an audio effect from a clip and paste it to another clip in the same timiline...With FCPro 7 it was all so fast........

    Tom Wolsky wrote:
    The advantage goes to FCP7 if you allow that it can copy and paste filters, audio and video, transformations, and other attributes separately.
    You can do that in FCPX too, as all the things you cited are listed separately in the inspector.
    Here's a little gotcha. Let's say you've color corrected a few clips and you've applied an effect to one and want to paste it the other clips. You switch off color correction and copy the clip. You select the other clips and paste effects. What do you think happens? The effect is applied, but the color correction is applied as well, only it's switched off as it was in the first clip, so all the color correction on the other clips is lost. Fun, eh?
    I'll try to replicate your gotcha - but no, that doesn't sound like fun at all!

  • What's the easiest way to move or copy an effect from a layer or object to another layer or object?

    If I drag an effect from the target circle of one object to anther in the layer's panel it replaces the effect along with all appearance. But I want just to add the effect. For example, a layer has a drop shadow and a path, round corners. I want to move the drop shadow from the layer  to the path so that the path now has the round corners and the drop shadow. 
    To do this I have to open the shadow effect of the layer wright down its parameters, then create a shadow effect for the path with the same parameters which is a lot of work. Any easier way?

    Thanks Monika,
    May be I'm not understanding you or may be you misunderstood me.
    This is an example:
    Create a document and a path (for example a box) and apply Effects > Stylize > Round Corners
    In the layers panel, click the target circle of the layer and apply Effects > Stylize > Drop Shadow.
    Now I want to move or copy the drop shadow from the layer and add it to the path without removing the Round Corners effects already applied to the path.
    The result for the path should be Drop Shadow effect added to it and the Round Corners effect remains. 
    The result for the layer should be no effect remains for it in case of moving the effect or the Drop Shadow effect remains in case of copying it (holding Alt key while dragging from its target circle).

  • Realistic Page Turn Effects from a PDF document

    Is there a way to create animated page turn effects from within Acrobat or in combination with Flash?
    I would like to create books, magazines, brochures that have hot links to other pages within the same document, web links, and multimedia capabilities, but which display animated page turns. Something along the style of http://page-flip.com/products.htm
    Ideally, I would like to create the documents in various programs, and then turn them into a PDF with the hot links and multimedia capabilities. I then want them to display as a Flash video with the animated, realistic page turn effects, along with pagination and zoom controls.
    There are software programs available that will do this but they cost big $$$$. Is there a way to export/print/save a PDF file to a SWF format and automatically have the page turn effects added?
    I have CS4 with Acrobat Pro and Flash Pro. I found a couple of Flash extension that appear to do this but they are clumsy to use and I am not very experienced with Flash and ActionScript. I am looking for an easy way to accomplish this, hopefully, right from within Acrobat.
    Thanks in advance for your suggestions.
    Dan

    Adobe CS5 support animated Flash and movies in PDF files, you can visit the home page for detail. When it comes to convert PDF to SWF with Page-Flip effect, Adobe didn't work that good. I recommend convert online at http://www.axmag.com/submit.html , this seems to be free.

  • TS3297 I want to buy the double coins from the game subway surfers! But they told me to contact the itunes support! I don't know why it's not working.. Please help! iPhone 4ss

    I want to buy the double coins from the game subway surfers! But they told me to contact the itunes support! I don't know why it's not working.. Please help! iPhone 4ss

    These are user-to-user forums, you are not talking to Apple here. You can contact iTunes support via this page and ask them why the message is appearing : http://www.apple.com/support/itunes/contact/ - click on Contact iTunes Store Support on the right-hand side of the page, then probably Purchases, Billing & Redemption

  • Is there a way that you can copy and paste blade effects from one clip to the other so that the cuts are an exact duplicate of each other?

    Is there a way that you can copy and paste blade effects from one clip to the other so that the cuts are an exact duplicate of each other?

    The same cuts that I have in this clip that i performed with the blade tool, I want to duplicate, copye, paste and apply to another clip. I want the cuts to mimic and be an exact same. I wish i could highlight the clip, click copy and then highlight the other clip and then click paste and the cuts apply.

  • Fade Effect from Spry Table

    In the tutorial provided by Adobe it shows one how to create
    a dynamic link list that triggers an events region. I want to know
    is can you insert a fade in Spry effect on a Spry region detail
    that is triggered from a Spry table repeat object? I placed an
    onClick function on the Div that houses the Spry region but the
    image in the Spry Detail region fades in only after it blinks in at
    100%. So the effect is only working a split second after the image
    appears at 100% then snaps to 0% and fades to 100%. What is the
    correct method for using spry effects from Spry Region Table Links
    to a targeted DIV or Spry region detail?

    So this example is exactly what I am looking for, however,
    when one uses images instead of simple text I think it fouls up the
    smoothness of the code presented here. My problem is it works,
    however, if you click through the images back and forth eventually
    the image fades out to 0%. I am guessing this it could be related
    to a preloading and cache issue? Or does this code handle spry
    details that load in images differently?
    http://www.megalomedia-inc.com/clients/bob/print.html
    Click print item 1 and 2 back and forth to create the error.
    Any insight on how to make this run smoothly would be greatly
    appreciated and when I am done with this AJAX application I will
    share it with the SPRY community.

  • How to handle both single click and double click from mouse

    hey,
    I looked in past threads and didn't get a proper answer for capturing both single and double click from the mouse.
    in most applications the single click action does not interfere with the double click action, for example in a text editor, single click sets the cursor in between the text, double click marks a word, triple click marks a sentence, they do not bother each other, they all can happen first the single then the double and then the triple, but what if i have a very distinct action for each of the actions, the e.getClickCount() returns every time the number of clicks and if i use
    if(e.getClickCount()==1)
        doSingleClick();
    if(e.getClickCount()==2)
        doDoubleClick();it will always do first the single click and then the double click, which works fine with the example i gave, but not with what i want to do, so i was thinking to over come this that i will use another thread to run my tasks if dt has past since the last click and by the last click counts to perform the correct action and go to sleep until the next mouse click notify it, what do you think?
    run this to get what i mean...
    package blah;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MouseClickTest {
         static long previousTime = System.currentTimeMillis();
         public static void main(String[] args) {
              JPanel panel = new JPanel();
              JButton component = new JButton("Hit me, please");
              component.addMouseListener(new MouseAdapter(){
                   public void mouseClicked(MouseEvent me){
                        if(me.getClickCount()==1)
                             System.out.println("Now I will do single click action");
                        if(me.getClickCount()==2)
                             System.out.println("Now I will do DOUBLE click action");
    //                    System.out.println("Click count: " + me.getClickCount());
              panel.add(component);
              Launcher.launch(panel);
    package blah;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class Launcher {
         public static JFrame launch (Container contents, String title, Color backgroundColor) {
              JFrame frame = new JFrame (title);
              if (backgroundColor != null) {
                   frame.setBackground (backgroundColor);
                   contents.setBackground (backgroundColor);
              } else {
                   frame.setBackground (contents.getBackground());
              frame.getContentPane().add (contents, BorderLayout.CENTER);
              frame.pack();
              frame.addWindowListener (new WindowAdapter() {
                   public void windowClosing (WindowEvent e) {
                        System.exit (0);
              frame.setVisible (true);
              return frame;
         public static JFrame launch (Container contents, String title)      {
              return launch (contents, title, null);
         public static JFrame launch (Container contents, Color backgroundColor) {
              return launch (contents, contents.getClass().getName(), backgroundColor);
         public static JFrame launch (Container contents) {
              return launch (contents, contents.getClass().getName());
    }

    Read my comments and solution in this posting; [http://forums.sun.com/thread.jspa?forumID=57&threadID=705244]
    and then choose a better design for your application.

  • Batch remove an effect from all clips in a timeline

    This has probably been asked a hundred zillion times, but is there a way to batch remove an effect from all clips in a timeline?

    I saw that there, but was hoping to remove just unsharp mask from all the clips but keep colour correction effects.

  • I'm trying to open sound effects from the recource page and there's no waveform

    I'm trying to open sound effects from the recource page and there's no waveform

    What version of Audition are you talking about?  Going from memory, there was a change to how things worked (starting at CS6 maybe?) from their being a "resource centre" to a "Download sound effects and more" link on the help menu.  Exactly where that leaves owners of earlier versions would, I think, be a question for Adobe, not a user forum (though there are some pretty clever people who visit here.

  • New TDS rate effective from 1 oct 2009

    Hi,
    As I am new in SAP can somebody please tell me how to configure new TDS rates in SAP.
    As the new rates are effective from 1 oct 2009, I want to know step by step configuration as how many tax types needs to created and what rates to be maintained against them.
    Please explain in detail as I don't know much about withholding tax
    Thanks in Anticipation.
    Regards,
    Shruti

    Hi shruthi,
    Please note the following Points:-
    Your Question contain 2 Parts.
    1) Functional Knowledge
    2) Applying the functional Knowledge in SAP.
    for the above my suggession is as follows:-
    1). Find out the reliable source from which tax rates are available (It may be through any registered website or through any ready recoknor tax Books).
    2) With regard to Configuring the same in SAP require a configuration knowledge as well testing the cofiguration setting.
      There are Building Blocks available in SAP Library which you can try out.
    regards
    N.Kumar

  • Project Effective from Date

    Hi,
    As soon as i create a new project using Project quick entry screen,the key member for project manager "effective from date" is getting set automatically which is not providing the actual project start date...when i try to alter it..itz not allowing the same employee name...
    how can i overcome this issue...plz help me
    thanks a lot in advance

    Hi Preety,
    When u create new project then in setup quick entry page u define project manager
    if ur project start date and project manger date is different then your project is not approve
    if u want to overcome this solution then u assign other project manger give the start date as your project date above in your eg. you must define project manger as 1 - jun -2010 and give the end date of this project manger as 15 - jun -2010 and assign your project manger to 16 - jun -2010 so your new project manger which is assign in 16 - jun - 2010 it's effected after 15 - june - 2010
    in project module project start date and project manager date must be require same without this u can not approve your project.
    nil
    Project Manager

Maybe you are looking for

  • Need help on Point of Sale application communicate to POS Terminal

    Hi Everyone, I have developed POS application in forms 6i. i need to communicate to POS Terminal for verify payment. If anyone have a solution how to use ocx/dll for POS terminal please help me in this regards. my email : [email protected] Thanks All

  • I upgrade from LR3 to LR5 and the basic panel is the old format...does not have the new sliders that

    and the basic panel is the old format...does not have the new sliders that were introduced in LR 4. Using Windows 7 if that matters. still seeing fill light and recovery instead of shadows and highlights thanks jp

  • Enhance button causes whole picture to turn green or red (with Pics)

    I import the pictures from my new Nikon D5000 in jpg format just fine. The problem lies whenever I try to enhance the images - here is a screen shot of the result I get: http://imgur.com/TVFiz.png Any solution to this? Would like to keep on using iPh

  • Batch for material in plant already exists

    Hi ,           When create a goods reciept for material ABBBBB in plant X001 and sloc 0001 for the first time in a day , system automatically creates a batch number . When I try to create a goods reciept for the same material in same plant/sloc combi

  • Xcode 6 playground error

    I just installed Xcode 6 beta 6, but as soon as I create any playground I get the message "Playground execution terminated because the process stopped unexpectedly." I can't do anything without this dialogue instantly reappearing. I can't find any re