Forums Register Login

How to write a custom alert window?

+Pie Number of slices to send: Send
Hi all, I am Chaitanya, I am working on a small swing application. Its a billing application. There is a button named "add to cart". When the user clicks this button the details of the current item are stored in a bean and bean is added to a ArrayList. There is another button named "show items". When the user clicks on this button an alert window (JOptionPane.showMessageDialog()) must open showing a list of items selected by the user.

I can spawn another window and show the details, but I dont want it like that. Or at least that newly spawned window must have properties like alert windows. Means, until and unless this window is closed the parent window must be disabled.

How can I do this? Thank you all in advance. Have a good day.
+Pie Number of slices to send: Send
 

How can I do this?



What's wrong with the solution you mentioned, JOptionPane.showMessageDialog(...) ?
+Pie Number of slices to send: Send
Hi Mr. Darryl, I'm unable to understand how to do it with message dialog.

JOptionPane.showMessageDialog("this", ::The Array List must go here:: );

how to include the following code there

+Pie Number of slices to send: Send
JOptionPane#showMessageDialog accepts an Object message. Because of this, you can pass any visual component as a message too, not just text.
In your case, you will need to convert your POJO list to a corresponding visual type. JList or JTable or something else depending on your requirement.

1) Take your POJO list
2) Build visual component from the list
3) Invoke JOptionPane#showMessageDialog passing this visual component as the "message"
+Pie Number of slices to send: Send
Thanks Mr. Maneesh, I ll try and let you know.
+Pie Number of slices to send: Send
JOptionPane is smart enough to display an array by showing each element of the array on its own line, and is also smart enough to use the toString() of the array element for the displayed text.
+Pie Number of slices to send: Send
Darryl,
The OP modified/clarified his requirement as a code comment in the second post

//this must be printed on the pane with a button besides every row to delete the row if the user mistakenly enters wrong data.

 
+Pie Number of slices to send: Send
Oops, missed that. Thanks for pointing it out.
+Pie Number of slices to send: Send
Hi all, I tried what Mr. Maneesh said. It worked fine. But there is a problem with the button. Its not getting displayed in the JTable. Some id javax.swing.JButton[0,0,0x0,......] is getting printed. I'm unable to get a visual component.

Whats the problem here? Thank you all in advance.
+Pie Number of slices to send: Send
Check out Rob Camick's Table Button Column.
+Pie Number of slices to send: Send
I have checked it, some what hard to understand.
New rule: no elephants at the chess tournament. Tiny ads are still okay.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2611 times.
Similar Threads
Need an idea regarding my billing application.
put javascript method in body tag and its not returning anything
adding a SelectItem object at particular index position in java.util.list
GUI Design
Form Resubmitting problem.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:52:28.