somebody know how to make the text which is in the text field on click to disapear
ex: If saying "Search" when ill click on the text field the text to disapear and i can write ...
Thanks ! :)

You can just do it by javascript.
Onclick event just change the element value with "".
For eg:-

<script>
function makeBlank()
{
document.getElementById("search").value="";
}
</script>

<input type="text" value="Search" onclick="makeBlank();" id="search">

wait i dont get this where to put this and there is no other way of doing this ?

Is this for Java using applet/swing or J2EE?
If it is for J2EE then add it in your html page.Otherwise i will reply for Java swing/applet.
Please show your code ,so that we can help.

look i have notes program and i want at the textfield for name to write "Enter name" and in noteArea to write "Place some notes" and when you will click on one of theese to disapear and you continue writing so its not for online purposes hope you understand what i mean ..

and also it is swing/applet its started in NetBeans....

show ur code snippet then only i can help.

dude there is no code for what im looking for just simple program made by NetBeans but nvm here is the code for my project ...

this is for Save Button

private void SaveButtonActionPerformed(java.awt.event.ActionEvent evt) {                                         
        FileReader freader = null;
        try {
            File folder = new File(mainAccName);
            String notename = nameOfNote.getText();
            String noteareaa = noteArea.getText();
            if (notename.isEmpty() || noteareaa.isEmpty()) {
                if (notename.isEmpty()) {
                    if (noteareaa.isEmpty()) {
                        LabelInfo.setText("You must have name and note");
                    } else {
                        LabelInfo.setText("You dont have name");
                    }
                } else {
                    LabelInfo.setText("You dont have note");
                }
                return;
            }
            File file = new File(folder, "Notes.txt");
            FileWriter filewriter = new FileWriter(file);
            BufferedWriter out = new BufferedWriter(filewriter);
            out.write("Name: " + notename);
            out.newLine();
            out.write("Description: " + noteareaa);
            out.newLine();
            out.write("---------------------------------------------------------------");
            out.newLine();
            out.close();
            this.dispose();
        } catch (Exception ex) {
            noteArea.setText("Something bad happened !\n");
            noteArea.setText("The text can't be saved !");
        }

This is for Review Button

private void ReviewButtonActionPerformed(java.awt.event.ActionEvent evt) {                                         
        try {
            File folder = new File(mainAccName);
            String Notename = nameOfNote.getText();
            String notearea = noteArea.getText();
            Desktop desktop = null;
            if (Desktop.isDesktopSupported()) {
                desktop = Desktop.getDesktop();
            }
            File file = new File(folder, "Notes.txt");
            FileReader filereader = new FileReader(file);
            BufferedReader out = new BufferedReader(filereader);
            desktop.open(new File(folder, "Notes.txt"));
        } catch (IOException ioe) {
        }
    }

After a few experiments I find that I get good results with implementing a custom JPanel to hold a JTextField. Instead of putting the text in the JTextField's Document, I override paint on the JPanel so that I can draw over the children of the panel and use that to draw the text I want over the JTextField if the field is empty and doesn't have focus. I also add a FocusListener that calls repaint() on my custom JPanel for the field losing or gaining focus.

This way you don't have to deal with any complications from having the text that you want to disappear being actually in the field. You don't have to worry about confusing your text with text that the user actually entered, and if the user leaves the field blank your text reappears.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.