buttons choice labels?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: buttons choice labels?

  1. #1
    Erdem Ates Guest

    buttons choice labels?

    Hi all,

    I am trying to write an applet using awt Button, Choice and Labels. With the
    code below can you please tell me why do the buttons dont apppear on applet
    but the choice and labels ??? when i remove the initComponents() function i
    can see the buttons but when i use the function the buttons are gone and
    there are only the choice and the labels.

    Thanks for your helps.

    public class SystemMonitor extends Applet implements ActionListener,
    ItemListener
    {

    private Button btnResetPortStats = new Button("Reset Port Stats");
    private Button btnResetSystemStats = new Button("Reset System Stats");
    private Choice portChoice;
    public void init()


    btnResetPortStats = new Button("Reset Port Stats");
    btnResetSystemStats = new Button("Reset System Stats");
    btnResetPortStats = new Button("Reset Port Stats");
    btnResetSystemStats = new Button("Reset System Stats");
    portChoice = new Choice();
    portChoice.add("Port1");
    portChoice.add("Port2");
    portChoice.add("Port3");
    portChoice.add("Port4");

    add(btnResetPortStats);
    add(portChoice);
    add(btnResetSystemStats);

    btnResetPortStats.addActionListener(this);
    btnResetPortStats.setActionCommand("Increase");
    btnResetSystemStats.addActionListener(this);
    btnResetSystemStats.setActionCommand("Decrease");
    portChoice.addItemListener(this);

    initComponents();
    }

    public void initComponents()
    {
    lHWClockText = new Label("HW Clock");
    lHWClock = new Label("");

    this.setLayout(null);

    lHWClock.setForeground(Color.darkGray);
    lHWClockText.setForeground(Color.darkGray);

    add(lHWClock);
    add(lHWClockText);
    }
    }



  2. #2
    MarkN Guest

    Re: buttons choice labels?


    Quick glance and - It doesn't look like you are using a layout manager or
    alternatively telling the applet where to place the objects.

    "Erdem Ates" <eates@daire11.org> wrote:
    >Hi all,
    >
    >I am trying to write an applet using awt Button, Choice and Labels. With

    the
    >code below can you please tell me why do the buttons dont apppear on applet
    >but the choice and labels ??? when i remove the initComponents() function

    i
    >can see the buttons but when i use the function the buttons are gone and
    >there are only the choice and the labels.
    >
    >Thanks for your helps.
    >
    >public class SystemMonitor extends Applet implements ActionListener,
    >ItemListener
    >{
    >
    >private Button btnResetPortStats = new Button("Reset Port Stats");
    >private Button btnResetSystemStats = new Button("Reset System Stats");
    >private Choice portChoice;
    >public void init()
    >
    >
    > btnResetPortStats = new Button("Reset Port Stats");
    > btnResetSystemStats = new Button("Reset System Stats");
    > btnResetPortStats = new Button("Reset Port Stats");
    > btnResetSystemStats = new Button("Reset System Stats");
    > portChoice = new Choice();
    > portChoice.add("Port1");
    > portChoice.add("Port2");
    > portChoice.add("Port3");
    > portChoice.add("Port4");
    >
    > add(btnResetPortStats);
    > add(portChoice);
    > add(btnResetSystemStats);
    >
    > btnResetPortStats.addActionListener(this);
    > btnResetPortStats.setActionCommand("Increase");
    > btnResetSystemStats.addActionListener(this);
    > btnResetSystemStats.setActionCommand("Decrease");
    > portChoice.addItemListener(this);
    >
    > initComponents();
    > }
    >
    >public void initComponents()
    > {
    > lHWClockText = new Label("HW Clock");
    > lHWClock = new Label("");
    >
    > this.setLayout(null);
    >
    > lHWClock.setForeground(Color.darkGray);
    > lHWClockText.setForeground(Color.darkGray);
    >
    > add(lHWClock);
    > add(lHWClockText);
    > }
    >}
    >
    >



  3. #3
    Erdem Ates Guest

    Re: buttons choice labels?

    Thanks Mark,

    but if that was the reason how could i be able to see the choice box ??
    "MarkN" <java.@127.0.0.1> wrote in message news:3d340ac8$1@10.1.10.29...
    >
    > Quick glance and - It doesn't look like you are using a layout manager or
    > alternatively telling the applet where to place the objects




  4. #4
    MarkN Guest

    Re: buttons choice labels?


    don't do this 'this.setLayout(null);'



    "Erdem Ates" <eates@daire11.org> wrote:
    >Thanks Mark,
    >
    >but if that was the reason how could i be able to see the choice box ??
    >"MarkN" <java.@127.0.0.1> wrote in message news:3d340ac8$1@10.1.10.29...
    >>
    >> Quick glance and - It doesn't look like you are using a layout manager

    or
    >> alternatively telling the applet where to place the objects

    >
    >



  5. #5
    Erdem Ates Guest

    Re: buttons choice labels?

    Thanks Mark that solved the prob.

    "MarkN" <java.@127.0.0.1> wrote in message news:3d355e59$1@10.1.10.29...
    >
    > don't do this 'this.setLayout(null);'




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center