Q:

How to add multiple items to apopup menu in java?

I am developing a java application for a inventory management system.i used weblaf lookandfeel for designing.
i added a statusbar and added a button to statusbar named notification and i can see a notification popup menu by
clicking the button.i wrote this code to find min level items,
public void low() {

    try {
        ResultSet rs = Database.getConnection().executeQuery("SELECT name FROM detail WHERE qty<=100");
        while (rs.next()) {
            System.out.println(rs.getString("name"));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
} 

Now i need to all the low level items to notification popup,How to do this correctly.Hightly appriciate your help.

A:

Your Popup, which is a Swing UI component should display the list of names. What you are doing here is printing them out on the console. Rewrite the low method as follows, to get a list of all the names:
public List<String> low() {
    ArrayList<String> items = new ArrayList<>();
    try {
        ResultSet rs = Database.getConnection().executeQuery("SELECT name FROM detail WHERE qty<=100");
        while (rs.next()) {
            items.add(rs.getString("name"));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return items;
}

Then you can fill your popup with the items of the list.

