Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Using a JLabel to use html elements

  1. #1
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default 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.

       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/Av1.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?
    Last edited by javapenguin; May 17th, 2012 at 10:01 PM.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,264
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default 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.

    Using a JLabel to use html elements

    I am locking this thread. Please keep discussions in the appropriate location

Similar Threads

  1. Using a JLabel to use html elements
    By javapenguin in forum AWT / Java Swing
    Replies: 1
    Last Post: May 17th, 2012, 09:43 PM
  2. Loop through JLabel and change JLabel
    By JoeBrown in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 11th, 2012, 12:52 PM
  3. Adding JLabel on other Jlabel
    By mike416 in forum AWT / Java Swing
    Replies: 3
    Last Post: March 29th, 2012, 11:50 AM
  4. JLabel
    By Poseidon in forum AWT / Java Swing
    Replies: 2
    Last Post: February 18th, 2012, 03:39 PM
  5. [SOLVED] ArrayList object's elements confusing??? doesnt replace the elements? set() method?
    By chronoz13 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: June 21st, 2011, 01:20 PM