• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Khalid Programming Ex. 12.1

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The following program works fine but I am not able to set black as the background color in the textarea. How can I do it. Thanks in advance.
import java.awt.*;
class MyTextArea
{
public static void main(String args[])
{
Frame f = new Frame("Black");
TextArea ta = new TextArea("Non editable", 5,
10, TextArea.SCROLLBARS_NONE);
ta.setEditable(false);
ta.setForeground(Color.yellow);
ta.setBackground(Color.black);
f.add(ta);
f.setSize(200,200);
f.setVisible(true);
}
}
 
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.awt.*;
class MyTextArea
{
public static void main(String args[])
{
Frame f = new Frame("Black");
TextArea ta = new TextArea("Non editable", 5,
10, TextArea.SCROLLBARS_NONE);
ta.setEditable(false);
ta.setForeground(Color.white);
ta.setBackground(Color.black);
f.add(ta,"North");
f.setSize(200,200);
f.setVisible(true);
}
}
/*Hi,
Your code is running perfectly fine.I have changed the code a little bit and see the difference.Friend,u have added the textarea in the center(by default)of the frame, therefore, it occupies the entire frame.*/
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic