Gary Bryan

Greenhorn
+ Follow
since Sep 16, 2000
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 Gary Bryan

Thanks, but what I was trying to do was to append HTML to a textpane (or editor pane) which already has HTML in it. Thanks for the example anyway, it might come in useful sometime.
19 years ago
How do you insert HTML into a JTextPane? I am trying to just append HTML to the end of the text pane. I tried
text.setText(text.getText() + "
new text");
but I got an EmptyStackException.
I also found an insertHTML method in HTMLEditorKit, but it has loads of arguments that I don't know the purpose of. I just want to append HTML to the textpane!
20 years ago
You need to set the layout manager to null, add the textfield to the container you want it on, then use the setLocation method to set its position.
(on the container you want)
TextField tf;
...
tf = new TextField(10);
add(tf);
setLayout(null);
...
public void mousePressed(MouseEvent e) {
tf.setLocation(50, 50);
}
would set the location of the textfield's top-left corner to 50,50.
If you want to set it to where the mouse was clicked, use
tf.setLocation(e.getPoint());
Hope this helps.
20 years ago
I am trying to move items in a List (on 1.0) up or down. I thought of the code below, but it doesn't work.
else if (t == up) {
String goingDownItem = topList.getItem(topList.getSelectedIndex() - 1);
String goingUpItem = topList.getItem(topList.getSelectedIndex());
topList.replaceItem(goingDownItem, topList.getSelectedIndex());
topList.replaceItem(goingUpItem, topList.getSelectedIndex() - 1);
topList.select(topList.getSelectedIndex() - 1);
return true;
}
else if (t == down) {
String goingDownItem = topList.getItem(topList.getSelectedIndex());
String goingUpItem = topList.getItem(topList.getSelectedIndex() + 1);
topList.replaceItem(goingUpItem, topList.getSelectedIndex());
topList.replaceItem(goingDownItem, topList.getSelectedIndex() + 1);
topList.select(topList.getSelectedIndex() + 1);
return true;
}
where t is the event's target.
The idea is that the text of the selected item, and the text of the item item above it (for moving up) or below it (for moving down) are put into Strings, then they are replaced with each other. I get a lot of strange effects with items not moving, staying the same, moving to the top of the list, etc.
20 years ago
I found out that the problem was that I hadn't started rmiregistry running. The tutorial on Webmonkey didn't mention anything about rmiregistry. It also didn't mention making stub and skeleton classes, which took me a while to work out.
Anyway, I seem to be having another problem. I get an exception which says it can't find the stub file (GBChatServer_Stub.class) which does exist. I have checked the class path and everything.
20 years ago
I found out my IP address by going to the TCP/IP control panel on my computer, and it wasn't the same one that came up on "connected to:" on the dial-up program. I also used the BT Internet website, which tells you your IP address ( http://www.btinternet.com/new/content/mybti/ip_address.shtml ).
I also thought that RMI automatically used the port 1099. When I have used sockets before, I used other ports (like 4444, 666, 1405, etc.), so I thought it could be that particular port that doesn't work.
I haven't got to the stage of trying the client at a friend's house, because I can't get the server to start.
20 years ago
I have been trying out a RMI chat client and server which I got from a site, and I plan to adjust it a bit. The site was WebMonkey.
I was wondering if I would be able to run a server from my computer, on which I have a dial-up connection, and run the client from a friend's house by finding out my IP address and getting my friend to type it in to his computer, so the client connects to it (or something like that). I tried that and I got an exception that said:
Server error:
java.rmi.ConnectException: Connection refused to host: [host62-7-118-194.btinternet.com:1099]; nested exception is:
java.net.ConnectException: OpenTransport error -3260; connection refused
This seems to mean that my ISP won't let me do this. Is there another way? I have been able to use ServerSockets and Sockets without any problems.
[This message has been edited by Gary Bryan (edited March 06, 2001).]
20 years ago
I have written an applet, and when I try to load it on the Internet, i get an error like the above. It works fine locally, it's just on the Internet it doesn't work. The applet fails to load because of this.
------------------
--
Gary Bryan
20 years ago
I have been making a "love test" program, but I need something that lets the user input 2 names (one at a time). I have tried something like this:
String name1 = System.in.something();
String name2 = System.in.something();
but I've read about InputStreams, DataInput and stuff like that, so it can't be that simple. I have looked at the Sun tutorial on Standard In, Out and Error, but the bit for In is still under construction.
Please help, I've tried 2 newsgroups and another message board
------------------
--
Gary Bryan
20 years ago