import java.awt.*; import javax.swing.*;
import java.awt.event.*;
class Year{
static int days;
Year(){
days = 365;
}
Year(int y){
days = y;
}
public static void getDays(){
JOptionPane.showMessageDialog(null,"The year has " + days + " days.");
}
}
class LeapYear{
static int days;
LeapYear(){
days=366;
}
public static void getDays(){
JOptionPane.showMessageDialog(null,"The year has " + days + " days.");
}
}
public class UseYear{
public static void main(String args[]){
JFrame f=new JFrame();
JLabel lab=new JLabel("Enter Year");
final JTextField text=new JTextField(20);
JButton b=new JButton("Get");
JPanel p=new JPanel();
p.add(lab);
p.add(text);
p.add(b);
f.add(p);
f.setVisible(true);
f.pack();
b.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
Year year=new Year();
LeapYear lyear=new LeapYear();
String y=text.getText();
int yy=Integer.parseInt(y);
if(yy%4==0){
lyear.getDays();
}else{
year.getDays();
}
}
});
}
}
I am getting the following errors:
2 warnings found:
File: C:\Users\mercy\Documents\CIS131_Fall2011\Year.java [line: 59]
Warning: The static method getDays() from the type LeapYear should be accessed in a static way
File: C:\Users\mercy\Documents\CIS131_Fall2011\Year.java [line: 63]
Please help!
Warning: The static method getDays() from the type Year should be accessed in a static way


Sign In
Create Account


Back to top









