Leo Deegan

Greenhorn
+ Follow
since Jun 15, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Leo Deegan

I figured out a solution:

Make a JPanel with a BorderLayout.
Add the JList to the JPanel using BorderLayout.NORTH.
Put the JPanel in the JScrollPane.
20 years ago
I hope this is descriptive enough:

I have a JList in a JScrollPane and the list of items in the JList is not enough to fill the whole viewable area. (I have like 3 items, but there's enough space for, say, 10 items.)

Pretend the first item in the list is already selected. When I mouse-click the empty space below the last item in the list, the last item in the list becomes selected. I don't want this to happen.

I want mouse clicks on the empty space below the last item to be ignored. How can I accomplish this?

Thanks in advance
--Leo
20 years ago
The package line says that your PostServlet class is in the com.javaranch package, which means it is in the subdirectory com/javaranch relative to your source root directory.

If you have the import java.io.* line, you are indicating that your class can use the java.io package classes without fully qualifying their names. If you notice, your class can use a PrintWriter without having to call it java.io.PrintWriter each time you use the PrintWriter name.

When you declare a package, you are not calling the package. When you import the set of classes in a package (e.g., import java.io.*), you are also not making a call.
20 years ago
Hi Salvador -

The package declaration indicates the package location of your class. It does not execute a call to the package (in fact, I don't believe packages are executable). In your example, you do not need to import the package com.javaranch.

--Leo
20 years ago
Hi there Pooja -

Here's some test code that I used to do what I think you want to do. My solution was to use a couple of java.text.SimpleDateFormat objects.

Take care,
--Leo

20 years ago
Ah, yes, good eye. I missed that detail in the question.
20 years ago
Hi there Frank,

I'm not sure what your parsing rules are exactly, but I'm guessing that you want a dash between every grouping of four digits for a number that is 16 digits long. A number that large can be handled by a java.math.BigDecimal. Here's my main method to test out a DecimalFormat approach (sorry, I did this in JDK 1.4.2, but try it out in 1.3 and see if it works):

20 years ago
Oh, I saw your p.s.

J2EE (Java 2, Enterprise Edition) is a catch-all set of code and specifications for developing enterprise level applications. J2EE includes JSP, Servlets, and EJBs. J2EE also provides APIs for handling XML, SQL, mail and messaging, along with other things of interest to enterprise developers.
20 years ago
Hi Mike,

By Java Beans, I'm sure you meant Enterprise JavaBeans (EJBs). You can use the three technologies in a web application. The JSPs provide your webpage content; requests can be handled by a ControlServlet, say; and you can use EJBs for the data persistence.

Suppose the web app is like a bookstore, and it allows the user to save their book selections for purchase at a later time. The ControlServlet can handle a request like "http://www.myexamplebookstore.com/controlServlet?saveBooks=true", and the ControlServlet can use an EJB like LibrarianBean (okay, that's laughable) to persist the user's book selections to the database.

Hope that helped,
--Leo
20 years ago
That should work. In fact, you can do this:

20 years ago
Hi Dipen, here's one main use for an interface:

An interface is used to declare methods without defining their behavior. The behavior is implemented in the classes that implement that interface.

Take, for example, the following interface.



The above interface declares a method (operateOn), but does not define what the method does. The following classes provide different behavior by implementing the interface.

20 years ago
Hey there, y.

1. An abstract method cannot have a block for its body (that is, it can only use a semicolon and cannot use { }).

2. An abstract class can be instantiated, provided its abstract methods are implemented when the class is instantiated. For instance,

public abstract class Abc {
public astract boolean foo();
}

can be instantiated like this:

Abc abc =
new Abc() {
public boolean foo() {
return false;
}
};

One reason for providing a constructor for an abstract class is that its subclasses may take advantage of the constructor.
20 years ago