-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnextprevswing
More file actions
66 lines (63 loc) · 1.46 KB
/
nextprevswing
File metadata and controls
66 lines (63 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.util.*;
import java.io.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
class prnext extends JFrame implements ActionListener
{JTextField jtprv;JTextField jtnext;JTextField jtcurr;JLabel jlcurr,jlprv,jlnext;
JButton jb1,jb2;
prnext()
{ setLayout(null);
jlcurr=new JLabel("Enter the number");
jlcurr.setBounds(200,200,150,30);
jtcurr=new JTextField();
jtcurr.setBounds(350,200,50,30);
add(jtcurr);
add(jlcurr);
jtnext=new JTextField();
add(jtnext);
jlnext=new JLabel("Next Number");
add(jlnext);
jlnext.setBounds(200,300,150,30);
jtnext.setBounds(350,300,50,30);
jtprv=new JTextField();
add(jtprv);
jlprv=new JLabel("Previous Number");
jlprv.setBounds(200,400,150,30);
jtprv.setBounds(350,400,50,30);
add(jlprv);
setVisible(true);
setSize(600,600);
jb1=new JButton("OK");
add(jb1);
jb2=new JButton("CANCEL");
add(jb2);
jb1.setBounds(200,500,100,50);
jb1.addActionListener(this);
jb2.setBounds(300,500,100,50);
jb2.addActionListener(this);
}
public void actionPerformed(ActionEvent a)
{
if(a.getSource()==jb1)
{
String s=jtcurr.getText();
int n=Integer.parseInt(s);
int next=n+1;
int prev=n-1;
jtnext.setText(String.valueOf(next));
jtprv.setText(String.valueOf(prev));
} else
{
jtprv.setText("");
jtnext.setText("");
jtcurr.setText("");
}
}
}
public class prevnext {
public static void main(String[] args) {
// TODO Auto-generated method stub
prnext ob=new prnext();
}
}