• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

DRAW A NEW LINE

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am new to designing applets.
This is a simple question, How do you cause a line space in an applet. I tried System.out.println but this doesnt work.
I want a radio group to start in a new line.
here is my code:
import java.awt.*;
import java.applet.Applet;
public class myapplet1 extends Applet {
public void init() {
setBackground(Color.lightGray);
setForeground(Color.red);
TextField t = new TextField("Default Data");
t.setBackground(Color.white);
add(t);
Button b = new Button("Click");
add(b);
Checkbox c = new Checkbox("Select", false);
add(c);
//I want the line space here
CheckboxGroup group = new CheckboxGroup();
Checkbox g1 = new Checkbox("1",false,group);
Checkbox g2 = new Checkbox("2",false,group);
Checkbox g3 = new Checkbox("3",true,group);
add(g1);
add(g2);
add(g3);
}
}
If there are any problems with the code that you can notice please DO tell me.
Thanks in advance.
Zahid
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Zahid,
The default layout of an Applet is FlowLayout. This makes all components added to it line up like words in a sentence until one hits the edge of the screen. Then it starts over far enough down to put space between the components. One thing you could do is set your applet's layout to GridLayout... if you specify one column and as many rows as you have components they will all line up one above the other.
If you have a complex layout in mind, you will have to create a layout for your applet, then add components to panels with layouts of their own... you can nest other panels within these panels too if you want...
HTH,
-Nate
 
This is my favorite show. And this is my favorite tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic