| | |
Arrays
![]() |
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 7
Hi everyone,
I am currently trying to add values to an element spec array dynamically.
This is what i am trying to do
The above code is trying to add some custom elements into the styyled document but the thing is that i do not know what amount of this element does the user require. For example if the user requires only one of this element then this is what i would add into the array
if the user wants two types of this elements then i this is what i would add into the array
The thing is i would not be able to know whatever the fixed array size is but this array has to be of an exact size because it is an element that is being added to the styled document
What i want to able to do is to find a way in which i can add these elements to the styled document even after its array size has been declared thus expanding the array size and adding values to it.
Some examples or sample codings would really be helpful
I hope someone can help me with this problem
Thank You
Yours Sincerely
Richard West
I am currently trying to add values to an element spec array dynamically.
This is what i am trying to do
Java Syntax (Toggle Plain Text)
SimpleAttributeSet start = new SimpleAttributeSet(); start.addAttribute(AbstractDocument.ElementNameAttribute, "start"); SimpleAttributeSet end = new SimpleAttributeSet(); end.addAttribute(AbstractDocument.ElementNameAttribute, "end"); DefaultStyledDocument.ElementSpec esStart1 = new DefaultStyledDocument.ElementSpec(start, DefaultStyledDocument.ElementSpec.StartTagType); DefaultStyledDocument.ElementSpec esStart2 = new DefaultStyledDocument.ElementSpec(start, DefaultStyledDocument.ElementSpec.StartTagType); DefaultStyledDocument.ElementSpec esStart3 = new DefaultStyledDocument.ElementSpec(start, DefaultStyledDocument.ElementSpec.StartTagType); DefaultStyledDocument.ElementSpec esEnd1 = new DefaultStyledDocument.ElementSpec(end, DefaultStyledDocument.ElementSpec.EndTagType); DefaultStyledDocument.ElementSpec esEnd2 = new DefaultStyledDocument.ElementSpec(end, DefaultStyledDocument.ElementSpec.EndTagType); DefaultStyledDocument.ElementSpec esEnd3 = new DefaultStyledDocument.ElementSpec(end, DefaultStyledDocument.ElementSpec.EndTagType); DefaultStyledDocument.ElementSpec[] esArray = { esStart1, esEnd1, esStart2, esEnd2, esStart3, esEnd3};
The above code is trying to add some custom elements into the styyled document but the thing is that i do not know what amount of this element does the user require. For example if the user requires only one of this element then this is what i would add into the array
Java Syntax (Toggle Plain Text)
DefaultStyledDocument.ElementSpec[] esArray = { esStart1, esEnd1}
if the user wants two types of this elements then i this is what i would add into the array
Java Syntax (Toggle Plain Text)
DefaultStyledDocument.ElementSpec[] esArray = { esStart1, esEnd1, esStart2, esEnd2};
The thing is i would not be able to know whatever the fixed array size is but this array has to be of an exact size because it is an element that is being added to the styled document
What i want to able to do is to find a way in which i can add these elements to the styled document even after its array size has been declared thus expanding the array size and adding values to it.
Some examples or sample codings would really be helpful
I hope someone can help me with this problem
Thank You
Yours Sincerely
Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
•
•
Join Date: Jun 2004
Posts: 2,108
Reputation:
Solved Threads: 18
There's really no other way than creating a new array each time.
I'm sure a performance hit would come out of that.
Java Syntax (Toggle Plain Text)
String[] original = new String[4]; String[] temp = new String[words.length+1]; original = temp;
I'm sure a performance hit would come out of that.
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 7
Hi everyone,
I used the ArrayList, it worked perfectly for my uses
Thank You
Richard West
I used the ArrayList, it worked perfectly for my uses
Thank You
Richard West
Microsoft uses "One World, One Web, One Program" as a slogan.
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
Doesn’t that sound like "Ein Volk, Ein Reich, Ein Führer" to you, too?
— Eric S. Raymond
Tell me what type of software do you like and what would you pay for it
http://www.daniweb.com/techtalkforums/thread19660.html
![]() |
Similar Threads
- (reformatted) How to return Multi-Dimensional Arrays (C++)
- What relation does **indirection operator have with Multidimensional Arrays (C++)
- Arrays (C++)
- How to Return Multidimensional Arrays (C++)
- C file input/output 2D arrays. (C)
- passing arrays in visual basic (Visual Basic 4 / 5 / 6)
Other Threads in the Java Forum
- Previous Thread: My class cannot be reuse
- Next Thread: java 2d games problem (collision, well prevention)
| Thread Tools | Search this Thread |
account android api applet application array arrays automation awt bidirectional binary birt bluetooth busy_handler(null) chat class classes client code columns component database designadrawingapplicationusingjavajslider draw eclipse error errors exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance input integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source plazmic print problem program programming project property recursion ria scanner search server set smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree webservices windows






