Results 1 to 3 of 3
- 09-24-2012, 05:29 PM #1
Member
- Join Date
- Sep 2012
- Posts
- 3
- Rep Power
- 0
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); } } } }
- 09-25-2012, 04:13 AM #2
Re: How can I show the max value of employee sales row when i click the max button
Cross posted and much discussed:
How Can I Transfer The Data To Other Txtfield When Click Submit - Java | Dream.In.Code
dbWhy do they call it rush hour when nothing moves? - Robin Williams
-
Re: How can I show the max value of employee sales row when i click the max button
Thanks for the warning Darryl!
Similar Threads
-
Button click GUI question
By ZambonieDrivor in forum New To JavaReplies: 2Last Post: 11-29-2010, 07:48 AM -
How to show new window after click on button
By javahoush in forum SWT / JFaceReplies: 4Last Post: 12-29-2009, 09:25 AM -
How can I display on Button click?
By ntagrafix in forum New To JavaReplies: 3Last Post: 11-04-2009, 12:05 AM -
JPanel: Show Tooltip on click
By knuth in forum New To JavaReplies: 2Last Post: 10-01-2009, 04:46 PM -
deselecting a button after the click.
By ramsrocker in forum New To JavaReplies: 10Last Post: 02-15-2009, 06:52 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks