Roger Wells

Ranch Hand
+ Follow
since Aug 01, 2016
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
1
Total given
2
Given in last 30 days
1
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Roger Wells

Rob Camick wrote:

Tim Holloway wrote:
I'm glad that there was a pop-up explanation of what "SSCCE" meant. Because it meant nothing to me.


Yes, the pop-up has been a feature of the forum for many moons

Now if only we can get Roger to read it. He was also asked in his last question to post a SSCCE:

https://coderanch.com/t/731764/java/JTable-data-colums-row-selected#3404917

The last question took 15 replies to resolve the issue. I'm not about to go down that path again.

A good question should have all the information we need to solve the problem in the original question which is why I believe a a "proper" SSCCE should be included with every question so we know the exact context of how the code is used and the problem is replicated.



Sorry to be such a problem. The short program works.
I'll keep after it
Roger
1 week ago
Tim

Thanks for the help with it I got something to work. I am still having problems but I am closer to knowing what
problem is.

Here is my current code: Which works because I have set strTemplateName
and intTemplateCode variables just before. If I comment out the setting of
the variables it will not work




So something is wrong with the way I am setting the variables.

Here is the code that sets the variables



Hope this makes sense and appreciate hour help.
Roger
1 week ago

Campbell Ritchie wrote:Wells? What goes wrong? If you want any help, you should give us the full details.

Moving to our GUIs forum.



I thought I did but let me try again: I am trying to get the label to display the following text: Format: - 1940 Census - 2 but  it only displays Format: - - 0.
It appears that it completely ignores both the string variable and sets the int variable to 0

I thought the following code should do this but for some reason it dose not.
1 week ago
I am unable to get the following code to work. I am trying to add a string variable and a int variable to the JLabel. The print statement prints correctly, Format: - 1940 Census - 2,  but the label has the following Format: - - 0 which appears to not even see the strTemplateName and puts a 0 instead of the actual value.

Any help would be appreciated. Thanks

1 week ago
Paul and Rob

I'm sorry about the confusion with rows and columns. I also get confused when starting with 0 instead of 1.

I stay confused so I am sure I will be back with more confusing questions. Hope you are patient with me!

Here is the code that worked for me.

2 weeks ago
Rob

After much hair pulling I finally got this to work. I found another tutorial that helped me understand.

I have a question still. This table has 2 rows and several columns. When I click on a column I would like for it to
select all of the rows in that column so that I can pull data from all of the rows. Currently this only pulls data from the first column.

Can you offer some suggestion on how to fix this?

Here is my current code:

2 weeks ago

Rob Camick wrote:Read the section from the Swing tutorial on How to Write a ListSelectionListener for working examples.



Rob I appreciate you help. Sorry but I am still having problems. I have read the TableListSelectionDemo.java several times.

So here is where I am starting one line of code at a time.
I get the following error:

<identifier> expected
incompatible types: ListSelectionModel cannot be converted to listSelectionModel
variable tblTemplate might not have been initialized


2 weeks ago

Paul Clapham wrote:JTable has a getSelectionModel() method which will give you a ListSelectionModel object. It tells you what rows are selected. You can add a ListSelectionListener to that via the addL..S..L..() method and override the methods which tell you when the row selection is changing, just like any other listener.



I guess I need more help I have read through suggestions but no success. Hers is where I am. I am trying to listen for a row to get focus in the tblTemplate. You can see some of the items I have tried but I can't get it to work.

2 weeks ago
Yes I am aware of them but for listeners they seems to be based on the data being changed not just a focus event.

Unless I am missing something which is a good chance.

2 weeks ago
Can someone point me to a good tutorial or example that will help me understand how to get the data from a JTable when the row has focus or is selected.

In reading it seems that I will need some type of listener but most of what I read is if the data in the table is changed. My table can not be changed but when it gets
focus i need to get the data.

Thanks
2 weeks ago
Thanks for the advice I got it to work. I somewhat understand what it is doing now.

3 weeks ago

Rob Camick wrote:
Why are you using "10"? What does that value mean to you?



What I want it to mean is the column should be a width of 10. I had chosen 10 just as an example but I don't know what it means 10 pix 10 char? But it did not seem to do anything.
3 weeks ago
I am trying to get the headings of a JTable to be centered and change the width of the column heading "KEY". I have searched through the form but most of the information is several years old.

Here is my code



Any suggestions appreciated
Thanks
3 weeks ago
I have a computer data entry screen that looks like this; (see screen shot below)


When I select the complete window and copy it to the clipboard then past it to Notes all of the information is displayed correctly in notes like this

First & Middle Name(s)
William

Exact, sounds like, similar & initials
Last Name
Wells

When I do the same thing with this piece of code



First & Middle Name(s)

Exact, sounds like, similar & initials
Last Name

Only the headings are copied into clipData the William and Wells are not copied in. I have tried all of the stringFlavor but none of them work.

When I paste to notes if I then select all of the information and copy then run my code it works.

Would appreciate any help or suggestion that will allow my code to bring in all of the data like happens in notes.

Java NetBeans 8.2, iMac 10.14.6
8 months ago
Can I do this with a CardLayout and get the same results?
1 year ago