• 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
  On 15/05/2013 at 04:45, Ezaura said:

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

    • FxSound 1.1.34 Beta by Razvan Serea FxSound (formerly DFX Audio Enhancer / FxSound Enhancer) is now free, making high-quality audio enhancement accessible to everyone. Designed for all PC sound systems, from average setups to audiophile-grade equipment, it offers automatic or fully customizable processing. As automatic or customizable as you want, it utilizes the highest-grade processing to deliver more volume, better equalization, and a wider, deeper sound. For the serious audiophiles, FxSound gives you the tools to adjust the FxSound Effects and EQ to your exact preferences. Turn FxSound on and immediately hear the difference in sound quality. FxSound is ideal for budget audiophiles, music lovers, gamers, transcriptionists, Netflix enthusiasts, and more. It’s particularly beneficial for those relying on quiet laptop speakers or low-quality audio hardware. As a free tool, FxSound excels in boosting volume, enhancing bass, and improving sound quality. No other free EQ for Windows matches its ease of use. FxSound Is Now Completely Free and Unrestricted FxSound Pro is now free for everyone, not just those who can afford it. Get free and unrestricted access to better sound today. FxSound is now entirely supported by users. Click here to donate to help fund continued development and improvements to FxSound. FxSound 1.1.34 Beta changelog: System tray context menu width is fixed and device names are adjusted to width Prompt to save the preset in a new name if changes are made and new preset is selected If preferred device is not connected then it is disabled and greyed out from selection until connected again Application crash dump is saved on unhandled exceptions Download: FxSound 1.1.34 Beta | ARM64 | ~70.0 MB (Open Source) View: FxSound Home Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Can you get a brand new (not refurb) device like this, but with 2025 hardware, for $266? Under $300? No? If you can, it must have the worst specs otherwise (4gb ram, 1366x768 12in lcd screen, 256gb spinning hard drive, etc.). Please show me this sub-$300 2025 laptop that is better than what the article shows.
    • Cjam 2.0 by Razvan Serea Cjam is a lightweight and fast MP3 editor for Windows that lets you cut, join, and edit MP3 files without re-encoding. This means your audio quality remains untouched, and edits happen instantly. Cjam is ideal for quick, lossless edits—whether you're trimming music, combining tracks, or preparing audio for learning tools or podcasts. It features batch processing, scripting support, cue and playlist file handling, and a simple interface. Cjam is perfect for anyone who needs efficient MP3 editing without the complexity of full audio suites. Cjam requires a PC running Windows 10 or later and Microsoft .NET 6.0 or later. Key features for Cjam: No Re-encoding: Edit MP3 files without losing quality. Cut and Join MP3: Easily cut, trim, and combine MP3 tracks. Batch Processing: Edit multiple files at once for faster workflows. Scriptable Interface: Automate tasks with a custom command language. Cue and Playlist Support: Handle CUE and playlist files for seamless audio management. Fast and Lightweight: Quick processing with minimal system resources. Lossless Audio Editing: Ensure your edits don't affect audio quality. Simple User Interface: Clean, intuitive design for easy navigation. File Format Support: Works with MP3, Cjam-specific file formats (CJAMC, CJAMJ, CJAM). Cjam 2.0.0.0 fixes: Fixed a bug where the folder list was not updating on the vmp3 screen Download: Cjam 2.0 | 1.3 MB (Freeware) Links: Cjam Home Page | Cjam Manual | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Honestly, i either don't care, mind, use, or had any problem with those. 11 is really good for me, has a lot of little refinements, looks great, if i wanted to tweak/fix it's behavior i would with a range of tools, and wouldn't come back to the 2010's looking Win 10 even at gunpoint.
  • Recent Achievements

    • Dedicated
      Cole Multipass earned a badge
      Dedicated
    • Week One Done
      Alexander 001 earned a badge
      Week One Done
    • Week One Done
      icecreamconesleeves earned a badge
      Week One Done
    • One Year In
      PAC0 earned a badge
      One Year In
    • One Month Later
      PAC0 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      572
    2. 2
      +FloatingFatMan
      189
    3. 3
      ATLien_0
      188
    4. 4
      Skyfrog
      115
    5. 5
      Som
      109
  • Tell a friend

    Love Neowin? Tell a friend!