ok. my JLabel code looks like this

JLabel searchResult = new JLabel (" <html> Type something in the searchbar. <br>" + " Type what yo would like to search and suggestions will pop up in this text box </html>");

which seems to be correct according to your example, but it doesn't seem to work.

no it isn't

import java.awt.GridLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class GridLayoutCOnt extends JPanel {

    private static final long serialVersionUID = 1L;

    public GridLayoutCOnt() {
        setLayout(new GridLayout(3, 1));
        add(new JLabel("<html> QQQQQQQQQQQQ: <br>"
                + " - wwwwwwwwwwwwwwwwwwwwwwwwww <br>"
                + " - eeeeeeeeeeeeeeeeeeeeeeeeee <br>"
                + " - eeeeeeeeeeeeeeeeeeeeeeeeee </html> "));
        add(new JLabel(" <html> Type something in the searchbar. <br>"
                + " Type what yo would like to search and suggestions will pop up in this text box </html>"));

        add(new JLabel("<html> Type something in the searchbar. <br>"
                + " Type what yo would like to search and suggestions will pop up in this text box </html>"));
    }

    public static void main(String[] a) {
        JFrame f = new JFrame();
        f.addWindowListener(new WindowAdapter() {

            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        f.setContentPane(new GridLayoutCOnt());
        f.pack();
        f.setVisible(true);
    }
}

Ok I fixed the breaks and it works thanks. I implemented a link to email code into my JLabel using the

<a href=\"MailTo:EmailHere@EmailRovider.com\"> Email Me </a>

but the mouse doesn't seem to sense the email link. It shows up in blue, but the mouse doesn't change. what is the reason for this?

hmmm I really don't know

but ...
try this expamles depot which link I gave/sent you, or Google, cos I think that it must be possible

ok thanks and also how would I get a FileReader to read a file then assign what it reads into a string so that I could put it in as a text for a JMenuItem?

this is my attempted code

FileReader bM1NameReader;
			try {
				bM1NameReader = new FileReader ("bM1.txt");
			} catch (FileNotFoundException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
			bM1Name = bM1NameReader.read();
			if (bM1Name.equals(null)){
				bMMaker();
				
			}

Never mind. I figured it out.

Now I am having trouble putting this code

try {
				File file = new File ("bM1.txt");
				BufferedWriter out = new BufferedWriter (new FileWriter (file,false));
				
				out.write(bMNameGet);
				out.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			// writes link to website
			try {
				File file = new File ("\\Bookmarks\\bMLink1.txt");
				BufferedWriter out = new BufferedWriter (new FileWriter (file,false));
				
				out.write(bMURLGet);
				out.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

into the action performed. I get a duplicate parameter e error. thanks for the help.

this code

if ("bookmark add".equals(e.getActionCommand())){
			bMNameGet = bMName.getText();
			bMURLGet = bMLink.getText();
			if (bMNameGet.equals ("")){
				JOptionPane.showMessageDialog(null, "Enter a name!");
			}
			if (bMURLGet.equals("")){
				JOptionPane.showMessageDialog(null, "Enter a URL");
			}
			if (!bMNameGet.equals("") && !bMURLGet.equals ("")){
				try {
					File file = new File (writeBM);
					BufferedWriter out = new BufferedWriter (new FileWriter (file,false));
					
					out.write(bMNameGet);
					out.close();
				} catch (IOException g) {
					// TODO Auto-generated catch block
					g.printStackTrace();
				}
				// writes link to website
				try {
					File linkFile = new File ("\\Bookmarks\\" + writeBMLink);
					BufferedWriter linkOut = new BufferedWriter (new FileWriter (linkFile,false));
					
					linkOut.write(bMURLGet);
					
				} catch (IOException f) {
					// TODO Auto-generated catch block
					f.printStackTrace();
				}	
				BufferedReader reader;
				String setBM;
				try {
					reader = new BufferedReader (new FileReader ("bM" + bM + ".txt"));
					try {
						setBM = reader.readLine();
						if (bM == 1){
							bM1Name = setBM;
						}
					} catch (IOException g) {
						// TODO Auto-generated catch block
						g.printStackTrace();
					}
				} catch (FileNotFoundException h) {
					// TODO Auto-generated catch block
					h.printStackTrace();
				}
				
			JOptionPane.showMessageDialog (null, "Bookmark has been added");
			bookmarks.dispose();
			}
		}

gives me a java.io.FileNotFoundException error. the file is located in a folder called Bookmarks and inside the folder there is a file called bMLink1.txt which is set as the writeBMLink string. The red part is where I get the error. Thanks for the help.

Never mind I figured this one out aswell. I didnt need the \\ before the folder. Now I have another question. I have a JMenuBar > JMenu > JMenuItem I would like to update the JMenuItem when the user add a bookmark. How would I do this?

Write the following code :
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource==b2) //object of button
t1.setText(""); //t1 object of Jtext field
}

Thanks I got it.

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.