Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown


Ranch Hand
Posts: 15304
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone show me some code that allows for 2 JTextFields in a JOptionPane with 3 custom button choices? I need to have a User Name and PAssword input, but the rest of the app needs to be locked with this option up. So just a JFrame or an Internal Frame won't work for me. Thanks
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here's a possible solution:
  • Create a JPanel with all the input components you need
  • Use the showOptionDialog method and use the JPanel you created as the message

  • When you receive the result, you can get the values of each component individually.
    Like this:

    Just one detail, since all those components are the "message", none of them will start with focus.
    Hope it helps.
    Alas, poor Yorick, he knew this tiny ad:
    Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
      Bookmark Topic Watch Topic
    • New Topic