Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i bulid two frame and want to use homepage button go to homepage frame then use back menu go back to menu frame this is

i bulid two frame and want to use homepage button go to homepage frame then use back menu go back to menu frame this is the code for me but only homepage button work i try to use same method (java program)(menu frame code ):

public class Menu {

private JFrame frame;

/**

* Launch the application.

*/

public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {

public void run() {

try {

Menu window = new Menu();

window.frame.setVisible(true);

} catch (Exception e) {

e.printStackTrace();

}

}

});

}

public Menu() {

initialize();

setVisible(true);

}

private void setVisible(boolean b) {

// TODO Auto-generated method stub

}

private void initialize() {

frame = new JFrame();

frame.setBounds(100, 100, 733, 442);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().setLayout(null);

btnNewButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

frame.dispose();

Homepage sc= new Homepage();

sc.Screen();

}

});

homepage code

public class Homepage {

private JFrame frame;

private JLabel lblNewLabel_1;

private JLabel lblNewLabel_2;

private JLabel lblNewLabel_3;

/**

* Launch the application.

*/

public static void Screen() {

EventQueue.invokeLater(new Runnable() {

public void run() {

try {

Homepage window = new Homepage();

window.frame.setVisible(true);

} catch (Exception e) {

e.printStackTrace();

}

}

});

}

public void clock() {

Calendar cal=new GregorianCalendar();

int month=cal.get(Calendar.MONTH);

int year=cal.get(Calendar.YEAR);

int day=cal.get(Calendar.DAY_OF_MONTH);

int minute=cal.get(Calendar.MINUTE);

int hour=cal.get(Calendar.HOUR);

lblNewLabel_1.setText("Time: "+ hour+":" +minute +" Date"+ year+"/ "+month+"/"+day);

}

public Homepage() {

initialize();

setVisible(true);

clock();

}

private void setVisible(boolean b) {

}

/**

* Initialize the contents of the frame.

*/

private void initialize() {

frame = new JFrame();

frame.setBounds(100, 100, 733, 442);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.getContentPane().setLayout(null);

JLabel lblNewLabel_4 = new JLabel("name list");

lblNewLabel_4.setFont(new Font("Century Schoolbook", Font.BOLD | Font.ITALIC, 21));

lblNewLabel_4.setBounds(173, 168, 382, 60);

frame.getContentPane().add(lblNewLabel_4);

JButton btnNewButton = new JButton("Back");

btnNewButton.addActionListener(new ActionListener() {

public void actionPerformed(ActionEvent arg0) {

frame.dispose();

}

});

help me about how to make two button both work

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

6. Identify characteristics of whiteness.

Answered: 1 week ago

Question

e. What are notable achievements of the group?

Answered: 1 week ago