Bob Zoloman

Ranch Hand
+ Follow
since Jul 02, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Bob Zoloman

That works perfectly, thanks!
18 years ago
I have a program where you click a button and it adds a character to a JTextField. You can keep clicking on the button and it will add random characters to it.

What I am trying to do is when a new character is inserted, I want it to be inserted from the left side not added on to the right. Here's an example

Say I have the following text in a JTextField:
a b c d

and I want to insert 'e'. By default 'e' will be added so it looks like this
a b c d e

I want it to look like this
e a b c d

where the text is inserted from the left hand side. I have tried setting the caretposition for that JTextField to zero each time a click event takes place, but that didn't work. Any help is appreciated.
18 years ago
I'm trying to make a JTextField that only accepts 0 or 1, as the input. Is there any way to do this? Thanks.
18 years ago
ughhhh nevermind I forgot to set it to a new variable... I can't believe it took me an hour to realize this...
18 years ago
If I have the following string:

"Remove the spaces between the words"

how can I turn it into

"Removethespacesbetweenthewords"

I have tried the following code, but it does not work.

18 years ago
When I have over 200KB of text in the JTextArea it becomes very slow to scroll. It is also very slow to initialize it with the text. Is there some sort of setting I need to set to make it go faster? Am I even using the right component or is there one more suitable for loading all that text. Thanks in advance.
18 years ago
For large text file append goes really slow. I think I'll try merging the files into one large file and initializing the JTextArea with that. Thanks for the help.
18 years ago
I'm trying to read multiple text files into a JTextArea. I'm currently selecting them via JFileChooser dialog, which returns the selectedFiles back as a File[]. When I try and output the files contents it only displays the last file read in.

Here's my code:

18 years ago
Would that be like implementing an observer pattern?
18 years ago
I'm trying to create one instance of a file type (txt, jpg, doc, etc...). I have an inheritance structure that goes something like this.

abstract FileClass <- superclass


JPG DOC TXT <- (child classes)


Ignore the fact that this example doesn't seem very practical, it's more for just learning inheritance. I have a swing menu where I can select to load, or save any of these child classes.



If I load up a JPG file I want to keep track of the files name, size, and keep a File object of it. If I then click on the DOC menu and select save, I want it be able to use the file object that was created when I loaded the JPG file.

In my menu class I have a reference to the FileClass (superclass), and have methods for each menu operation (a load/save method for each subclass). The problem is each menu option creates a new subclass object with a superclass reference. So it creates a new object each time a menu option is selected, which means I lose all the information of a loaded file if I choose to save it.

Ex
menuclass


[ September 23, 2006: Message edited by: Bob Zoloman ]
18 years ago
All I want to do is write text to a text file with a different font, and size. Notepad allows me to change fonts and sizes, so I'm assuming there must be some way to change the font of the String I want to output to the file.
18 years ago
Hi, I am trying to change the font, style, and size of a String so I can save the formatted output to a textFile. I tried to make a new Font object, but there is no setFont method on Strings to apply it to. Thanks in advance.
18 years ago
Say for example I had 10 separate classes, and each one has a task I want to have a progress bar for, the way I understand it is that I would need a getLengthofTask(), getCurrentTime(), methods plus all the instance variables required for progress bar, etc... embedded in every single class that uses one (in this case 10).

To me it seems like a really bad design... First, it reduces your classes reusablility, and you have duplicate code in every class. Is there a better design approach I could take?
18 years ago
Hi, I am trying to figure out how to implement a JProgressbar, but I'm a little confused on the part where you get the length of the a long running task, and the currentTime() of the task. If I want to use a progressbar for a certain class do I need to have those kinds of methods inside the class that has that task? It seems like I would have to repeat a lot of code in all classes that need a progress bar. Is there a better way to do it? Thanks in advance.
18 years ago
Sounds good i'll give it a try. Thanks for the help!
18 years ago