|
How can I use hashtable to count the appearances of some items in a file.
Query the hashtable for the key before you stick it in. It it doesn't exist, add the key with value 0. If it exists, get the key's value, add 1 to it, and reinsert it into the hashtable. When you're done, the values of all keys will be the # times they were added.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I meant add it with value 1, not zero.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hello,
I am fairly new to Java and I'm trying to create a
simple application.
I need it to create an editable TextArea on the
screen and then read the text which the user types in
there and display it in a Frame after manipulating the
text in some way, e.g. setting a particular font or
size of font or colour of font.
I am sure this is fairly easy.
I know how to create an editable TextArea on the
screen however I'm not sure what to so from there.
I need to somehow pause the program until the user has
entered their text and then use the getText method () on
TextArea and assign this to a string.
I then need to manipulate the string and create a Frame and
display it in the paint method using drawstring, how
do I manipulate the text to set the font type, font
size and font colour etc??
Any ideas appreciated, I may be approaching this the
wrong way!
Here is what I have so far;
Jon.
import java.awt.*;
import java.io.*;
import java.awt.event.*;
class IOExample extends Frame {
IOExample (){
addWindowListener (new MyListener());
}
public static void main (String args[]) throws IOException {
IOExample n = new IOExample();
TextArea textarea = new TextArea(100,100);
textarea.setEditable(true);
n.add(textarea);
n.show();
//need to pause here until the user has finished input. Not sure how to
//do this
String formatstring = textarea.getText();
//need to manipulate the string in some way, and I should be able to
//create new frame and display the text....
}
}
class Mylistener extends WindowAdapter{
public void WindowClosing (WindowEvent e) {
System.exit(0); } }
|
|
|
|
|
Hi Jon
Soln's Prety Simple ,
//--- your code --
public static void main (String args[]) throws IOException {
IOExample n = new IOExample();
TextArea textarea = new TextArea(100,100);
textarea.setEditable(true);
//--- Add A button HERE and add ActionListener
n.add(textarea);
n.show();
//STOP - Dont Use GetText() Here!
}
In the ActionPerformed Method of the class, Use getText().
Dont forget this..
class IOExample extends Frame implements ActionListener {
=========================
Let the TextArea, and Button be Members of the Class
IOExample and Initialize them in the Constructor.
|
|
|
|
|
The following Java class implements hashing with open addressing,using quadratic probing to resolve collisions.When I try to compile it (using microsoft's visual java),it gives me this error:Undefined name 'OpenAddressException' at line32.Could someone please tell me what is wrong with it?
[jkouris@hotmail.com]
---------------------------------------------------------------------------------------------------
public class OpenAddress
{
private int[] Element;
private int TableSize;
private int EmptyCell;
OpenAddress(int tablesize)
{
int index;
TableSize=tablesize;
EmptyCell=0;
Element=new int[tablesize];
for(index=0;index
|
|
|
|
|
change
throw new OpenAddressException("Element not found in table.");
to
throw new Exception("Element not found in table.");
|
|
|
|
|
|
I have tried setSize(), setBounds(), setMinimumSize(), setMaximumSize(), setPreferredSize(), and none of them work. The button takes up the entire applet window. Also, my applet shows up fine when I use appletviewer but when I put it in a webpage it doesn't show up. Any ideas? All input is appreciated.
|
|
|
|
|
It's been awhile since my java days -- but my first guess for you is to pick the correct layout manager.
The layout manager takes precedence over your sizing.... Is there still an XYLayout?
|
|
|
|
|
I am not familiar with layouts. Guess ill have to go reaserching =). Tnks for the reply.
|
|
|
|
|
Objects in a window are sized dynamically by the layout manager. If you don't specify a particular layout manager the default one is FlowLayout.
The layout manager asks the component for it's preffered size, then usually sets it's size to that (if it finds enough space).
If you really need to take control over an component's size they you probably need to subclass the component and override the getMinimumSize and getPreferredSize methods.
|
|
|
|
|
Anyone could suggest a book to a beginner who wants to learn Java 2 and takes the SL-275 exam?
Thanks
|
|
|
|
|
Hail all.
I have a question on LDAP. If I have a LDAP server with only supporting anonymous connection. Could I actually do authentication using users and passwords as stored in LDAP server? Thus I will make a open anonymous LDAP connection and then sending the user name and password to actually check whether there is an entry in there matching that user name (DN) with that password.
However, when I looked at the attributes in an entry (using anonymous connection again), I could not see user password as one of the attributes.
Then my question is, is it possible to do authentication using the method that I described above? Is there any API I could use (open to C++ or java)?
Any other method that I could make use anonymous connection to do authentication for LDAP ?
Thanks
|
|
|
|
|
I want to write a programme in Java which can connect a website and return data from the website( like its opening page, and its source eg. HTML code or Java script code of that site )...
i can use:
java.net.url myUrl = new URL("http://www.mySite.com");
But how to connect this site if i am using proxy setting.And again how to show the content of this site ?
Thanks in advance
Regards
Aminur
|
|
|
|
|
How can i add some text boxes through javascript
i have a form having some controls already now i wanna add some more controls below existing controls.
Pls tell me the solution as i am new to javascript
|
|
|
|
|
The method of making radical changes in screen contents from javascript (Called Dynamic HTML) is basically to overwrite a chunk of the HTML.
But you generally need to replace the whole contents of a particular tag.
So you might rewrite the hmtl for your whole form.
You do this by setting the "innerHTML" property of the element you're changing the contents of to a string value containing the new HTML code.
You can, of course, put in tags just for this purpose, typically I use tags with IDs.
If you just have some fields that are only shown sometimes it's generally easier to just mark them hidden in the HTML and use the javascript to change their style.visibility property to vissible.
|
|
|
|
|
Hi ! Hope you all be fine
I want to move a selected text in a JTextField from a location to another by pressing the mouse on selected text and dragging it to newer
location in the same textfield(Like Microsoft word) how to do it with my JtextField.Will u help me out please
Regards
Aminur
|
|
|
|
|
hi folks
Can u give me an idea for developing an application in java which receives and sends SMS messages.
get bac to me as soon as possible if u have any suggestion
thanking u in advance
BSR
BSR
|
|
|
|
|
In order to send SMS messages you will probably need a gateway of some variety. There are a few vendors that supply the hardware/software (nokia do one I think) or you can buy a service from a online SMS gateway provider where you will be charged per SMS. The interface to these is normally http so you will just need to use the standard java.net packages to send a message from your app. I ended up having my app sending emails to my gateway provider who converts these to SMSs.
I have also seen some people use a phone (or a PCMCIA card) connected to the PC to build their own gateway - it all depends on if you can find a phone that you can connect in this way...and have the patience to tease it into life. Chances are you will need to do some JNI too.
hope that helps,
matt
sonork [100.10146:bishboy]
|
|
|
|
|
I want to develope java application taht have an interfce. This application will be run on all those OS which java supports e.g. Windows, Unix, Solaris ...
Which classes i use to design interface that will be good for all OS.
I also want to create text file in this application on C drive in any directory. How i handle the path slashes in different OS.
|
|
|
|
|
I am developing a java application and i want to get the Operation System Info. that which OS in installed on machine.
|
|
|
|
|
System.getProperties(System.out)
then you can find your os type.
|
|
|
|
|
Anyone know an easy way do get the "client area" of a JFrame? I'm not using a layout manager. I need to know the size of the window *not* including the title bar. I'm writing code in the constructor of the frame. I tried getInsets, but it always returns 0's.
Thanks,
sbl
|
|
|
|
|
I don't think a container has a size or position at this point.
|
|
|
|
|
You are correct. I just had to set the size to arbitrary values (10,10,10,10) and show it. Then getinsets returned the proper info. I then just hide it, size it correctly and carry on.
Thanks,
sbl
|
|
|
|