java - Define listModel on button press -


Then I'm creating a program that has this part of the code

  last listModel Listmodel = new DefaultListModel (); Jebton BTN Brucerer = new pocket ("bus"); Btnbuscar.addActionListener {new actionalist} {public zero action action (action event e) {listModel = MySQL (select "* colosus WHERE id = '" + searchField.getText () + "' or '% name' "+ SearchField.getText () +"% 'or'% "like the keyword + searchField.getText () +"% '"," SELECT ");}}); Btnbuscular Setbound (336, 11, 89, 23); SearchPanel.add (btnBuscar); JScrollPane scrollPane = new JScrollPane (); ScrollPane.setBounds (10, 44, 316, 185); SearchPanel.add (Scrollpane); Gelist list = new jellist (list model); ScrollPane.setViewportView (list);  

As you can see that I'm making a ListModel variable and then want to use it on the button press. MySQL function gives a list model.

Then I want to make a list and want to give it the element inside the list. What's wrong with this code?

In addition to SQL queries, you can final variable. You should make listModel a field (the example variable) instead of the last local variable so that your appnalist and can change it.

Instead of

  public class YourClassName {public? YourMethodName () {last listModel listModel = new DefaultListMode (); Jebton BTN Brucerer = new pocket ("bus"); ...  

You will write

  Public category YourClassName {Private listModel listModel = New DefaultListModel (); public ? YourMethodName () {JButton btnBuscar = ...  

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -