• 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

I have a doubt

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I put a text area under a text field in a swing GUI. Will the code be different from the one where I put a text area to the side of a text field? How do we determine the position of the text field and text area relative to each other?
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This depends completely on the LayoutManager you are using (e.g. BoxLayout, BorderLayout, etc.).
Check out Sun's tutorials on Using Swing Layout Managers on their website.
Bill
 
Priya Pichamuthu
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks. But how do I write sentences in different colors on a GUI? Like I have a sentence
static string s = "Sparky the Dog";
How do I make it appear on the GUI in red color?
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You have to create labels out of the text and set their foreground color to the desired color and then add them to the content pane.
import java.awt.*;
import javax.swing.*;
static String someText = "Java";
JLabel label = new JLabel(someText);
label.setForeground(Color.red);
getContentPane().add(label);
It depends upon the layout manager where you add the created label.I have put it in the content pane.
Regards,
vikalp_setya@rediffmail.com
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic