🔒 Closed GUI error

  • Thread starter Thread starter Deleted member 1079204
  • Start date Start date
Status
Not open for further replies.
D

Deleted member 1079204

hi guys, may error na lumalabas sa loob ng Action Listener ng button, pero meron naman ng main method sa class na nilagay ko like yung patient.main(null);, nasa baba po yung code, mat mali ba sa flow or sa pag declare

"The method main(null) is undefined for the type JButton"

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

public class dashBoard extends JFrame {
public void userDashboard() {
JButton patient = new JButton("JButton");
patient.setBounds(30, 50, 150, 40);
patient.addActionListener(new ActionListener() {
Override
public void actionPerformed(ActionEvent e) {
patient.main(null);
}
});
JButton labs = new JButton("Labs");
labs.setBounds(200, 50, 150, 40);
labs.addActionListener(new ActionListener() {
Override
public void actionPerformed(ActionEvent e) {
labs.main(null);
}
});
JButton branches = new JButton("Branches");
branches.setBounds(370, 50, 150, 40)
branches.addActionListener(new ActionListener() {
Override
public void actionPerformed(ActionEvent e) {
branches.main(null);
}
});

JButton medicine = new JButton("Medicine");
medicine.setBounds(540, 50, 150, 40);
medicine.addActionListener(new ActionListener() {
Override
public void actionPerformed(ActionEvent e) {
medicine.main(null);
}
});
JButton appointment = new JButton("Appointment");
appointment.setBounds(90, 100, 150, 40);
appointment.addActionListener(new ActionListener() {
Override
public void actionPerformed(ActionEvent e) {
appointment.main(null);
}
});

JButton suppliesAndEquipment = new JButton("Supplies & Equipment");
suppliesAndEquipment.addActionListener(new ActionListener() {
Override
public void actionPerformed(ActionEvent e) {
equipmentSupplies.main(null);
}
});
JButton exit = new JButton("Close");
exit.setBounds(550, 466, 150, 40);
exit.addActionListener(new ActionListener() {
Override
public void actionPerformed(ActionEvent e) {
dispose();
}
});
add(patient);
add(exit);
add(suppliesAndEquipment);
add(appointment);
add(branches);
add(labs);
setSize(1000, 1000);
setVisible(true);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setLayout(null);
}

public static void main(String args[]) {
dashBoard dashboard = new dashBoard();
dashboard.userDashboard();
}
}
 
Nasan ang error ts? maraming jbutton dyan.
Edit: ito ang error ts.

Java:
JButton patient = new JButton("JButton");
patient.setBounds(30, 50, 150, 40);
patient.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
patient.main(null); //This part is when the error occured.
 
Nasan ang error ts? maraming jbutton dyan.
Edit: ito ang error ts.

Java:
JButton patient = new JButton("JButton");
patient.setBounds(30, 50, 150, 40);
patient.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
patient.main(null); //This part is when the error occured.
thanks dito, variable naming pala, salamat!
 
Status
Not open for further replies.

About this Thread

  • 3
    Replies
  • 253
    Views
  • 2
    Participants
Last reply from:
Unknown user

Online now

Members online
1,074
Guests online
827
Total visitors
1,901

Forum statistics

Threads
2,276,991
Posts
28,973,649
Members
1,229,682
Latest member
JhayPureno13
Back
Top