The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 337 Weeks Ago, 1 Day Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
import java.awt.*;
import javax.swing.*;
public class MyGUIProj{
public static void main(String[] args) {
JFrame frame = new MyFrame(); //line 1
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MyFrame extends JFrame {
private JLabel resultLabel, titleLabel;
private JButton submitButton;
private ActionListener listener;
private JPanel buttonPanel, labelPanel;
private int n;
public MyFrame(){
n = 0;
setSize(500, 500); //line 4 titleLabel = new JLabel("pushes:"); resultLabel = new JLabel("0");
labelPanel = new JPanel();
labelPanel.add(titleLabel);
labelPanel.add(resultLabel);
add(labelPanel, BorderLayout.NORTH);
listener = new MyListener(); submitButton = new JButton("Push Me!");
buttonPanel = new JPanel();
buttonPanel.add(submitButton);
submitButton.addActionListener(listener); //line 5
add(buttonPanel, BorderLayout.CENTER);
}
class MyListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
n += 2;
resultLabel.setText(Integer.toString(n));
}
}
}
When the submitButton is pressed 3 times,
the output of
System.out.println(resultLable.getText()); NEED HELP PLEASE
----------- ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly