473,806 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to Populate GUI Fields from JList

38 New Member
I am a beginner here, still in my first Java class, so I hope this question is not so simple as to offend anyone, but I am finishing up my cd inventory program.
Adding some GUI buttons to manipulate data in my JList.
JList is beyond the scope of my class so I am finding help hard to come by.
I only have two weeks of class left, so it is too late to go back to my array now.
It is sink or swim with what I have. :o)

For my question ... I have an ADD button that works like a charm, populates JList from my fields. I am now working on the PREV button to pull the information back to the fields from the previous cd. I have coded and coded but I am obviously doing something wrong because it keeps erroring upon execution.
Compiles fine, but will not run. Keep getting:
Exception in thread "AWT-EventQueue-0" java.lang.Numbe rFormatExceptio n: For input string: ""
at java.lang.Numbe rFormatExceptio n.forInputStrin g(NumberFormatE xception.java:4 8)
at java.lang.Integ er.parseInt(Int eger.java:468)
at java.lang.Integ er.parseInt(Int eger.java:497)
at Inventory2.btnA ddActionPerform ed(Inventory2.j ava:255)
at Inventory2.acce ss$000(Inventor y2.java:10)
at Inventory2$2.ac tionPerformed(I nventory2.java: 155)
at javax.swing.Abs tractButton.fir eActionPerforme d(AbstractButto n.java:1849)
at javax.swing.Abs tractButton$Han dler.actionPerf ormed(AbstractB utton.java:2169 )
at javax.swing.Def aultButtonModel .fireActionPerf ormed(DefaultBu ttonModel.java: 420)
at javax.swing.Def aultButtonModel .setPressed(Def aultButtonModel .java:258)
at javax.swing.pla f.basic.BasicBu ttonListener.mo useReleased(Bas icButtonListene r.java:236)
at java.awt.Compon ent.processMous eEvent(Componen t.java:5517)
at javax.swing.JCo mponent.process MouseEvent(JCom ponent.java:313 5)
at java.awt.Compon ent.processEven t(Component.jav a:5282)
at java.awt.Contai ner.processEven t(Container.jav a:1966)
at java.awt.Compon ent.dispatchEve ntImpl(Componen t.java:3984)
at java.awt.Contai ner.dispatchEve ntImpl(Containe r.java:2024)
at java.awt.Compon ent.dispatchEve nt(Component.ja va:3819)
at java.awt.Lightw eightDispatcher .retargetMouseE vent(Container. java:4212)
at java.awt.Lightw eightDispatcher .processMouseEv ent(Container.j ava:3892)
at java.awt.Lightw eightDispatcher .dispatchEvent( Container.java: 3822)
at java.awt.Contai ner.dispatchEve ntImpl(Containe r.java:2010)
at java.awt.Window .dispatchEventI mpl(Window.java :1791)
at java.awt.Compon ent.dispatchEve nt(Component.ja va:3819)
at java.awt.EventQ ueue.dispatchEv ent(EventQueue. java:463)
at java.awt.EventD ispatchThread.p umpOneEventForH ierarchy(EventD ispatchThread.j ava:242)
at java.awt.EventD ispatchThread.p umpEventsForHie rarchy(EventDis patchThread.jav a:163)
at java.awt.EventD ispatchThread.p umpEvents(Event DispatchThread. java:157)
at java.awt.EventD ispatchThread.p umpEvents(Event DispatchThread. java:149)
at java.awt.EventD ispatchThread.r un(EventDispatc hThread.java:11 0)


Here is my code. Everything works except the Previous Button action event.
Any suggestions?

Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. import javax.swing.*;
  5. import javax.swing.event.*;
  6. import java.text.*;
  7. import java.lang.*;
  8.  
  9. public class Inventory2 extends JFrame
  10. {
  11.     private JLabel cdNameLabel; // name label 
  12.     private JLabel artistLabel; // item number label 
  13.     private JLabel nstockLabel; // units in stock label 
  14.     private JLabel priceLabel; // price each label 
  15.     private JLabel itemLabel; // item number label 
  16.     private JTextField cdNameField; // name display 
  17.     private JTextField artistField; // artist display 
  18.     private JFormattedTextField nstockField; // units in stock display 
  19.     private JFormattedTextField priceField; // price each display 
  20.     private JTextField itemField; // item number display 
  21.     private NumberFormat nstockFormat; // format field and parse numbers 
  22.     private NumberFormat priceFormat; // format field and parse numbers 
  23.     private JButton btnAdd; // first button 
  24.     private JButton btnPrev; // previous button 
  25.     private JButton btnNext; // next button 
  26.     private JButton btnDel; // last button 
  27.     private JButton btnFirst; // first button
  28.     private JButton btnLast; // last button
  29.     private JButton btnModify; // modify button
  30.     private JButton btnSave; // save button
  31.     private JButton btnSearch; // search button
  32.     private JPanel buttonJPanel; // JPanle to hold buttons 
  33.     private JPanel fieldJPanel; // JPanel to hold labels and displays 
  34.     private JPanel fontJPanel; // JPanel to display logo 
  35.     private int currCD; 
  36.     private double total = 0; // variable for total inventory 
  37.     private JList Inventorylist; // JList to take place of old array
  38.     private DefaultListModel listModel;
  39.     private JScrollPane jScrollPanel;  
  40.     private float Invtotal = .00f;
  41.  
  42.     public Inventory2() // create class and method to perform GUI build 
  43.     { 
  44.         initComponents(); 
  45.     } 
  46.  
  47.     private void initComponents() 
  48.     { 
  49.         // create label names 
  50.         cdNameLabel = new JLabel("CD Name:"); 
  51.         artistLabel = new JLabel("Artist:");
  52.         nstockLabel = new JLabel("In Stock:"); 
  53.         priceLabel = new JLabel("Each Item Cost:$"); 
  54.         itemLabel = new JLabel("Item Number:"); 
  55.  
  56.  
  57.         // initial fields
  58.         cdNameField = new JTextField(25);
  59.         cdNameField.setEditable(true);
  60.         artistField = new JTextField(15);
  61.         artistField.setEditable(true);
  62.         nstockField = new JFormattedTextField(nstockFormat);
  63.         nstockField.setEditable(true);
  64.         nstockField.setColumns(5);
  65.         priceField = new JFormattedTextField(priceFormat);
  66.         priceField.setEditable(true);
  67.         priceField.setColumns(5);
  68.         itemField = new JTextField(4);
  69.         itemField.setEditable(true);
  70.  
  71.         // JList
  72.         jScrollPanel = new JScrollPane();
  73.         Inventorylist = new JList(); 
  74.         currCD = 0;
  75.  
  76.  
  77.         // buttons 
  78.         btnAdd = new JButton(); 
  79.         btnNext = new JButton(); 
  80.         btnPrev = new JButton(); 
  81.         btnDel = new JButton();
  82.         btnLast = new JButton();
  83.         btnFirst = new JButton();
  84.         btnModify = new JButton(); 
  85.         btnSave = new JButton();
  86.         btnSearch = new JButton();
  87.  
  88.         getContentPane().setLayout(new FlowLayout());
  89.  
  90.         setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  91.  
  92.  
  93.         // place textFields and labels
  94.  
  95.         //artist
  96.         artistLabel.setText("Artist"); 
  97.         getContentPane().add(artistLabel); 
  98.  
  99.         artistField.setMinimumSize(new Dimension(70,20)); 
  100.         artistField.setPreferredSize(new Dimension(70,20));
  101.         getContentPane().add(artistField); 
  102.  
  103.         // cd name
  104.         cdNameLabel.setText("CD Name"); 
  105.         getContentPane().add(cdNameLabel); 
  106.  
  107.         cdNameField.setMinimumSize(new Dimension(70,20)); 
  108.         cdNameField.setPreferredSize(new Dimension(70,20));
  109.         getContentPane().add(cdNameField);
  110.  
  111.         // copies in stock
  112.         nstockLabel.setText("Copies In Stock"); 
  113.         getContentPane().add(nstockLabel); 
  114.  
  115.         nstockField.setMinimumSize(new Dimension(5,20)); 
  116.         nstockField.setPreferredSize(new Dimension(5,20));
  117.         getContentPane().add(nstockField); 
  118.  
  119.         //price of cd
  120.         priceLabel.setText("Price"); 
  121.         getContentPane().add(priceLabel); 
  122.  
  123.         priceField.setMinimumSize(new Dimension(20,20)); 
  124.         priceField.setPreferredSize(new Dimension(20,20));
  125.         getContentPane().add(priceField); 
  126.  
  127.         //item number of cd
  128.         itemLabel.setText("Item Number"); 
  129.         getContentPane().add(itemLabel); 
  130.  
  131.         itemField.setMinimumSize(new Dimension(5,20)); 
  132.         itemField.setPreferredSize(new Dimension(5,20));
  133.         getContentPane().add(itemField); 
  134.  
  135.  
  136.         // add listeners
  137.  
  138.         btnAdd.setText("Add");
  139.         btnAdd.addActionListener(new ActionListener()
  140.         {
  141.             public void actionPerformed(ActionEvent evt)
  142.             {
  143.                 btnAddActionPerformed(evt);
  144.             }
  145.         });
  146.         getContentPane().add(btnAdd);
  147.  
  148.         // PREVIOUS
  149.         btnPrev.setText("Previous");
  150.         btnPrev.addActionListener(new ActionListener()
  151.         {
  152.             public void actionPerformed(ActionEvent evt)
  153.             {
  154.                 btnAddActionPerformed(evt);
  155.             }
  156.         });
  157.         getContentPane().add(btnPrev);
  158.  
  159.         // NEXT
  160.         btnNext.setText("Next");        btnNext.addActionListener(new ActionListener()
  161.         {
  162.             public void actionPerformed(ActionEvent evt)
  163.             {
  164.                 btnAddActionPerformed(evt);
  165.             }
  166.         });
  167.         getContentPane().add(btnNext);
  168.  
  169.         // SEARCH
  170.         btnSearch.setText("Search");
  171.         btnSearch.addActionListener(new ActionListener()
  172.         {
  173.             public void actionPerformed(ActionEvent evt)
  174.             {
  175.                 btnAddActionPerformed(evt);
  176.             }
  177.         });
  178.         getContentPane().add(btnSearch);
  179.  
  180.         // FIRST
  181.         btnFirst.setText("First");
  182.         btnFirst.addActionListener(new ActionListener()
  183.         {
  184.             public void actionPerformed(ActionEvent evt)
  185.             {
  186.                 btnAddActionPerformed(evt);
  187.             }
  188.         });
  189.         getContentPane().add(btnFirst);
  190.  
  191.         // LAST
  192.         btnLast.setText("Last");
  193.         btnLast.addActionListener(new ActionListener()
  194.         {
  195.             public void actionPerformed(ActionEvent evt)
  196.             {
  197.                 btnAddActionPerformed(evt);
  198.             }
  199.         });
  200.         getContentPane().add(btnLast);
  201.  
  202.         // MODIFY
  203.         btnModify.setText("Modify");
  204.         btnModify.addActionListener(new ActionListener()
  205.         {
  206.             public void actionPerformed(ActionEvent evt)
  207.             {
  208.                 btnAddActionPerformed(evt);
  209.             }
  210.         });
  211.         getContentPane().add(btnModify);
  212.  
  213.         // SAVE
  214.         btnSave.setText("Save");
  215.         btnSave.addActionListener(new ActionListener()
  216.         {
  217.             public void actionPerformed(ActionEvent evt)
  218.             {
  219.                 btnAddActionPerformed(evt);
  220.             }
  221.         });
  222.         getContentPane().add(btnSave);
  223.  
  224.         // DELETE
  225.         btnDel.setText("Delete");
  226.         btnDel.addActionListener(new ActionListener()
  227.         {
  228.             public void actionPerformed(ActionEvent evt)
  229.             {
  230.                 btnAddActionPerformed(evt);
  231.             }
  232.         });
  233.         getContentPane().add(btnDel);
  234.  
  235.  
  236.         // new Jlist model
  237.         listModel = new DefaultListModel();
  238.         Inventorylist.setModel(listModel);
  239.  
  240.         jScrollPanel.setViewportView(Inventorylist);
  241.  
  242.         getContentPane().add(jScrollPanel);
  243.  
  244.         pack();
  245.     }// close
  246.  
  247.  
  248.         private void btnAddActionPerformed(ActionEvent evt)
  249.         {
  250.             // Create cd to add
  251.             CdwArtist newCD = new CdwArtist();
  252.             newCD.setArtist(artistField.getText());
  253.             newCD.setName(cdNameField.getText());    
  254.             newCD.setItemno(Integer.parseInt(itemField.getText()));
  255.             newCD.setNstock(Integer.parseInt(nstockField.getText()));
  256.             newCD.setPrice(Float.parseFloat(priceField.getText()));
  257.  
  258.             // Add cd to list
  259.             listModel.addElement(newCD);
  260.             currCD = listModel.size()-1;  // sets currCD to added index
  261.  
  262.  
  263.             // Clear the text fields after add
  264.             artistField.setText(null);
  265.             cdNameField.setText(null);    
  266.             itemField.setText(null);
  267.             nstockField.setText(null);
  268.          priceField.setText(null);
  269.  
  270.             }// end ADD
  271.  
  272.         private void btnPrevActionPerformed(ActionEvent evt)
  273.         {
  274.             // Grab Previous cd 
  275.             CdwArtist newCD = (CdwArtist) listModel.get( currCD-- );
  276.             newCD.setArtist(artistField.getText());
  277.             newCD.setName(cdNameField.getText());    
  278.             newCD.setItemno(Integer.parseInt(itemField.getText()));
  279.             newCD.setNstock(Integer.parseInt(nstockField.getText()));
  280.             newCD.setPrice(Float.parseFloat(priceField.getText()));        
  281.  
  282.             }// end PREV
  283.  
  284.         // run it
  285.         public static void main(String args[])
  286.         {
  287.         java.awt.EventQueue.invokeLater(new Runnable()
  288.             {
  289.             public void run()
  290.                 {
  291.                 new Inventory2().setVisible(true);
  292.                }
  293.             });
  294.         }
  295.  
  296. } // close class
Jul 29 '07 #1
13 4823
JosAH
11,448 Recognized Expert MVP
According to that stacktrace the problem occurs in one of these lines:

Expand|Select|Wrap|Line Numbers
  1. newCD.setItemno(Integer.parseInt(itemField.getText()));
  2. newCD.setNstock(Integer.parseInt(nstockField.getText()));
  3.  
This indicates that either the itemField or the nstockFied don't contain a valid
integer number. As far as I can see those fields are JTextFields so you should
either supply valid text for those fileds or re-implement this part of your software.

kind regards,

Jos
Jul 29 '07 #2
blazedaces
284 Contributor
java.lang.Numbe rFormatExceptio n.forInputStrin g(NumberFormatE xception.java:4 8)
at java.lang.Integ er.parseInt(Int eger.java:468)
at java.lang.Integ er.parseInt(Int eger.java:497)
at Inventory2.btnA ddActionPerform ed(Inventory2.j ava:255)
Ok, so let's look at the printed error, the problem. If we know what the problem is and where it is we will better know how to solve it.

Now, why does java throw a NumberFormatExc eption? Let's look at the documentation (if I were you, I would make this a habit):
Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format.
Now we know what the problem is, next we'll try and understand where it is. The first place the error is caught inside of your class (as opposed to class Integer) is here: at Inventory2.btnA ddActionPerform ed(Inventory2.j ava:255). So here is that class:

Expand|Select|Wrap|Line Numbers
  1.         private void btnAddActionPerformed(ActionEvent evt)
  2.         {
  3.             // Create cd to add
  4.             CdwArtist newCD = new CdwArtist();
  5.             newCD.setArtist(artistField.getText());
  6.             newCD.setName(cdNameField.getText());    
  7.             newCD.setItemno(Integer.parseInt(itemField.getText()));
  8.             newCD.setNstock(Integer.parseInt(nstockField.getText())); //This is where it says the error shows up.
  9.             newCD.setPrice(Float.parseFloat(priceField.getText()));
  10.  
  11.             // Add cd to list
  12.             listModel.addElement(newCD);
  13.             currCD = listModel.size()-1;  // sets currCD to added index
  14.  
  15.  
  16.             // Clear the text fields after add
  17.             artistField.setText(null);
  18.             cdNameField.setText(null);    
  19.             itemField.setText(null);
  20.             nstockField.setText(null);
  21.          priceField.setText(null);
  22.  
  23.             }// end ADD
  24.  
Quickly, let's take a look at the documentation to know why does Integer.parseIn t(String s) throw that error and it says is throws it because:
"NumberFormatEx ception - if the string does not contain a parsable integer."

I don't know exactly the problem yet, but I'm pretty sure by doing the following you can get to the bottom of it: add System.out.prin t for the strings in the method that undergo parseInt. Change your method to look like this and tell us what you see as the output:

Expand|Select|Wrap|Line Numbers
  1.         private void btnAddActionPerformed(ActionEvent evt)
  2.         {
  3.             // Create cd to add
  4.             CdwArtist newCD = new CdwArtist();
  5.             newCD.setArtist(artistField.getText());
  6.             newCD.setName(cdNameField.getText());    
  7.             newCD.setItemno(Integer.parseInt(itemField.getText()));
  8.                         System.out.println("itemField.getText(): " + itemField.getText());
  9.             newCD.setNstock(Integer.parseInt(nstockField.getText())); //This is where it says the error shows up.
  10.                         System.out.println("nstockField.getText(): " + nstockField.getText());
  11.             newCD.setPrice(Float.parseFloat(priceField.getText()));
  12.  
  13.             // Add cd to list
  14.             listModel.addElement(newCD);
  15.             currCD = listModel.size()-1;  // sets currCD to added index
  16.  
  17.  
  18.             // Clear the text fields after add
  19.             artistField.setText(null);
  20.             cdNameField.setText(null);    
  21.             itemField.setText(null);
  22.             nstockField.setText(null);
  23.          priceField.setText(null);
  24.  
  25.             }// end ADD
  26.  
Hope that works and good luck,

-blazed
Jul 29 '07 #3
no1zson
38 New Member
I do not know how to reply to this. You both seem to indicate that the problem lies in my ADD button action event, but that works fine.

It is not until I coded my PREV button action event that the problem occurs.

Both my nstock and itemno fields are in fact intergers, and my application works without flaw until I coded this PREV button. Does that not indicate a probelm with the PREV button code?
Expand|Select|Wrap|Line Numbers
  1.     private void btnPrevActionPerformed(ActionEvent evt)
  2.         {
  3.             // Grab Previous cd 
  4.             CdwArtist newCD = (CdwArtist) listModel.get( currCD-- );
  5.             newCD.setArtist(artistField.getText());
  6.             newCD.setName(cdNameField.getText());    
  7.             newCD.setItemno(Integer.parseInt(itemField.getText()));
  8.             newCD.setNstock(Integer.parseInt(nstockField.getText()));
  9.             newCD.setPrice(Float.parseFloat(priceField.getText()));        
  10.  
  11.             }// end PREV
All this button should do is take the information from the previous cd and put it back into my text fields for viewing.

It works fine when I enter the information into the fields, hit ADD and enter it into my JList.
Jul 29 '07 #4
JosAH
11,448 Recognized Expert MVP
I do not know how to reply to this. You both seem to indicate that the problem lies in my ADD button action event, but that works fine.

It is not until I coded my PREV button action event that the problem occurs.

