Buona sera sto realizzando un'applicazione per un progetto ora ho questa schermata:
Ma quando clicco su modifica profilo o esci nel menu non funziona sapete aiutarmi a risolvere questo problema?
Grazie in anticipo
Java:
package GuiFood;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.ImageIcon;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JTextField;
import javax.swing.JSeparator;
import javax.swing.JButton;
import Classi.Controller;
import javax.swing.JToolBar;
import javax.swing.JTextArea;
import javax.swing.JMenuBar;
public class Menu extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
protected Object frame1;
private JTextField txtCosaPreferisciMangiare;
Controller ctrl;
public Menu(final Controller ctrl) {
setTitle("Login");
this.getContentPane().setBackground(new Color(255, 165, 0));
this.setResizable(false);
this.setBounds(100, 100, 747, 504);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.getContentPane().setLayout(null);
this.ctrl=ctrl;
{
JPanel panel = new JPanel();
panel.setBackground(new Color(255, 140, 0));
panel.setForeground(new Color(255, 140, 0));
panel.setBounds(0, 0, 532, 41);
getContentPane().add(panel);
panel.setLayout(null);
{
JSeparator separator_Ricerca = new JSeparator();
separator_Ricerca.setForeground(Color.WHITE);
separator_Ricerca.setBounds(6, 23, 248, 12);
panel.add(separator_Ricerca);
}
{
txtCosaPreferisciMangiare = new JTextField();
txtCosaPreferisciMangiare.setText("Cosa preferisci mangiare?");
txtCosaPreferisciMangiare.setSelectionColor(Color.LIGHT_GRAY);
txtCosaPreferisciMangiare.setForeground(Color.BLACK);
txtCosaPreferisciMangiare.setFont(new Font("Times New Roman", Font.ITALIC, 14));
txtCosaPreferisciMangiare.setDisabledTextColor(Color.LIGHT_GRAY);
txtCosaPreferisciMangiare.setColumns(10);
txtCosaPreferisciMangiare.setBorder(null);
txtCosaPreferisciMangiare.setBackground(new Color(255, 140, 0));
txtCosaPreferisciMangiare.setBounds(6, 6, 248, 20);
panel.add(txtCosaPreferisciMangiare);
}
{
JButton btnCerca = new JButton("Cerca");
btnCerca.setForeground(new Color(255, 165, 0));
btnCerca.setFocusable(false);
btnCerca.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./ricerca.png")), 10, 10));
btnCerca.setBounds(255, 4, 79, 25);
panel.add(btnCerca);
btnCerca.addActionListener(this);
}
{
JButton btnFiltri = new JButton("Filtri");
btnFiltri.setForeground(new Color(255, 165, 0));
btnFiltri.setFont(new Font("Lucida Grande", Font.PLAIN, 16));
btnFiltri.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./filtri.png")), 21, 21));
btnFiltri.setFocusable(false);
btnFiltri.setBounds(416, 2, 108, 25);
panel.add(btnFiltri);
btnFiltri.addActionListener(this);
}
}
{
JPanel panel_2 = new JPanel();
panel_2.setBackground(new Color(255, 165, 0));
panel_2.setBounds(0, 41, 532, 58);
getContentPane().add(panel_2);
panel_2.setLayout(null);
{
JToolBar menuBar = new JToolBar();
menuBar.setBackground(new Color(255, 165, 0));
menuBar.setBounds(0, 0, 518, 58);
panel_2.add(menuBar);
JButton antipasti = new JButton("anitpasti");
antipasti.setForeground(new Color(255, 165, 0));
antipasti.setBackground(new Color(250, 240, 230));
antipasti.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
menuBar.add(antipasti);
antipasti.setFocusable(false);
antipasti.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./antipasti.png")), 32, 32));
antipasti.setPreferredSize(new Dimension(100,40));
antipasti.addActionListener(this);
JButton primi = new JButton("primi");
primi.setForeground(new Color(255, 165, 0));
primi.setBackground(Color.WHITE);
primi.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
menuBar.add(primi);
primi.setFocusable(false);
primi.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./primi.png")), 32, 32));
primi.setPreferredSize(new Dimension(100,40));
primi.addActionListener(this);
JButton secondi = new JButton("secondi");
secondi.setForeground(new Color(255, 165, 0));
secondi.setBackground(Color.WHITE);
secondi.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
menuBar.add(secondi);
secondi.setFocusable(false);
secondi.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./secondi.png")), 32, 32));
secondi.setPreferredSize(new Dimension(100,40));
secondi.addActionListener(this);
JButton contorni = new JButton("contorni");
contorni.setForeground(new Color(255, 165, 0));
contorni.setBackground(Color.WHITE);
contorni.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
menuBar.add(contorni);
contorni.setFocusable(false);
contorni.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./contorni.png")), 32, 32));
contorni.addActionListener(this);
JButton dolci = new JButton("dolci");
dolci.setForeground(new Color(255, 165, 0));
dolci.setBackground(Color.WHITE);
dolci.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
menuBar.add(dolci);
dolci.setFocusable(false);
dolci.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./dolci.png")), 32, 32));
dolci.setPreferredSize(new Dimension(100,40));
dolci.addActionListener(this);
JButton bevande = new JButton("bevande");
bevande.setForeground(new Color(255, 165, 0));
bevande.setBackground(Color.WHITE);
bevande.setFont(new Font("Lucida Grande", Font.PLAIN, 10));
menuBar.add(bevande);
bevande.setFocusable(false);
bevande.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./bevande.png")), 32, 32));
bevande.setPreferredSize(new Dimension(100,40));
bevande.addActionListener(this);
}
}
{
JPanel panel_3 = new JPanel();
panel_3.setBackground(new Color(255, 140, 0));
panel_3.setBounds(0, 99, 532, 382);
getContentPane().add(panel_3);
panel_3.setLayout(null);
JTextArea ProductPane = new JTextArea();
ProductPane.setBackground(new Color(255, 140, 0));
ProductPane.setBounds(0, 0, 532, 382);
panel_3.add(ProductPane);
}
{
JPanel panel_1 = new JPanel();
panel_1.setBackground(new Color(255, 165, 0));
panel_1.setBounds(532, 0, 215, 481);
getContentPane().add(panel_1);
panel_1.setLayout(null);
JLabel username = new JLabel("Nickname Utente");
username.setBounds(6, 19, 138, 16);
panel_1.add(username);
JSeparator separator_1 = new JSeparator();
separator_1.setForeground(Color.WHITE);
separator_1.setBounds(0, 34, 215, 12);
panel_1.add(separator_1);
JSeparator separator_2 = new JSeparator();
separator_2.setForeground(Color.WHITE);
separator_2.setBounds(0, 436, 215, 12);
panel_1.add(separator_2);
JButton completeOrder = new JButton("Acquista");
completeOrder.setForeground(new Color(255, 165, 0));
completeOrder.setBounds(63, 446, 99, 29);
completeOrder.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./carrello.png")), 25, 25));
panel_1.add(completeOrder);
completeOrder.addActionListener(this);
JPanel panel = new JPanel();
panel.setBackground(new Color(255, 165, 0));
panel.setBounds(169, 3, 40, 32);
panel_1.add(panel);
JMenuBar menuBar = new JMenuBar();
panel.add(menuBar);
JMenu Servizi = new JMenu("");
menuBar.add(Servizi);
Servizi.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./Menu.png")), 18, 18));
JMenuItem ModificaProfilo = new JMenuItem("Modifica Profilo");
ModificaProfilo.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./Modifica.png")), 20, 20));
Servizi.add(ModificaProfilo);
JMenuItem Uscire = new JMenuItem("Uscire");
Servizi.add(Uscire);
Uscire.setIcon(scaleImageIcon(new ImageIcon(Menu.class.getResource("/Menu./Uscire.png")), 25, 25));
}
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getActionCommand().equals("Filtri"))
{
//ctrl.Filtri();
}
else if(e.getActionCommand().equals("Acquista"))
{
ctrl.visualizzazioneFattura();
}
else if(e.getActionCommand().equals("Servizi"))
{
if(e.getActionCommand().equals("Modifica Profilo"))
{
ctrl.ModificaProfilo();
}
else if(e.getActionCommand().equals("Uscire")) {
ctrl.distruggiSessione();
}
}
}
}
Grazie in anticipo
Ultima modifica: