Generate Textfield as per number given by user in java [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Requirement is like:
I want to take input values from user in frame but no of inputs is also decided by user.
So first,
In frame,I want user to write no of values in one text field
so as soon as user writes that many text fields should be generated in the same frame.
How can this be done?
Is this possible or is there any good way available for this?

I would use a table instead. Either the user can directly edit the table or you provide a "Add New Row" button. In my opinion changing the UI layout (adding text fields) at runtime is bad design.

Related

Add multiple values on a table using docx4j [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
The image below describes what I want to do, so I'm supposed to add many values to this three tables.
I'm using the library docx4j
You can use content control databinding for this; docx4j's OpenDoPE convention allows you to repeat table rows. And more recent versions of Word have a concept of repeating content controls; see https://www.docx4java.org/blog/2015/01/word-2013-repeatingsection-content-controls-ready-for-prime-time/
In principle, docx4j supports both, but it'll be easier to get help with the OpenDoPE approach.
To get started, try invoice.docx from https://github.com/plutext/docx4j/tree/master/sample-docs/word/databinding which is an example of repeating table rows.
To merge invoice-data.xml (from the same dir) into it, use https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/ContentControlsMergeXML.java
If you like this approach, you'll need to author your own input document; to do this, you can try the "friendly" Word AddIn at https://opendope.org/implementations.html

Set Variable as Name of JLabel [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
I'm trying to create JLabels in a loop and remove them at the End. So I need to give every Label its own name (Like Label[1], Label[2],...). I'm very new to Java so I can't imagine how to solve this problem. I already tried different ways but they all didn't work.
I am not sure but you can add a number of anonymous objects(in this case they will be JLabel or Label) to the Array List without naming them.(You need to use for loops). If you want to delete them, you need to use the same logic.
Let me know this works or not. If you stuck again, I can help you by writing the code. However, writing yourself will be more beneficial for you.
Have a nice day !!

how to build a table of items and it's radioButtons with a dynamic size? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to build a table, with some items, and for each item I want to have its own radioButton. but the input is dynamic. so the size of the table is dynamic, and the "ActionCommand" for each radioButton is dynamic.
what is the best way to do this?
the only way I know is to normally just make a dynamic list of radioButtons and initialize it dynamicly with the names of the items.
thank you
Depends of what you want to do after ? You have to give more details...
If it's for printing, you can take a look about JTable (or more powerful JXTable) which can handle your data with a specific model (model which you have to define).
Just remember to set the action command to each radio button before adding to the table. You'll have to take the time to read doc about this, but with some tests it givesa very good result !
Else, yeah, just a map, with the name of the item, and the radio button.

Add formatted text [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
im stuck on a simple question, i want to display formatted text in a swing control and keep on adding new values into it, i don't want to use .setText(.getText + text) for personal reasons, (something like the append method for text area is what I am looking for) I've tried JEditorpane, Textpane but all of them do not have append method. Which swing control should I use?
While JEditorPane has no append method, you can certainly add text to its Document via its insertString(...) method, and I suggest that you look into doing this.
Edit
You ask:
it worked it out but it seems it works like setText, all the previous data vanishes.. how do i keep the previous data ?
Are you correctly passing in the first parameter, the offset? This should be the length of the current Document.

Programming a reset button? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm currently making a mortgage calculator, but I need some help. I have a reset button on my GUI that makes all of the forms blank again after typing something into them. The IDE already helped me make the button, so here is where I'm at:
private void resetActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
What do I need to put in here?
You either recreate your complete GUI (probably not an option), or painstakingly use .setText("") against each and every input field you have, and similar logic for radio buttons, etc. There's no royal way to it, unfortunately.

Categories

Resources