• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

java swing jtextfield jbutton using serialization and deserialization

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Someone help me to complete this program. I want to store data in this form using serialization and deserialization.


public class College_Form extends JFrame implements ActionListener {
JTextField tf1, tf2, tf3, tf4;
JButton b1, b2, b3;
JLabel l1, l2, l3, l4, l5;

College_Form() {

l5 = new JLabel("NETAJI SUBHAS INSTITUTE OF TECHNOLOGY");
l5.setForeground(Color.red);
l5.setFont(new Font("Arial", Font.BOLD, 25));
l5.setAlignmentX(TOP_ALIGNMENT);

l1 = new JLabel("Name:");
l2 = new JLabel("Department:");
l3 = new JLabel("Dues:");
l4 = new JLabel("Roll:");

tf1 = new JTextField(20);
tf2 = new JTextField(20);
tf3 = new JTextField(10);
tf4 = new JTextField(10);

b1 = new JButton("Save");
b2 = new JButton("Clear");
b3 = new JButton("Cancel");



add(l5);
add(l1);
add(tf1);
add(l2);
add(tf2);
add(l3);
add(tf3);
add(l4);
add(tf4);
add(b1);
add(b2);
add(b3);

setLayout(null);
l5.setBounds(100, 10, 700, 100);
l1.setBounds(250,140,100,50);
l2.setBounds(250,190,100,50);
l3.setBounds(250,250,100,50);
l4.setBounds(250,300,100,50);
tf1.setBounds(350, 150, 300, 20);
tf2.setBounds(350, 200, 200, 20);
tf3.setBounds(350, 260, 100, 20);
tf4.setBounds(350, 310, 100, 20);
b1.setBounds(200, 400, 100, 30);
b2.setBounds(350, 400, 100, 30);
b3.setBounds(500, 400, 100, 30);

setVisible(true);
setSize(800, 600);

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
}
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Based on the code you posted, there could be (at a minimum) 3 problem areas
1) Listening to button click
2) Obtaining all data and wrapping it up in an object
3) Actually storing the data

Which area are you facing problems? What have you tried so far? Please TellTheDetails
 
sanjeet kunal
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't no how to fetch data in file by clicking on save button using serialization.So, can you write code for this.
 
Maneesh Godbole
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sanjeet kunal wrote:I don't no how to fetch data in file by clicking on save button using serialization.So, can you write code for this.


Can I? Sure. Will I. Nope.
Thats not how things work here at the Ranch.
Show us what you have tried, tell us where you are stuck and we will help point you in the right direction.

Lets break down your problem into smaller problems and tackle them one at a time
You say your data is in a file. Do you know how to write code to read a file?
If not, recommended reading: https://docs.oracle.com/javase/tutorial/essential/io/

reply
    Bookmark Topic Watch Topic
  • New Topic