Win a copy of Head First Android this week in the Android forum!

Tai Yo

Ranch Hand
+ Follow
since May 13, 2015
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 Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Tai Yo

@Campbell Ritchie Thank you for your reply.  String#format() method and split("\\s+") helped to divide the columns. Additional, I have used regex to parse double.
4 years ago
I have jTextArea which accepts numerical data.
I would like to ask how can I split the column 3 and 4

as shown here:
4 years ago
I would like to ask, this problem can be solved with AbstractButton.doClick()?
5 years ago
@Dave Tolls  I didn't think include Cancel Button, maybe some JOptionPane with a message "Do you want to save changes?", then reset to the previous value.
5 years ago
I have a Content menu with several jPanels (jPanel1, jPanel2), and every jPanel is referenced by CardLayout. Every jPanel has textfields and comboboxes and Save Button. After filling textfields we click save Button, it will save to text file. Also there is have Load Button which loads saved data to textfields. The problem that I am facing is when I modified the text on textfiled (jPanel1) then without clicking Save Button I moved to jPanel2 (CardLayout), and when I return to jPanel1, the modified text on textfield is still shown. I found a solution in combobox case from this link. Similar one I want to implement to textfields too.
5 years ago
I have a simple question but I couldn't figure out how to solve it.
It is related to save and get jTextField values, for example:
1. User typed some text on jTextField1 ( for example, "text 1") and clicked Save Button.
2. User cleared "text 1" and typed new text "text 2", but Save Button doesn't clicked.
3. If a user doesn't click Save Button then jTextField1 should return previous value "text1".

I would like to ask how to return previous value of jTextField1 i.e "text 1" when Save Button doesn't hit?
Any help is really appreciated.
5 years ago
Sorry for long delay. Due to other stuff this problem was waiting own solution for a time. Just now I could return to this problem and quickly found where I was mistaken. Solution was so simple. I just moved addDocumentListener to SubPanel, it solved my problem.
5 years ago
I think you may search for Autocomplete jcb, here you can find some solutions:
AutoComplete JComboBox
5 years ago
@Campbell Thank you for your reply. Sorry if I don't formulated clearly my question.
The layout of Main frame as follows:

jButton2 will call Test.jButton1:

but when I click jButton2 it calls only last clicked Test.jButton1.
For example, if I added dynamic data2 and data3, then only jButton1 of data3 is clicked, for data2 is no sense.
I don't know how to call all the Test.jButton1 action commands of dynamically added data2, data3,... by jButton2.
5 years ago
I have JFrame Main which contains in left side JXTaskPainContainer (content menu) and right side cardLayout panel. Content menu has a JButton btn "data", when we click btn it shows on cardLayout panel -> JPanel Test. Under content menu there is addButton, which adds dynamic btn -> "data2", "data3",.... Here is Main class and Test JPanel class:

The problem that I am facing is when I added dynamically "data2", "data3",..., then when I click jButton2 which must call Test.jButton1, output it prints (or hears) only last clicked Test.jButton1.
I would like to ask how can hear all Test.jButton1 action commands in Main class?
5 years ago
I have a text file with contents:

And I am loading I and II column to GUI using this code:

For III column case:

Everything works well with above code, but now I am facing problem with loading of inst#3 and inst#5 part, because they contain 2 line of string, as we don't add empty strings to ArrayList<String> inst, because by counting HashMap values, jButton1 adding SubPanels to jPanel2:

Setting up the JComboBox's and JTextFields by adding the data stored in the map:

I would like to ask how can I set the full text of inst#3 and inst#5 to jTextFields?
Any help is greatly appreciated.
5 years ago
Thank you for response. I solved it using switch statement.
5 years ago
I am loading text file contents to GUI. The line is splitted by comma.
Now by counting commas in line I want to set them to jcb and textfields.
But when I use if/else for 2 cases that is commas<4 and commas<3, I found that jcb and textfields are interfere each other.
In case of when commas==3, jTextField1 getting the value of t1[1] except t1[2].
How can I write if/else for this case without interfere them?

5 years ago
@Tony Docherty Thank you for reply, your method working. I didn't consider delimiter, but you give a idea.
5 years ago
I am loading text file contents to GUI using this code:

Contents of input.txt file:

I w'd like to ask how can I count the items, i.e. values v in sections? How can I get number 4, according to authors name?
5 years ago