netbeans gui designer (autogenerate controls)
I am coding a small GUI with netbeans and I am using objects from the Palette Manager. I have created a very simple application. Just a JLabel and a JTextArea. A small image here http://cateof.wordpress.com/2010/01/27/example-overflow/ (one image better than 1000 lines of code)
I am looking for a "meta programming" idea for my GUI. For example if the user executes the application at 01:00 I have to draw 1 line with a JLabel and JTextArea. If th开发者_运维问答e craft person executes at 5:00 then 1 need five JLabels and 5 JTextAreas. The real problem is that I don't now at compile time the number of JLabels or JTextAreas. How can I implement it? The number of objects it is proportional to/depends on the user input
(PS: It is not that simple... If strcmp(time,01:00) -> draw 1 line etc etc)
TIA, cateof
I might not be sure what your asking but im pretty sure you should just do a for loop to create the labels and text
for (int i=0; i<hours; i++) {
JLabel label = new JLabel();
...
myJFrame.add(label);
...
}
Since I assume you want to have data just define an array with the size hours and the type JTextArea (or whatever the data is returned as) and then loop through the array to get the data back out.
Your question seems kind of vague and without the code I cant say this is the best implementation but it should work. Post the code somewhere and you should get a better response.
精彩评论