I have a JPanel in which I add a number of custom JButtons. When I put the JPanel into a showMessageDialog window, I don't manage to get any value from the pressing of one of the buttons. This is the window:
And this is the code:
public static void mainMenu() throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException{
JPanel panel = new JPanel(null);
JButton button1 = new JButton();
button1.setText("Conteggio Tweet"); button1.setSize(300, 80); button1.setLocation(100, 200); button1.setFont(new Font("Verdana", Font.ITALIC, 20));
JButton button2 = new JButton();
button2.setText("Top #Hashtag"); button2.setSize(300, 80); button2.setLocation(100, 300); button2.setFont(new Font("Verdana", Font.ITALIC, 20));
JButton button3 = new JButton();
button3.setText("Top Words"); button3.setSize(300, 80); button3.setLocation(450, 200); button3.setFont(new Font("Verdana", Font.ITALIC, 20));
JButton button4 = new JButton();
button4.setText("Top Utenti"); button4.setSize(300, 80); button4.setLocation(450, 300); button4.setFont(new Font("Verdana", Font.ITALIC, 20));
JButton button5 = new JButton();
button5.setText("Sentiment analysis"); button5.setSize(650, 80); button5.setLocation(100, 400); button5.setFont(new Font("Verdana", Font.ITALIC, 20));
JLabel titolo = new JLabel();
titolo.setText("Select an option:"); titolo.setSize(650, 80); titolo.setLocation(250, 70); titolo.setFont(new Font("Verdana", Font.BOLD, 30));
panel.add(button2); panel.add(button1); panel.add(button3); panel.add(button4); panel.add(button5); panel.add(titolo);
JOptionPane.showMessageDialog(null, panel, "Twitter", 0, icon);
}
How can I retrieve a value from the buttons? Thank you.