I have 3 conditions (3 menu items in menu). In those 3 items, how to get one menu item selected as soon as the frame opens and displays the content of that item by default?
Later on if we select other menu items, then corresponding contents on the frame will be displayed as usual. I have written very lengthy code for this GUI, so unable to paste here. But got stuck up at this point.
Simply invoke the
actionPerformed()method of yourActionListenerafter your GUI is fully constructed. This is particularly easy if you have implemented theActioninterface, as shown in How to Use Actions.Using this example, add the following line near
setVisible()to simulate adding a few random nodes to the graph:To simulate clicking a button, this line simulates adding a selected node: