Untitled

 avatar
unknown
plain_text
3 years ago
1.1 kB
2
Indexable
package p2;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class task1 {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		JFrame frame = new JFrame("Task 1");
		JPanel bp = new JPanel();
		JButton but1 = new JButton("100");
		JButton but2 = new JButton("0");
		bp.add(but1);
		bp.add(but2);
		frame.setSize(300, 200);
		frame.add(bp);
		
		but1.addActionListener(new ActionListener() {
			@SuppressWarnings("deprecation")
			@Override
			public void actionPerformed(ActionEvent e1) {
				//int h = 16;
				int tmp = Integer.parseInt(but2.getLabel());
				
					tmp++;
					but2.setLabel(""+tmp);
				
					
				
			}
			
		});
		
		but2.addActionListener(new ActionListener() {
			@SuppressWarnings("deprecation")
			@Override
			public void actionPerformed(ActionEvent e1) {
				//int h = 16;
				int tmp = Integer.parseInt(but1.getLabel());
				
					tmp--;
					but1.setLabel(""+tmp);
				
					
				
			}
			
		});
        frame.setVisible(true);
		
	}
}	
Editor is loading...