Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JList and closing frames

 
Bron Czimes
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi everyone,
got a coupla questions, if you can answer them

I was just wondering if there is an option, when using a JList, to make the listbox a little bit wider, so that the items in the listbox can have a little bit of "breathing space". At the moment, all I seem to be able to get to work, is putting spaces around the actual items, before I put them into the list box. Surely theres a better way of doing it!!

And the second question.... when a user clicks the X to close a frame, I'm giving them the option to cancel the action if they made a mistake. I'm using a dialog box to do this. I've been fiddling with Dialog.YES_OPTION and Dialog.NO_OPTION to determine what the user wants before closing the frame but it doesn't seem to be working. It keeps giving me an error about boolean and int types.
code is

Thanks for your help.
Bron
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked into your first question a little bit. Thought that by using a custom ListCellRenderer you could somehow specify the margin between the text and the border of a JLabel, but looking at the API I am not sure this is even possible.

As far as your 2nd problem, the code below does what you expect.

 
Bron Czimes
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i tried that but modified it in a GUI format.
ie


but now it closes the whole program regardless of which button i press.
???
 
Bron Czimes
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ah, not to worry, i've worked it out
thanks for your help Gregg
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic