Displaying Scrolling List of Database Items

Displaying Scrolling List of Database Items

I want to display a scrolling list of items from a database:

 product | description | manu | expiration | product | description | manu | expiration | product | description | manu | expiration | product | description | manu | expiration | product | description | manu | expiration | product | description | manu | expiration | product | description | manu | expiration | 
What’s the best way to do it? And HOW do you do it?

The easiest way of doing this is to use a monospaced font (so the columns line up) and fill the items into a single box.

Here is a sample Java applet that does just that.

Is that what you have in mind? It is also possible to have four listboxes and to keep them in synch. Submit another query if you need to see the code for that.

 import java.awt.*; import java.applet.*;  public class ColList extends Applet {  public void init()    {  setLayout(new GridLayout(1, 1));       items = new List(4, false);       items.addItem(new Item("KA-1094", "Pencil Sharpener", "Ultrasonic", "Aug 99").toString());       items.addItem(new Item("KB-1195", "Automatic Transmission", "Chevrolet", "Aug 97").toString());       items.addItem(new Item("KN-1339", "Can Opener", "Ultrasonic", "Feb 99").toString());       items.addItem(new Item("KP-1094", "Toaster Oven", "Royal Highness", "Mar 02").toString());       items.addItem(new Item("KU-2236", "Mending Kit", "Yue Loong", "Mar 98").toString());       items.addItem(new Item("KV-9401", "Chip Extraction Tool", "Intel", "Jan 99").toString());       items.addItem(new Item("KX-5734", "Laser Printer", "Lasertronic", "Aug 96").toString());       items.addItem(new Item("KZ-4453", "Dish Brush", "Yue Loong", "Jan 02").toString());              items.setFont(new Font("Courier", 8, Font.PLAIN));              add(items);    }        List items;     }   class Item {  public Item(String prod, String descr, String manu, String expire)    {  product = prod;       description = descr;       manufacturer = manu;       expiration = expire;    }    private static String pad(String s, int n)    {  if (n < s.length()) return s.substring(0, n);        StringBuffer sb = new StringBuffer(s);       sb.ensureCapacity(n);       for (int i = 0; i < n - s.length(); i++) sb.append(' ');       return sb.toString();    }    public String toString()    {  return pad(product, 8) + "|" + pad(description, 20) + "|" +          pad(manufacturer, 15) + "|" + expiration;    }    private String product;    private String description;    private String manufacturer;    private String expiration; }    

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as