Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7887217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:31:18+00:00 2026-06-03T05:31:18+00:00

I have in my app a chat component which has a JTextArea on it.

  • 0

I have in my app a chat component which has a JTextArea on it.
Now, how can I add an ActionListener-like event for a specific text (like student://xxxx)?

So when I click on that text (student://xxxx) something will happen.
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:31:20+00:00Added an answer on June 3, 2026 at 5:31 am

    Here try this small program, try to click at the start of student://, that will pop up a message Dialog

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    public class TextAreaExample extends JFrame
    {
        private JTextArea tarea =  new JTextArea(10, 10);
        private JTextField tfield = new JTextField(10);
    
        private void createAndDisplayGUI()
        {
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            tarea.setText("Hello there\n");
            tarea.append("Hello student://");
            JScrollPane scroll = new JScrollPane(tarea);
    
            tfield.addActionListener(new ActionListener()
            {
                public void actionPerformed(ActionEvent ae)
                {
                    tarea.append(tfield.getText() + "\n");
                }
            });
    
            tarea.addMouseListener(new MouseAdapter()
            {
                public void mouseClicked(MouseEvent me)
                {
                    int x = me.getX();
                    int y = me.getY();
                    System.out.println("X : " + x);
                    System.out.println("Y : " + y);
                    int startOffset = tarea.viewToModel(new Point(x, y));
                    System.out.println("Start Offset : " + startOffset);
                    String text = tarea.getText();
                    int searchLocation = text.indexOf("student://", startOffset);
                    System.out.println("Search Location : " + searchLocation);
                    if (searchLocation == startOffset)
                        JOptionPane.showMessageDialog(TextAreaExample.this, "BINGO you found me.");
                }
            });
    
            getContentPane().add(scroll, BorderLayout.CENTER);
            getContentPane().add(tfield, BorderLayout.PAGE_END);
            pack();
            setLocationByPlatform(true);
            setVisible(true);
        }
    
        public static void main(String... args)
        {
            SwingUtilities.invokeLater(new Runnable()
            {
                public void run()
                {
                    new TextAreaExample().createAndDisplayGUI();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used to have a small chat app(which was almost working), that uses PHP,
I'm writing a little chat app, and I have this event handler: void o_Typing(object
My app is a Wifi chat app with which you can communicate between two
For example. if I have a chat app that uses objects like: ChatRoom and
I have written an app that reads incoming chat(somewhat like an instant messenger), formats
I have a chat app which needs to save history (similar to the native
I have the following app, that's like a chat, so I'm programmatically creating some
I wanted to add a voice chat feature to my business app. I have
I have written a small chat app that uses mysql + php to facilitate
I have BlazeDS running in an instance of Coldfusion 8. A flex chat app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.