Question
I asked this earlier but I have narrowed down the problem. Here is my code: public class mainScreen extends JPanel implements ActionListener { JFrame mainFrame
I asked this earlier but I have narrowed down the problem. Here is my code:
public class mainScreen extends JPanel implements ActionListener { JFrame mainFrame = new JFrame("Task Board"); JPanel mainPanel = new JPanel(); JButton editButton; taskBoardModel userBoard; public void mainScreen(taskBoardModel getBoard) { userBoard = getBoard; JFrame mainFrame = new JFrame("Task Board");
this.drawMenu(userBoard); this.drawColumns(userBoard.columns); } public void drawMenu(taskBoardModel userBoard) { JPanel menuPanel = new JPanel(); mainFrame.setLayout(new BorderLayout()); mainPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); menuPanel.setLayout(new BorderLayout()); JPanel menuLeft = new JPanel(); JPanel menuRight = new JPanel(); menuLeft.setLayout(new FlowLayout()); menuRight.setLayout(new FlowLayout()); JLabel selectLabel = new JLabel("Select Project: "); JComboBox selectBox = new JComboBox(); selectBox.addItem(""); JButton editButton = new JButton("Edit"); JButton saveButton = new JButton("Save"); JButton deleteButton = new JButton("Delete"); //JButton editButton = new JButton("Edit"); editButton.addActionListener(this); menuLeft.add(selectLabel); menuLeft.add(selectBox); menuLeft.add(saveButton); menuLeft.add(editButton); menuLeft.add(deleteButton); JButton loadButton = new JButton("Load..."); JButton createButton = new JButton("Create new"); JButton logoutButton = new JButton("Logout"); menuRight.add(loadButton); menuRight.add(createButton); menuRight.add(logoutButton); menuPanel.add(menuLeft,BorderLayout.WEST); menuPanel.add(menuRight,BorderLayout.EAST); menuPanel.setBorder(BorderFactory.createLineBorder(Color.black)); userBoard.columns.get(0).columnName = "WORK DAMNITG"; mainFrame.add(menuPanel,BorderLayout.NORTH); mainFrame.add(mainPanel,BorderLayout.CENTER); mainFrame.setSize(1000, 1000); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setVisible(true); } public void actionPerformed(ActionEvent ae) { if(ae.getSource() == editButton) { JOptionPane.showMessageDialog(null, "I am happy.");
} } My problem seems to be that the editButton isn't working. I have added an actionlistener and I wrote an actionlistener method, but it still doesnt do anything when i click it.
Thanks.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started