Results 1 to 3 of 3
  1. #1
    opeboy is offline Member
    Join Date
    Sep 2012
    Posts
    3
    Rep Power
    0

    Default How can I show the max value of employee sales row when i click the max button

    Java Code:
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    
    
    class newframe extends JFrame{
    
    	JButton submit = new JButton("Submit");
    	
    	public static void main(String[] args) {
    		newframe frameTabel = new newframe();
    		//frameTabel.setLayout(new GridLayout(1,2));
    	}
    
    	JTextField id = new JTextField(15);
    	JTextField name = new JTextField(15);
    	JTextField sales = new JTextField(15);
    	DisplayPanel displayPanel = new DisplayPanel();
    
    
    	newframe(){
    		super("Monthly Sales");
    		setSize(350,300);
    		setLocation(500,280);
    		
    		JPanel bigPanel = new JPanel(new BorderLayout());
    		bigPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(),"Monthly Sale"));
    		
    		bigPanel.add(new InputPanel(), BorderLayout.NORTH);
    		bigPanel.add(displayPanel);
    		bigPanel.add(new ButtonPanel(), BorderLayout.SOUTH);
    
    		submit.addActionListener(new ActionListener(){
    			public void actionPerformed(ActionEvent e){
    				displayPanel.addFiedls();
    			}
    		});
    		
    	    getContentPane().add(bigPanel); 
    		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		setVisible(true);
    	
    	}
    	
    	// the panels to input the data that will be in the NORTH region
    	class InputPanel extends JPanel {
    		
    		InputPanel() {
    			super(new GridLayout(4, 3));
    			add(new JLabel("Employee Id:"));
    			add(id);
    			add(new JLabel("Employee Name:"));
    			add(name);
    			add(new JLabel("Employee Sales:"));
    			add(sales);
    			// center Sumbit button
    			JPanel p = new JPanel(new GridLayout(1,2));
    			p.add(new JLabel(""));
                p.add(submit);
    			add(p);
    		}
    	}
    	// the output fields which will be in the CENTER region
    	class DisplayPanel extends JPanel {
    		
    		// the 3 headers
    		String[] header = {"Employee ID", "Employee Name", "Employee Sales"};
    		// the 3 X 5 labels to display
    		JLabel[][] labels = new JLabel[5][3];
    		// index which row I am at
    		int row = 0;
    		
    		DisplayPanel() {
    			// 6 rows and 3 columns
    			super(new GridLayout(6, 3, 5, 5));
    			// add the 3 header
    			for(int i = 0; i < header.length; ++i)
    				add(new JLabel(header[i]));
    			// the other JLabel. Each row
    			for(int i = 0; i < labels.length; ++i) {
    				// each columns
    				for(int j = 0; j < labels[i].length; ++j) {
    					labels[i][j] = new JLabel("");
    					labels[i][j].setOpaque(true);
    					labels[i][j].setBackground(Color.WHITE);
    					add(labels[i][j]);
    				}
    			}
    		}
    		// adds the new entry into the next one
    		void addFiedls() {
    			if(row == labels.length)
    				return;              // sorry no more room
    			labels[row][0].setText(id.getText());
    			labels[row][1].setText(name.getText());
    			labels[row][2].setText(sales.getText());
    			++row;
    		}
    	}
    	
    	// the 3 buttons in the SOUTH region
    	class ButtonPanel extends JPanel implements ActionListener {
            JButton min, max, exit;
            
    		ButtonPanel() {
    			min = new JButton("MIN");
    			min.addActionListener(this);
    			add(min);
    			max = new JButton("MAX");
    			max.addActionListener(this);
    			add(max);
    			exit = new JButton("EXIT");
    			exit.addActionListener(this);
    			add(exit);
    		}
    		
    		public void actionPerformed(ActionEvent e) {
    			Object o = e.getSource();
    			
    			
    			if(o == min) {
    				
    				// the min button as been hit
    		}
    			else if(o == max) {
    				
    				
    						
    				// the max button has been hit
    			}
    			else {
    				// the exit button has been hit
    				System.exit(0);
    			}
    		}
    	}
    }
    How can I show the max value of employee sales row when i click the max button-java.jpg

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: How can I show the max value of employee sales row when i click the max button

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Button click GUI question
    By ZambonieDrivor in forum New To Java
    Replies: 2
    Last Post: 11-29-2010, 08:48 AM
  2. How to show new window after click on button
    By javahoush in forum SWT / JFace
    Replies: 4
    Last Post: 12-29-2009, 10:25 AM
  3. How can I display on Button click?
    By ntagrafix in forum New To Java
    Replies: 3
    Last Post: 11-04-2009, 01:05 AM
  4. JPanel: Show Tooltip on click
    By knuth in forum New To Java
    Replies: 2
    Last Post: 10-01-2009, 05:46 PM
  5. deselecting a button after the click.
    By ramsrocker in forum New To Java
    Replies: 10
    Last Post: 02-15-2009, 07:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •