java - Why am I unable to select all the text when clicking a button? -


i new gui based java programming , query.

import java.awt.*; import java.awt.event.*; class panels  {   static frame f; static textarea t;   public static void main(string...xyxxcxcx)    {      f=new frame();      f.setlayout(new flowlayout());      f.setsize(400,300);      t=new textarea(); button b=new button("select all");      f.add(b); f.add(t);      t.settext("step ring game");      b.addactionlistener(new actionlistener()         {            public void actionperformed(actionevent e)                 {                     t.selectall();                 }             }                 );      f.setvisible(true);   }  } 

when click "select all" button, expect text present in text area selected. not happening. please advise.

it is happening, textareabut button has focus, never see it. if tabbed on textarea, you'd see text selected.

what if called

public void actionperformed(actionevent e) {     t.selectall();     t.requestfocusinwindow(); } 

question: why use awt library? it's 20 years out of date.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

android - CollapsingToolbarLayout: position the ExpandedText programmatically -

Listeners to visualise results of load test in JMeter -