Using a JLabel to use html elements
I was able to create a, very poor, textarea with the html and textarea tags inside a JLabel. However, it's not letting me really alter the cols that much. Also, it won't do textfield.
Also, how do I access the value of my textarea inside the JLabel? And how do I get the JLabel to do an href, i.e. become a link? I got the blue underline but it's not going anywhere.
Code java:
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.GridLayout;
import javax.swing.JScrollPane;
public class LabelFormExample extends JFrame
{
private JLabel form;
private JPanel contentPane;
public LabelFormExample()
{
super("Form");
contentPane = new JPanel();
setContentPane(new JScrollPane(contentPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
setDefaultCloseOperation(EXIT_ON_CLOSE);
form = new JLabel("<html><form><textarea rows=30 cols=30> <br/> Wenguin <br/> <textfield> </textfield> <A HREF=http://www.w3schools.com/tags/att_textarea_cols.asp> Mongoose </A></form></html>");
System.out.println(form.getText());
contentPane.add(form);
contentPane.setLayout(new GridLayout(4,1));
contentPane.add(new JLabel("<html><A href=http://www.w3schools.com/tags/att_textarea_cols.asp> Website </A></html>"));
setVisible(true);
contentPane.add(new JLabel("<html><textfield text=mongoose></textfield></html>"));
contentPane.add(new JLabel("<html><img src=C:/Users/Wenguin/Documents/Rikki2/Rikki2/Avíá1.jpg></img></html>"));
}
public static void main(String[] args)
{
new LabelFormExample();
}
}
Seriously, how do you turn a JLabel into a hyperlink?
What happened to my thread?
Seriously, is there a way to incorporate html elements in Java GUI's?
What I was confused on was how come my textarea inside the JLabel couldn't expand beyond a certain amount of columns.
This also might be useful if trying to make a JApplet also have an html form in it.
Why the heck was my thread deleted?
Re: Using a JLabel to use html elements
You should know the forum rules and rhythm by now - your thread was not deleted, it was moved to the appropriate category.
http://www.javaprogrammingforums.com...-elements.html
I am locking this thread. Please keep discussions in the appropriate location