Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: sir please help me how make sure addbutton, save button, or other

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Location
    Bangalore
    Posts
    15
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default sir please help me how make sure addbutton, save button, or other

    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.font.*;
    import javax.swing.event.*;
    import javax.swing.Action;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JPanel;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
     
    import java.util.Calendar;
     
    public class Cvs extends JFrame implements ActionListener {
     
    	private static final long serialVersionUID = 1L;
     
     
    	static private int slno,wayBillNo,pcs;
    	static private double weight;
    	static private String destination,consigneeName,receivedBy,statusSescription,refefence,relation;
    	static private Calender sendingDate,statusDeliveryDate;
    	private JPanel panel;
     
    	static JButton  addButton,editButton,saveButton,exitButton;
    	static JTextField label1,label2,label3,label4,label5;
    	static JLabel first,second,thard,four,five;
     
    	public Cvs() {
     
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setTitle("Works PLace");
    		setSize(1350,750);
    		setResizable(false);
    		setLocationRelativeTo(null);
     
    		panel = new JPanel();
    		setSize(1350,750);
    		panel.setLayout(null);
     
    		JMenuBar bar = new JMenuBar();
    		JMenu file = new JMenu("File");
    		JMenuItem close = new JMenuItem("Close");
    		JMenuItem save = new JMenuItem("Save");
    		JMenuItem saveas = new JMenuItem("Saveas");
    		JMenuItem print = new JMenuItem("Print");
     
    		JMenu edit= new JMenu("Edit");
    		JMenuItem copy=new JMenuItem("Copy");
    		JMenuItem past=new JMenuItem("Past");
    		JMenuItem delete=new JMenuItem("Delete");
    		JMenuItem allselect=new JMenuItem("AllSelect");
     
    		JMenu help = new JMenu("Help");
    		JMenuItem about = new JMenuItem("About");
    		JMenuItem shortcut = new JMenuItem("ShortCut");
     
    		file.add(close);
    		file.add(save);
    		file.add(saveas);
    		file.add(print);
     
    		edit.add(copy);
    		edit.add(past);
    		edit.add(delete);
    		edit.add(allselect);
     
    		help.add(about);
    		help.add(shortcut);
     
     
    		first=new JLabel("Customers Address");
    		first.setSize(200,170);
    		first.setLocation(10,0);
     
    		second=new JLabel("Issue Of Date");
    		second.setSize(200,170);
    		second.setLocation(450,0);
     
    		thard=new JLabel("Inward AWB");
    		thard.setSize(170, 298);
    		thard.setLocation(10,0);
     
    		four=new JLabel("Issue AWB");
    		four.setSize(200,170);
    		four.setLocation(450, 68);
     
    		five=new JLabel("Reference");
    		five.setSize(160, 450);
    		five.setLocation(10,0);
     
    		addButton = new JButton("Add");
    		addButton.setSize(90,50);
    		addButton.setLocation(15, 550);
     
    	    editButton = new JButton("Edit");
    	    editButton.setSize(90,50);
    	    editButton.setLocation(110,550);
     
    	    saveButton = new JButton("Save");
    	    saveButton.setSize(90, 50);
    	    saveButton.setLocation(205,550);
     
    	    exitButton = new JButton("Exit");
    	    exitButton.setSize(90,50);
    	    exitButton.setLocation(300,550);
     
    	    label1 = new JTextField();
    	    label1.setSize(250,65);
    	    label1.setLocation(150,70);
    	    label1.setFont(new Font("Arial", Font.CENTER_BASELINE,12));
    	    label1.setEditable(true);
     
    	    label2 = new JTextField();
    	    label2.setSize(150,30);
    	    label2.setLocation(550,70);
    	    label2.setFont(new Font("Arial", Font.BOLD,12));
    	    label2.setEditable(true);
     
    	    label3 = new JTextField();
    	    label3.setSize(150,30);
    	    label3.setLocation(150,140);
    	    label3.setFont(new Font("Arial", Font.BOLD,24));
    	    label3.setEditable(true);
     
    	    label4 = new JTextField();
    	    label4.setSize(150,30);
    	    label4.setLocation(550,140);
    	    label4.setFont(new Font("Arial", Font.BOLD,24));
    	    label4.setEditable(true);
     
    	    label5 = new JTextField();
    	    label5.setSize(150,30);
    	    label5.setLocation(150,210);
    	    label5.setFont(new Font("Arial", Font.BOLD,24));
    	    label5.setEditable(true);
     
    	    panel.add(label1);
    	    panel.add(label2);
    	    panel.add(label3);
    	    panel.add(label4);
    	    panel.add(label5);
    	    panel.add(addButton);
    	    panel.add(editButton);
    	    panel.add(saveButton);
    	    panel.add(exitButton);
    	    panel.add(first);
    	    panel.add(second);
    	    panel.add(thard);
    	    panel.add(four);
    	    panel.add(five);
     
    	    add(panel);
     
     
    	    addButton.addActionListener(this);
    	    editButton.addActionListener(this);
    	    saveButton.addActionListener(this);
    	    exitButton.addActionListener(this);
     
     
    		add(panel);
    		bar.add(file);
    		setJMenuBar(bar);
    		bar.add(edit);
    		bar.add(help);
     
    	}
     
     
    	@Override
    	public void actionPerformed(ActionEvent e) {
     
     
    			if(e.getSource()==exitButton){
    				System.exit(0);
     
     
    	}
    }
    }
    Attached Images Attached Images
    Last edited by pbrockway2; June 25th, 2013 at 06:17 PM. Reason: code tags added


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: sir please help me how make sure addbutton, save button, or other

    Please use code tags. Please state your question or problem in the body of the post. Your attempt at stating what you need in the thread title has been chopped into oblivion. You want help making sure the buttons do what?

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Location
    Bangalore
    Posts
    15
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: sir please help me how make sure addbutton, save button, or other

    yes sir i want to make sure the buttons please advice

    --- Update ---

    the exit button is working but i don't how to code for other button

  4. #4
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: sir please help me how make sure addbutton, save button, or other

    I've added code tags. The idea is that you put [code] at the start of a section of code and [/code] at the end. That way the code will be readable when it appears here on a web page.

    ---

    Have a look at How to Use Buttons, Check Boxes, and Radio Buttons in Oracle's Tutorial.

    When applying those ideas to your own problem, start small. Have just a single button and as few other components as possible. Then, if you get stuck, there won't be so much code for people to read. Once you have a single button handling events as you intend you can apply the same ideas to the others.

  5. #5
    Junior Member
    Join Date
    Jun 2013
    Location
    Bangalore
    Posts
    15
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: sir please help me how make sure addbutton, save button, or other

    pbrockway2@ thnkQ sir i will better try our way...

    --- Update ---

    pbrockway2@ could you please tell me how to code for actionPerformed for save Button actually i am beginner in this field, i don't have idea....

  6. #6
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    987
    Thanks
    6
    Thanked 206 Times in 182 Posts

    Default Re: sir please help me how make sure addbutton, save button, or other

    I can't speak for others here - but, honestly, I can't comment without seeing some code. It really doesn't matter if what you've tried "works" or not: it matters a great deal what you've tried and what you have understood about button event handlers. Remember, you haven't actually said *what*you are trying to save.

Similar Threads

  1. Button to save data in text fields to a File
    By puuts in forum What's Wrong With My Code?
    Replies: 10
    Last Post: May 24th, 2013, 10:07 AM
  2. save button in java
    By donzii in forum What's Wrong With My Code?
    Replies: 4
    Last Post: December 20th, 2012, 07:57 AM
  3. How to save Image into a package by JButton save?
    By justyStepi in forum AWT / Java Swing
    Replies: 1
    Last Post: May 12th, 2012, 07:02 PM
  4. Dear sir
    By sandeep_mca in forum Member Introductions
    Replies: 1
    Last Post: February 11th, 2011, 08:37 AM