Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:48:55+00:00 2026-06-07T12:48:55+00:00

I am making a program for a family enterprise that will manage the brochures

  • 0

I am making a program for a family enterprise that will manage the brochures from their raw materials providers. I find you will need all the code, so I posted it on pastebin. http://pastebin.com/Gc3aLe10

But also, here I attach where I think the problem is:

tnBuscar.addActionListener(new ActionListener(){
        public void actionPerformed(ActionEvent e) {

            String search = searchField.getText();
            Connection con = null;
            java.sql.Statement st = null;
            ResultSet rs = null;

            String url = "jdbc:mysql://localhost:3306/";
            String db = "FAVEGA";
            String driver = "com.mysql.jdbc.Driver";
            String user = "root";
            String pass = "";
            try {
                Class.forName(driver);
                con = DriverManager.getConnection(url + db, user, pass);
                con.setAutoCommit(false);
                st = con.createStatement();
                String sql = "SELECT * FROM catalogos WHERE id = '" + search + "' OR name LIKE '%" + search + "%' OR keywords LIKE '%" + search + "%'";
                rs = st.executeQuery(sql);
                while (rs.next()) {
                    final String resultName = rs.getString("name");
                    buffer.add(resultName);
                }
            } catch (ClassNotFoundException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            } catch (SQLException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }finally{
                btnEditar.setVisible(true);
                btnReiniciar.setVisible(true);
                final JList list = new JList(buffer.toArray());         
                final JScrollPane scrollPane = new JScrollPane(list);
                scrollPane.add(list);
                scrollPane.setViewportBorder(new LineBorder(new Color(0, 0, 0)));
                scrollPane.setBounds(67, 195, 269, -143);
                buscarPanel.add(scrollPane);                    
                list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                list.setBounds(0, 0, 435, 240);

                scrollPane.setPreferredSize(new Dimension(70, 80));
                list.setLayoutOrientation(JList.VERTICAL);
                buscarPanel.invalidate();
                buscarPanel.validate();
                btnEditar.addActionListener(new ActionListener(){
                    public void actionPerformed(ActionEvent e) {
                        if(list.getSelectedValue() != null){
                            String selectedValue = (String) list.getSelectedValue();
                            tab.setSelectedIndex(2);
                            btnReiniciar.addActionListener(new ActionListener(){
                                public void actionPerformed(ActionEvent e) {
                                scrollPane.setVisible(false);
                                btnEditar.setVisible(false);
                                btnReiniciar.setVisible(false);
                            }
                            });
                }
                    }
                });
            }
        }
    });

This button searches for items in my database, but it somehow doesn’t load the JList when it runs. What is the problem?
PS:No runtime errors, no Stacktrace.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:48:57+00:00Added an answer on June 7, 2026 at 12:48 pm
    1. don’t re_create whole GUI,

    2. use XxxListModel instead of remove & add JComponents to the JPanel

    3. all updates to the XxxModel must be done on EDT

    4. right finally block is always fired, but not right place for creating GUI

    5. have to call revalidate() & repaint() if you remove and then add JComponent from/to the already visible container

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a program that will display a few images from a directory beside
So i am making a program that will find the multiples of 3 and
I am making a program that will track golf stats so i need to
I am currently making a program that will send an email if the date
I have been making a program that creates multiple CSV's from another source CSV
I'm making a program that will move around quite huge sets of files, sometimes
I'm making a program that asks for an integer from the user, it then
Im making a program in C# that has passwords and I need to encrypt
I am making a program that takes input from files that I have called
I'm making a program that will have a widget that has to be fixed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.