*when i pressed on the button which name(Next) (will navigate through all the students saved in the Array List)
*i finished the java application to create a frame.but i want to ask can i solve the problem by use muselistener?
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.border.LineBorder;
i couldnt attached the photo.
*i finished the java application to create a frame.but i want to ask can i solve the problem by use muselistener?
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.border.*;
import java.util.ArrayList;
public class Student extends JFrame{
public JTextField StId=new JTextField(" ");
public JTextField StNm=new JTextField(" ");
public JTextField StAv=new JTextField(" ");
public JButton nt=new JButton("Next");
public JButton nw=new JButton("New");
public JButton ad=new JButton("Add");
Student(){
JPanel p1=new JPanel(new GridLayout(1,4,20,20));
p1.add(new JLabel("File Name"));
p1.add(new JTextField(" "));
JButton Ld=new JButton("Load");
p1.add(Ld);
JButton Se=new JButton("Save");
p1.add(Se);
add(p1,BorderLayout.NORTH);
JPanel p2=new JPanel(new GridLayout(4,2,20,20));
p2.add(new JLabel("Student ID"));
p2.add(StId);
p2.add(new JLabel("Student Full Name"));
p2.add(StNm);
p2.add(new JLabel("Student Average"));
p2.add(StAv);
p2.add(new JLabel("Student Status"));
p2.add(new JComboBox(new Object[]{"freshman","sophomore","junior","senior"}));
add(p2,BorderLayout.CENTER);
JPanel p3=new JPanel(new GridLayout(1,4,20,20));
p3.add(nt);
p3.add(nw);
p3.add(ad);
p3.add(new JLabel(""));
add(p3,BorderLayout.SOUTH);
p3.setBorder(new LineBorder(Color.blue,1));
p2.setBorder(new LineBorder(Color.blue,1));
p1.setBorder(new LineBorder(Color.blue,1));
nt.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
if(e.getClickCount()==1){
StId.setText("1110188");
StNm.setText("samah");
StAv.setText("77.4");
}else if(e.getClickCount()==2){
StId.setText("1110155");
StNm.setText("awad");
StAv.setText("44");
}else{
StId.setText("1145198");
StNm.setText("fatma");
StAv.setText("78.6");
}
}});
}
}
import java.awt.*;
import javax.swing.JFrame;
import javax.swing.border.LineBorder;
public class Main {
public static void main(String[] args){
Student st=new Student();
st.setTitle("StudentFrame");
st.setVisible(true);
st.setLocation(50,50);
st.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
i couldnt attached the photo.