2 Replies Latest reply: Nov 24, 2006 2:36 AM by 807607 RSS

    Order numbers from biggest to smallest

    807607
      hello
      I'm pretty new to java, just started this week

      I trying to order a set of numbers inputed by a textfield from biggest to smallest and display in order, using swing. I'm sure its pretty standard, i was trying to create the textfiles with a cycle but was unable to do it so i declare the individually...this is the code i have so far

      Can anyone point in the right direction???

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.JOptionPane;
      public class Numeros extends JPanel{
           
          private Rectangle mBox = new Rectangle(100, 100, 20, 30);
          // text fields for numbers
          private JTextField Num = new JTextField(5);
          private JTextField Num2 = new JTextField(5);
          private JTextField Num3 = new JTextField(5);
          private JTextField Num4 = new JTextField(5);
          private JTextField Num5 = new JTextField(5);
            // a button to allow the user to update the
          
          
          private JButton mMoveButton = null;
                
          public Numeros(){
                super();
                
                try{
                     
                     
                     mMoveButton= new JButton("Ordenar");
                               }catch(Exception e){
                               mMoveButton= new JButton("???");
                               }
                          mMoveButton.addActionListener(new ActionListener(){
                               
                               public void actionPerformed(ActionEvent e){
                               int m;
                               int n= Integer.parseInt(Num.getText());
                               int n2= Integer.parseInt(Num2.getText());
                               
                               repaint();
                               }});
                              
                       
                       add(new JLabel("Number:"));add(Num);
                       add(new JLabel("Number:"));add(Num2);
                       add(new JLabel("Number:"));add(Num3);
                       add(new JLabel("Number:"));add(Num4);
                       add(new JLabel("Number:"));add(Num5);
                       add(mMoveButton);
                          }
                               
          public static void main(String[] args) {
               JPanel mipanel= new Numeros();
               JFrame Marco= new JFrame();
               Marco.setContentPane(mipanel);
               Marco.setSize(300,300);
               Marco.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               Marco.setVisible(true);
          
           
           
                     }
              
           
                
           }