This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!

Rob Camick

+ Follow
since Jun 13, 2009
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rob Camick

but I already clicked Like and clicked the Resolved button.

The "Like" button could be clicked by anybody. It doesn't imply you read the answer.

The "Resolved" button is new to me (I've never asked a question). Just followed up by reading the "Ranch Guide". Indeed the folder icon with a circle inside it implies the question has been resolve.

This is a feature few people appear to use on the forum. Learned something new today, thanks.

I noticed that the value differs by a constant of 283 for my window size

This is the size of the view used by the scrollpane.

You can get the value by using the getExtentSize() of the JViewPort of the ScrollPane.

As a simple test add the following to your AdjustmentListener:

4 days ago
You got help in your last question:

You still haven't replied to state whether the suggestion worked or not or say thank you for the help, so I think I'll skip  this question.
4 days ago
Swing paints components in their ZOrder, which by default basically mean they are painted in the  reverse order that they are added to the panel.

This is not usually an issue when components are displayed in 2 dimensions.

But when trying to overlay components it is important.

So your code should be something like:

Check out Overlap Layout for more information on how ZOrder works.
5 days ago
From the pictures it looks like you:

1. know how to read data from a file and load it into a JTable

2. know how to use a JTabbedPane since you posted a simple example

3. know how to use a file chooser since data is loaded in the JTable, so why keep talking about it.

There is so much confusing misleading information I still don't know what the actual problem is.

You need to learn how to simplify problems when you want to problem solve or get help from a forum

I still have no idea why you need a tabbed pane? What information do you expect to be in the tabbed pane?

The code posted is too complex because we don't have access to the database. We can't see what is actually happening.

The code posted should be a simplified version of what you are trying to do.

For example. Here is a SSCCE as I understand the problem:

It allows anybody to run the code to see exactly what happens. It demonstrates the "flow" of the question while keeping the logic simple.

Now the question is which step of the above process are you having trouble with?

Why do you want a tabbed pane? What do you expect to see on the tabbed pane?

Make changes to the presented SSCCE so it works as you expect, then make the change to your real application.
6 days ago

I still have no idea what your problem is.
6 days ago
I still don't understand your question.

Here i attached my file to import. That part also i done.

We don't care what is already working.

You question should state exactly one problem that you are trying to solve.

Can you please how to add JTable in JTabbedpane to import the file in database.

You add the JScrollPane (containing the JTable) to the JTabbedPane the same way you add a JLabel to the JTabbedPane.

to import the file in database.

How is this relevant? Are you now asking how to sue SQL??

A posting should have one simple clear question.

Your topic title and all the images you have posted in the question are completely confusing. I have no idea what your actual question is.

We don't care about your real application.

We only care about the one specific problem you are trying to solve.

1 week ago

How would toString() look if I wanted to display a string and an int?

You concatenate the String and int into a single String variable and return the String variable.

This is basic Java for manipulating a String and has nothing specific to do with the toString() method.
1 week ago

Better to post the whole wall of text than to leave out something important I guess.

You posted way too much code.

But the number must also be stored in the same "item" as the corresponding name in the DefaultListModel.

Your question is about using a DefaultLiistModel to contain the name and number. All the other code is irrelevant to that requirement.

So first you need to learn how to display an Object with multiple properties in a JList.

If you look at the DefaultListModel you will see that you add an Object to the model, not a String, so you can create a custom Object that contains both the name and number properties.

Then you next need to decide what to display in the JList. Do you want just the name, number or name and number together?

Then you have a couple of option:

1. The default renderer for a JList will simply invoke the toString() method of the Object contained in the ListModel. So you can implement the toString() method of your custom object to display whatever you want.
2. Implement a custom renderer to display the data from your custom object.

Check out Combo Box With Hidden Data for an example implementation of a generic Object used to hold multiple properties. Yes the example is for a combo box, but the concept of using the custom Object with a custom toString() method is the same for a JList and a JComboBox.

Like I said for every name, I would also want to require the user to input a number for that name.

How you get the name and number to create the custom Object would now be an implementation method of your application.

The common approach would be to prompt for the name and number at the same time so you can create your custom Object.

The number could be stored in a string, ideally in an integer but that’s not that important.

Since you are creating the custom Object to be stored in the model, you can store the number however you want. I would store it as an int if that is how you would use it in future processing.

1 week ago

that form will display on 1 tab.Another tab is empty

There is no trick. You create 2 panels and add each panel as a separate tab in the tabbed pane.

The last code you posted works fine for me, except you should set the layout manager BEFORE you add the component top the panel and you didn't specify any "constraints" for the GridBagLayout.

So you just need to debug your code to see what is different from your working example. We don't have access to your database so we can't help with that.

Read the section from the Swing tutorial on How to Use Tabbed Panes for more working examples to get you started. The tutorial also has a section on "How to Use GridBagLayout".
1 week ago
A JTable is designed to display data in each cell, not components.

I don't know why you would be attempting to display a tabbed pane in the cell of a JTable and I also have no idea how you would do this.

Create a JTabbedPane with two tabs and display a separate table on each tab.
1 week ago

I have no idea why, because I clear that Panel always before calling connectDotsGUI.

I would guess one of two problems:

1. You don't clear the panel like you think you do
2. You invoke the logic that adds the buttons twice.

So you need to add debug code to see the logical order of all you methods and display the number of component on the panel as each of your methods is invoked.
1 week ago
Check out Text Prompt for a class to manage this for you.
2 weeks ago
In your first picture you have a table with many columns because you manually create the array to be used for the column names.

In your second picture you only have a single column because you try to use the "split" method to create an array of column names. The problem is the split method isn't working so you need to fix it.

I have no idea how to split a string like you have in our file. As I suggested. in my answer I only know how to use the split() method when you file contains a string with delimiters.

Here is a simple example:

So your problem is the format of your data.

I showed you:

1. How so parse the data when you have a delimiter by using the split() method
2. How so use "substring(...)" to get the data when you have a fixed column size

You need to apply these concepts to your code. I can't control the format of your data. It is up to you to format your data and use the appropriate approach to parse the data into individual pieces of data that you can use to add to the TableModel.
2 weeks ago

Using the split(...) method is only useful when you data is delimited by a special character.

( ID = 2 Chars, Username = 10 chars ( if username not having 10 chars means, it include space for that, password = 5 chars, email = 5 chars, Age = 2 chars, Gender = 1 chars)

In your case you stated the data is column dependent, which mean you need to use the substring(...) method to access each column of data.

So your code might be something like:
2 weeks ago