• 0

jOptionPane Dropdown menu help


Question

Hello.

I have a String [], which provides the options for a jOptionPane dropdown menu selection.

With two identical OptionPanes, each asking the same question using the same possible choices, is there a way of removing an option from the dropdown list once it has been already selected? So you have 2 votes from a,b,c,d. Once "a" is selected from the first dropdown selection window, I want the second one to display only options b,c,d.

Hope I didn't do too badly in my explanation. Thanks

Link to comment
https://www.neowin.net/forum/topic/1152298-joptionpane-dropdown-menu-help/
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hmm I'm just a beginner too, but I think in regards to your idea I'd have to create a huge amount of String[] variables for all different cases. I should have made clearer the choices amount to more than just 4. Or are you trying to say something else? Essentially I do want to remove an element from the array but theory is all I have.

Currently I have 2 string for the selections, and an if statement - selection1 = selection2, redo vote2 (selection2).

  • 0

Hmm I'm just a beginner too, but I think in regards to your idea I'd have to create a huge amount of String[] variables for all different cases. I should have made clearer the choices amount to more than just 4. Or are you trying to say something else? Essentially I do want to remove an element from the array but theory is all I have.

Currently I have 2 string for the selections, and an if statement - selection1 = selection2, redo vote2 (selection2).

when you say string[] variables do you mean an array of chars or an array of strings? If it's an array of chars you should probably just call it a string variable and drop the [] (awaits angry java nerds? idk). In any case whether its an array of chars or strings it really doesn't matter.

basically you repopulate the second jOptionPane by adding all the elements of an array as long as that element doesn't match the selected text of the first jOptionPane; a simple logical 'if' statement can compare them. I'm not sure how iteration works in Java but however you iterate through an array... do that... and during iteration compare that element to the selected item if there is a match don't add that to the second list. The array can be any size you want as can the elements.

If this still doesn't make sense then perhaps I truly don't understand what you're asking and in that case I'm sorry.

This topic is now closed to further replies.
  • Posts

    • LAV Filters 0.82.0 by Razvan Serea LAVFSplitter is a multi-format media splitter that uses libavformat (the demuxing library from ffmpeg) to demux all sorts of media files. LAV Splitter is a Souce Filter/Splitter required to demux the files into their separate elementary streams. LAV Audio and Video Decoder are powerful decoders with a focus on quality and performance, without any compromises. Supported Formats: MKV/WebM, AVI, MP4/MOV, MPEG-TS/PS (including basic EVO support), FLV, OGG, and many more that are supported by ffmpeg! LAV Filters are based on ffmpeg and libbluray and is aimed to offer a all-around solution to perfect playback of file-based Media as well as Blu-rays. LAV Filters 0.82.0 changelog: LAV Splitter NEW: Support for demuxing Dolby Vision Enhancement Layer streams NEW: Support for Animated WebP images Changed: When demuxing Blu-ray discs, Dolby Vision metadata is available on the primary video stream LAV Video NEW: Support for Animated WebP images Changed: Hardware decoding support for DVDs has been removed Download: LAV Filters 0.82.0 | 15.5 MB (Open Source) View: LAV Filters Website | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • For some reason when EU forced Microsoft to allow users to change the default browser and search provider in Windows (also no ads for Office and the likes) - it was good. But when it comes to Apple - then it's bad. BTW, Apple would have gone out of business if Microsoft wasn't pressed by US government several decades ago. 😉
    • I understand Microsoft's intention here, at least I think I do. There have been so many printer driver related problems over the years due to OEM printer drivers not be compatible with the latest Windows update, that Microsoft wants to eliminate those by controlling the printer driver updates and keeping them compatible with the latest Windows update. That is okay as far it goes, but what it can do is put limitations on printers that wouldn't be there with OEM drivers since the OEM printer drivers are not universal drivers. It's a tradeoff and one can only hope it doesn't turn all Windows printers into $69 Brother printers.
  • Recent Achievements

    • One Month Later
      Sopa flores earned a badge
      One Month Later
    • First Post
      StaticMatrix earned a badge
      First Post
    • Week One Done
      StaticMatrix earned a badge
      Week One Done
    • Rookie
      lamborghiniv10 went up a rank
      Rookie
    • One Month Later
      pinnclepd earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      505
    2. 2
      PsYcHoKiLLa
      207
    3. 3
      +Edouard
      156
    4. 4
      Steven P.
      87
    5. 5
      ATLien_0
      79
  • Tell a friend

    Love Neowin? Tell a friend!