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 8879959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:04:08+00:00 2026-06-14T20:04:08+00:00

Really jammed up on my project here and I’m fairly new to java and

  • 0

Really jammed up on my project here and I’m fairly new to java and really new to databases. What I’ve done in my code is fill the “data” object with a bunch of words but what I want to do is fill those frames with info from a database I’ve made. I’ve been Googling and search for days and have not found anything that helps me understand what I need to do. Any help would be greatly appreciated.

import java.awt.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.table.*;
import java.awt.event.*;

public class Project3 extends JFrame {
private JPanel contentPane;
private JTable table_1;
private JScrollPane scrollPane;
String[] columnNames = { "Restaurant", "Dish", "Type", "Price", "Rating" };
Object[][] data = {
        { "Nemo", "Vesuvio", "Pizza", new String("65kr"), new Integer(7) },
        { "John", "Doe", "Rowing", new Integer(3), new Boolean(true) },
        { "Sue", "Black", "Knitting", new Integer(2), new Boolean(false) },
        { "Jane", "White", "Speed reading", new Integer(20),
                new Boolean(true) },
        { "Joe", "Brown", "Pool", new Integer(10), new Boolean(false) } };

/**
 * Launch the application.
 */
public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                Project3 frame = new Project3();
                frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the frame.
 */
public Project3() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setBounds(100, 100, 800, 600);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new BorderLayout(0, 0));
    setContentPane(contentPane);
    JPanel panel = new JPanel();
    contentPane.add(panel, BorderLayout.CENTER);
    panel.setLayout(null);
    scrollPane = new JScrollPane();
    scrollPane.setBounds(139, 162, 469, 420);
    panel.add(scrollPane);
    table_1 = new JTable(data, columnNames);
    scrollPane.setViewportView(table_1);
    table_1.setFillsViewportHeight(true);
    table_1.setModel(new DefaultTableModel(new Object[][] {
            { "Nemo", "blah", "Pizza", "65kr", new Integer(7) },
            { "Nemo", "blah", "Rowing", "1 000 000kr", Boolean.TRUE },
            { "Sue", "blah", "Knitting", new Integer(2), Boolean.FALSE },
            { "Jane", "blah", "Speed reading", new Integer(20),
                    Boolean.TRUE },
            { "Joe", "Brown", "Pool", new Integer(10), Boolean.FALSE },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null },
            { null, null, null, null, null }, }, new String[] {
            "Restaurant", "Dish", "Type", "Price", "Rating" }));
    JButton btnChangeadd = new JButton("Change/Add");
    btnChangeadd.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            // CALL CHANGE METHOD HERE
        }
    });
    btnChangeadd.setFont(new Font("Lucida Grande", Font.PLAIN, 16));
    btnChangeadd.setBounds(143, 104, 175, 42);
    panel.add(btnChangeadd);
    JLabel lblNewLabel = new JLabel("Welcome RestaurantID");
    lblNewLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 24));
    lblNewLabel.setBounds(264, 56, 260, 36);
    panel.add(lblNewLabel);
    JButton button = new JButton("+");
    button.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            // CALL SOMETHING HERE IF YOU WANT
        }
    });
    button.setBounds(66, 248, 40, 29);
    panel.add(button);
    JButton button_1 = new JButton("-");
    button_1.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {

        }
    });
    button_1.setBounds(66, 289, 40, 29);
    panel.add(button_1);
    JButton btnDelete = new JButton("Delete");
    btnDelete.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            //DELETE METHOD
        }
    });
    btnDelete.setFont(new Font("Lucida Grande", Font.PLAIN, 16));
    btnDelete.setBounds(344, 104, 191, 42);
    panel.add(btnDelete);
    JButton btnLogOut = new JButton("Log out");
    btnLogOut.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
        }
    });
    btnLogOut.setBounds(667, 6, 117, 29);
    panel.add(btnLogOut);
}

}

  • 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-14T20:04:09+00:00Added an answer on June 14, 2026 at 8:04 pm

    Start with the JDBC tutorial, and then study the article Table From Database. Also,

    • Use constants or factories when available, rather than needless constructors, for example:

      {"Nemo", "Vesuvio", "Pizza", "65kr", 7},
      {"John", "Doe", "Rowing", 3, true},
      {"Sue", "Black", "Knitting", Integer.valueOf(3), Boolean.FALSE},
      
    • Use the @Override annotation to avoid careless overloading:

      @Override
      public void run() {
          ...
      }
      
    • Begin to embrace object orientation using the Java Collections Framework, in preference to arrays. Note how the examples cited specify formal parameters such as List<T>, where List is an interface type and T is a generic type parameter.

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

Sidebar

Related Questions

Really simple question here (more to confirm my thoughts, than anything)... Java method: StringBuffer.Delete(start,end)
Really a buggy question , hee is the code: import java.io.IOException; import java.security.*; import
really weird behavior in Vb.net 2010 Express. Here is the code: Private Sub Form1_Load(ByVal
Really stupid C question. I'm trying to build the source code here so I
Really dumb question. Here's my sample code: #include <stdio.h> #include <stdlib.h> typedef struct sample
Really basic question I'm sure for some of you Java heads out there. I
really new to JQuery.. like 2 hours new. Began to write a drop down
Really stuck on trying to write code to unzip a file or directory on
Really 2 questions. Why is it that these bits of code dont validate to
Really basic question here. So I'm told that a dot . matches any character

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.