Alex Wolf

Greenhorn
+ Follow
since Aug 24, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Alex Wolf

Hi, Im writing a messenger, and I'm experiencing a problem with too much text in JTextPanes. That means, the more messages I receive, the slower the messenger reacts because there's so much text in the JTextPane. This goes to the point of it being unusable. I usually fix this by closing the window and reopening it so that there's no text to display. This works for a while, but its annoying.

I want fix this by setting the JTextPane to display up to a certain number of lines, for example 200, and everything thats exceeds this, should be written to a file so that I can recall it if the user chooses to scroll to the top.
When receiving messages, the text is formatted and then added to the JTextPane and when recalling it should be formatted the same way.

I need some help getting started. I don't know how to extract the formatted text from the JTextPane.
Its easy to set text with html formatting:

but retrieving the text just gives me plain text.
19 years ago
gotcha. thanks for the info both of you.
19 years ago
like.... HHHEEEELLLLPPP

please...

tried implements AWTEventListener but eventDispatched never gets called...
19 years ago
Hi,

I have a window that I want to keep in the back at all times behind all windows. It should ignore mouse clicks, or not ever get to be the front. infact the whole program should be in the background at all times.

how would i go about this?
i have tried adding a mouselistener with mouseClicked( MouseEvent e ) { JFrame.toBack(); }
but thats already too late... because then the window comes to the front and covers all running applications windows before it is sent back and its not what I want.

I think I want to somehow stop the EventDispatcher to not dispatch the event at all... but I need help.
19 years ago
if you already have all the Questions in a ResultSet, couldn't you just say



I dont know what type of data you have in your ResultSet. You don't need to go through the tracking vector, its just to keep track of which questions have already been used so they won't get repeated.
19 years ago
What I would do in your situation, is make 2 Vectors or something, one for keeping track of which random number has already been picked, and one for your 50 questions. Get a random number, and if it isn't in the first vector, add it to both vectors. After you added 50 random numbers to both vectors, use the vector with the 50 numbers as your question base. After the questions have been answered, you can toss the vector with the 50 numbers, and start over. this way your tracking vector keeps a list of which questions have already been answered. the rest is just extracting the question from the ResultSet based on its random row number from your returned array.

19 years ago
hello everyone,

i want to add text to a JEditorPane. this works great:
JEditorPane.setText( "<strong>this is bold text</strong> this is not" );
what about if i want to add text?
JEditorPane.getDocument().insertString( int, "<strong>Bold</strong>plain", AttributeSet );
this just puts "<strong>Bold</strong>plain". how can i format it before it gets added? I dont want to have to use
alltext += "<strong>Bold</strong>plain";
JEditorPane.setText( alltext );

Im guessing its something with EditorKits or HTMLDocuments or something? but I dont understand the documentation.
Alex
19 years ago
hi,
this sounds like a trick question.... but what the heck... tell me why you wouldn't just put

I would recommend to use the the code tags to make your code look neat. otherwise its hard to read.
19 years ago
Hi,
I was wondering why some of my programs are daemons and some not. for example, I created this class that executes commands on my other computer like ssh but without the security the structure is somewhat like this

nowhere in that class have i called Thread.setDaemon(true), but it still wont show itself on run.
this other class I made recently basically has the same structure but won't run as a daemon. I tried extending thread and setDaemon( true ) before start() but it wont hide. It implements ImageObserver and utilizes the Robot class. Thats the only big difference I can see between the two classes. Does anyone have any ideas about why my later class wont hide? I would also be interested in why my first class is a daemon when I didn't even ask it to be. I can post the code if neccessary.
Thanks.

Edit: just tested the later class on windows XP and it is a daemon. not so on mac OS X. im confused. does apple change their version of the VM so much that it would do that? maybe apple thought Robot and daemon are a bad combination? or imageobserver expects you to display something anyways?
[ December 06, 2004: Message edited by: Alex Wolf ]
19 years ago
hello again Sanjul,
im guessing your problem with the the Character class is because char and Character are not the same thing. here is some sample code to help you check for integers.

then you should put a try catch thing around the whole thing, and make a catch statement similar to this


if you want the server and the client to throw the exception then I would check the user input, and set a boolean if there were errors, send the text to the server and after that, if there were errors throw the exception, because if you throw the exception before you send the data, the server wont throw an exception...

Till next time.

or check the input after you have sent it.
[ December 06, 2004: Message edited by: Alex Wolf ]
Hello again,
ok i "looked into it", but i can't see a problem. I have tried it using a PC with windows XP running the server, and my macintosh OSX running the client. it works flawlessly. I put the IP address of the Windows XP computer here -> String hostName = "192.168.0.1"; and it worked just fine. I dont know how to fix your problem. It must have something to do with your computer. As far as fixing anything on windows, i'd say delete everything and reinstall - correct me if im wrong . do you have any other computers you could try it on?
Hi Bhushan,
I can't help you with proxy servers because i dont know how to make one, therefore since you offered, it would be cool if i could see the code to understand how a proxy server works, or at least how it partially works since you still have problems.
regards,
Alexander
ok i think i know what you want.
basically you want to read a website with a httpurlconnection, then you're searching for the variable from the what you read, and then you need to make a POST to the site, for like a form or so.

I'd suggest you read through the documentation of URLConnection and HttpURLConnection.



this is just the posting part. im too lazy to experiment for you, so you'll have to do the first part yourself. I hope this helps you somewhat. Just read the documentation, and collect examples.
good luck
hello Sanjul,

I have tried your program. Although I have not tried using it over a network, there's no reason it shouldn't. Make sure you are not using a firewall or router between the computers you are testing your program on. I put my own IP instead of "localhost" as default server, but that doesn't mean much.

Check out java.lang.Character, it has a method "isDigit()" and "getType()" which might be usefull for checking the users input.

Another note, if the client is restarted, your "sum" variable needs to be reset, otherwise you will add the new values to the previous sum.

good luck.
hi Seshan,
you should check out the
FTPBean. thats what I used for FTP for java. It even has an example to get you started.
Good luck.