Both my nstock and itemno fields are in fact intergers, and my application works without flaw until I coded this PREV button. Does that not indicate a probelm with the PREV button code?
Expand|Select|Wrap|Line Numbers
  1.     private void btnPrevActionPerformed(ActionEvent evt)
  2.         {
  3.             // Grab Previous cd 
  4.             CdwArtist newCD = (CdwArtist) listModel.get( currCD-- );
  5.             newCD.setArtist(artistField.getText());
  6.             newCD.setName(cdNameField.getText());    
  7.             newCD.setItemno(Integer.parseInt(itemField.getText()));
  8.             newCD.setNstock(Integer.parseInt(nstockField.getText()));
  9.             newCD.setPrice(Float.parseFloat(priceField.getText()));        
  10.  
  11.             }// end PREV
All this button should do is take the information from the previous cd and put it back into my text fields for viewing.

It works fine when I enter the information into the fields, hit ADD and enter it into my JList.
You also use that same 'add' method in line 154 or so; as a matter of fact you
use that method for every action when whatever button is pressed. I'm afraid it's
a copy/paste thingy ;-)

kind regards,

Jos
Jul 29 '07 #5
no1zson
38 New Member
You are right, I am a beginner but that is just dumb on my part.
Copy/paste is exactly what I did and did not catch the error until you pointed it out. I wanted to work through one button at a time, so did not change the names when I did it because the new ones were not coded yet and it would error out.

I have however now changed the PREV button, and although the errors have moved down the chain a bit (I am at least in the right button now) they still point to errors with the same lines of code.
Expand|Select|Wrap|Line Numbers
  1. // PREVIOUS
  2.         btnPrev.setText("Previous");
  3.         btnPrev.addActionListener(new ActionListener()
  4.         {
  5.             public void actionPerformed(ActionEvent evt)
  6.             {
  7.                 btnPrevActionPerformed(evt);
  8.             }
  9.         });
  10.         getContentPane().add(btnPrev);
Would the method types be different pulling information from the JList than they were going in? If it were an INT going in, it would be an INT coming back out would it not? The field is coded as such, so I would think nothing would change there. I thought I just had a syntax issue, but it is looking like a bigger problem ... no?
Jul 29 '07 #6
JosAH
11,448 Recognized Expert MVP
You are right, I am a beginner but that is just dumb on my part.
Copy/paste is exactly what I did and did not catch the error until you pointed it out. I wanted to work through one button at a time, so did not change the names when I did it because the new ones were not coded yet and it would error out.

I have however now changed the PREV button, and although the errors have moved down the chain a bit (I am at least in the right button now) they still point to errors with the same lines of code.
Expand|Select|Wrap|Line Numbers
  1. // PREVIOUS
  2.         btnPrev.setText("Previous");
  3.         btnPrev.addActionListener(new ActionListener()
  4.         {
  5.             public void actionPerformed(ActionEvent evt)
  6.             {
  7.                 btnPrevActionPerformed(evt);
  8.             }
  9.         });
  10.         getContentPane().add(btnPrev);
Would the method types be different pulling information from the JList than they were going in? If it were an INT going in, it would be an INT coming back out would it not? The field is coded as such, so I would think nothing would change there. I thought I just had a syntax issue, but it is looking like a bigger problem ... no?
Well, as far as I can see your btnPrevActionPe rformed method suffers from that
same copy/paste virus too: i.e. it too tries to parse an Integer from a JTextField.

I think you should design your prev/next/add/whatever actions first before you
attempt to implement anything at all.

kind regards,

Jos
Jul 29 '07 #7
no1zson
38 New Member
That is the crux of my problem, this is my design, this is what I sat down and came up with.
I have never done this before, so each step I take is the first in that direction, I do not know any other way to do this.
I understand what you are saying, (I think)
Expand|Select|Wrap|Line Numbers
  1. newCD.setItemno(Integer.parseInt(itemField.getText()));
  2.             newCD.setNstock(Integer.parseInt(nstockField.getText()));
  3.             newCD.setPrice(Float.parseFloat(priceField.getText()));
are all parsing integers, but getting text ....if this is the problem, (which I do not doubt what you say), but why would this work in my ADD button but not here?
Jul 29 '07 #8
JosAH
11,448 Recognized Expert MVP
That is the crux of my problem, this is my design, this is what I sat down and came up with.
I have never done this before, so each step I take is the first in that direction, I do not know any other way to do this.
I understand what you are saying, (I think)
Expand|Select|Wrap|Line Numbers
  1. newCD.setItemno(Integer.parseInt(itemField.getText()));
  2.             newCD.setNstock(Integer.parseInt(nstockField.getText()));
  3.             newCD.setPrice(Float.parseFloat(priceField.getText()));
are all parsing integers, but getting text ....if this is the problem, (which I do not doubt what you say), but why would this work in my ADD button but not here?
Shouldn't that 'prev' button read 'delete'? From what I see from your code you
want to delete that CD from your inventory. Deleting a CD is easy: just remove
it from your JList model and revalidate the display of it.

kind regards,

Jos
Jul 30 '07 #9
no1zson
38 New Member
No. The PREV button should pull in the previous record.
If you see a flaw in my code that does not indicate this please point it out because I do not.

The DELETE button will delete a record, but I have not even started on that buttun yet.
I put the architecture in the code so that I could see it as a reminder of everything I want to accomplish this week. It is one of several buttons I want to code before Friday.
Add was first, it works.
Prev is next, it does not work.
Next, Delete, Search, Modify, First and Last are all to come ....
Jul 30 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5453
by: Roman Thurnherr | last post by:
Hi all I'm using two JLists with the same MouseListener in a JFrame. How can I find out on which JList the MouseEvent was released? Is it generally possible or should I use a MouseListener for each JList? Thanx for your help Roman
3
5339
by: Jordan | last post by:
Suppose I have a system that keeps track of 5 different types of "People". My intent is to have a base Person class, then 5 derived classes for each of the specific person types (e.g., Patient, Doctor, Employee, Contractor, etc). Now, at runtime I need to retrieve all the property values from a database and populate all of the fields of both the base and derived classes. Not all fields will need to be exposed via public properties as...
1
2415
by: Salha | last post by:
Hello there, Can you help me in following problem: Am working on a chemistry dictionary. I want to have all the chemistry terms in a JList and whenever i select a term from a JList, it displays the meaning in a text area (as any encyclopedia) and the term in a textfield. My questions: 1. How can i load the chemistry terms in to the JList and meanings in the textarea and store them? 2. How can i select a term and diplays it in the...
0
1390
by: paoparaopao | last post by:
Hi, I want to drag rows up/down in a JList; for example, drag 3rd row to 1st row. I have setDragEnabled(true) for JList, but it doesn't work! How do I drag rows in JList? Thanks!
4
2071
Nepomuk
by: Nepomuk | last post by:
Hi! I'm trying to use a JList. Here's the code: String languages = { "deutsch", // german "english", // english "castellano", // castilian "français", // french "italiano", // italian "日本語", // japanese
8
3170
by: sukatoa | last post by:
I came from List in awt.... Im currently having an experiment about JList.... say like 140,280 ( h,w ) i have 4 values that have been set on JList using addElement from DefaultListModel....
2
1964
by: wishbone34 | last post by:
Hi, here is some of my code public class ControlIL extends JFrame implements ActionListener, ListSelectionListener { private JList Items; //builds the UI public ControlIL(){ DefaultListModel model = new DefaultListModel();
2
2897
by: Gangreen | last post by:
Hi all, I've bumped into an odd problem creating a GUI in swing. As you will see in the screenshots, I have a tabbed layout. Each tab is a Jpanel. On this panel I have put a JList, containing a series of objects. My intention is to have a single column of objects in the list, and have it to scroll when the objects exceed the vertical space. My code is this: private JComponent createListBox() { Object test = {"Thingy 1","Thingy...
2
6299
by: Gangreen | last post by:
hi, I have an arrayList in my program that I want to display in a Jlist. I need the JList to update his contents when the elements in the arraylist change/ an element is added/deleted/... I'm lost on how to do this. Passing the arrayList as an array into the Jlistconstructor will just display the elements, but no updates will be made according to the API. Apparently ListDataListeners should be used, and I don't seem to be able to find a...
0
10620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10369
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10372
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10110
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5546
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5682
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3851
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.