Can someone please help? Why am I getting this error massage from code[incompatible types: MainMenu cannot be converted to java.awt.event.ActionListener]
Here is the CODE - import java.awt.*;
-
import javax.swing.*;
-
import javax.swing.table.*;
-
import java.awt.event.*;
-
-
public class MainMenu extends JFrame //implements ActionListener
-
{
-
private DefaultTableModel model;
-
private JTable table;
-
private JScrollPane scroll;
-
private JPanel panel;
-
private JPanel mainMenuCard;
-
private JLabel titleLbl;
-
private JButton manageCustomerBtn,manageSaleBtn,manageSaleBookBtn,makeOrderBtn,viewCartBtn,exitBtn;
-
-
-
public MainMenu()
-
{
-
super("MainMenu");
-
setSize(500,400);
-
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
createGUI();
-
setVisible(true);
-
-
titleLbl=new JLabel("MAIN MENU");
-
manageCustomerBtn=new JButton("Manage Customer");
-
manageSaleBtn=new JButton("Manage Sale");
-
manageSaleBookBtn=new JButton("Manage Sale Book");
-
makeOrderBtn=new JButton("Make Order");
-
viewCartBtn=new JButton("View Cart");
-
exitBtn=new JButton("Exit");
-
-
manageCustomerBtn.addActionListener(this);
-
manageSaleBtn.addActionListener(this);
-
manageSaleBookBtn.addActionListener(this);
-
makeOrderBtn.addActionListener(this);
-
viewCartBtn.addActionListener(this);
-
exitBtn.addActionListener(this);
-
-
c.gridwidth=1;
-
c.gridheight=1;
-
c.weightx=0;
-
c.weighty=0;
-
c.fill=GridBagConstraints.HORIZONTAL;
-
-
addComponent(titleLbl,0,0,0,0,0,0);
-
addComponent(manageCustomerBtn,0,1,0,0,0,0);
-
addComponent(manageSaleBtn,0,2,0,0,0,0);
-
addComponent(manageSaleBookBtn,0,3,0,0,0,0);
-
addComponent(makeOrderBtn,0,4,0,0,0,0);
-
addComponent(viewCartBtn,0,5,0,0,0,0);
-
addComponent(exitBtn,0,6,0,0,0,0);
-
-
}
-
-
public void createGUI()
-
{
-
model=new DefaultTableModel();
-
-
int rows = 5,cols = 5;
-
model=new DefaultTableModel(rows,cols);
-
-
// Object[] colNames={"Customer Id", "Customer Name","Customer Phone", "Customer Email"};
-
// model = new DefaultTableModel(null,colNames);
-
-
Object[][] data={};//{1,"aaa","2015-10-08"},{2,"bbb","2015-10-08"}};
-
Object[] colNames={};//"john","james","joseph"};
-
model = new DefaultTableModel(data,colNames)
-
{
-
public boolean isCellEditable(int row,int col)
-
{
-
return false;
-
}
-
};
-
-
table=new JTable(model)
-
{
-
boolean[] cellEditables={false,true,true};
-
public boolean isCellEditable(int row,int col)
-
{
-
return cellEditables[col];
-
}
-
};
-
-
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
-
-
scroll=new JScrollPane(table);
-
scroll.setPreferredSize(new Dimension(350,250));
-
panel=new JPanel();
-
panel.add(scroll);
-
add(panel);
-
}
-
-
public static void main(String[] args)
-
{
-
new MainMenu();
-
}
-
}
-
-
a pic of the problem is attached.
Thanks in advance.
3 5572
Your main menu must implement an interface (and its methods), else it cannot be used as an action listener.
Just remove your comments in line 6 (see below) and use auto-complete to create the missing methods. - public class MainMenu extends JFrame implements ActionListener
sorry, please how I use auto-complete to create the missing method? This is new to me. Thanks in advance.
In Eclipse, the word "MainMenu" would be underlined. You just right-click (not left-click) on it and an option pops up with "create missing methods". Then you can find the new methods at the end of your program.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: linux newbie |
last post by:
is there any java expert could tell me what the problem below and
explain the code to me, your explanation is greatly appreciated :)
static Class class$java$awt$event$ActionListener;
...
|
by: Dennis Schulz |
last post by:
Hi all,
the following programm is supposed to check for login and password
with inbuilt linux functions. in line 57 and 64 there are erorrs:
incompatible types in asignment. whats wrong with...
|
by: Randy Fraser |
last post by:
What is the proper way of declaring an override on a button click event for
a base form.
I am getting " Cannot bind an event handler to the 'Click' event because it
is read only." listed in the...
|
by: v4vijayakumar |
last post by:
Whats wrong with the code in line no. 7?!
#cat test3.c
#include <stdio.h>
int main(int argc, char *argv)
{
int ia1 = {0, 1, 2};
int ia2;
ia2 = ia1;
|
by: fei.liu |
last post by:
I have the following source code. It seems wierd to me why gca's value
cannot be reassigned. It's afterall a pointer and has a pointer value.
I am aware that the standard says it's not allowed. But...
|
by: hgoren |
last post by:
hi everyone,
I am having a trouble in my code. It gives the following error:
Incompatible types in assignment of 'int*' to int
Here is my code:
#include<stdio.h>
#include<stdlib.h>...
|
by: pandaemonium |
last post by:
I have two quick problems with the code I am writing:
First, I define a struct of char arrays (strings) and then try accessing the same. I get an "incompatible types in assignment" error:
struct...
|
by: kardon33 |
last post by:
I am getting a "error: incompatible types in assignment" error and cant figure out why? I am trying to set lastRow to row at the end of the code snippet.
int row;
int lastRow;
size_t...
|
by: Jatinmalhotra |
last post by:
import java.io.*;
class CAcc
{
String name=new String;
long accno;
char type;
double Bal;
CAcc(String Name,long Accno,char Type,double bal)
{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |