DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2005
    Posts
    8

    Unhappy alighnments in applet!

    hey mates

    is there away to increase the width of awt Lists (as shown in the image)? and is there a way to display the buttons next to the list in the shown way?



    if the images doesnt appear, right click on it>>>show picture
    thanks

  2. #2
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    This should do it.

    Code:
    import java.awt.*;
    import java.awt.event.*;
    /**
     * A panel with a  List and a button panel
     */
    class AWTListPanel extends Panel implements ActionListener {
      List list=new List();
      Button b1=new Button("Clear Fields");
      Button b2=new Button("Add Item");
      Button b3=new Button("blabla");
      Button b4=new Button("bbabbala");
      Panel btnPan=new Panel(new GridLayout(4,1,4,4));
    
      public AWTListPanel () {
        super(new BorderLayout());
        add(list, BorderLayout.CENTER);
        btnPan.setBackground(Color.gray);
        btnPan.add(b1);
        btnPan.add(b2);
        btnPan.add(b3);
        btnPan.add(b4);
        add(btnPan, BorderLayout.EAST);
        b1.addActionListener(this);
        b2.addActionListener(this);
        b3.addActionListener(this);
        b4.addActionListener(this);
      }
      public void actionPerformed(ActionEvent ae) {
        System.out.println("Got:"+ae.getActionCommand());
      }
    
      public static void main(String[] args) {
        AWTListPanel pan=new AWTListPanel();
    
        Frame f=new Frame("List Test");
        f.add(pan);
        f.setBounds(100,100,400,120);
        f.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
        f.setVisible(true);
      }
    }
    eschew obfuscation

  3. #3
    Join Date
    Aug 2005
    Posts
    8
    oh bless u thanks alot, i'll have a try and let u know how it goes...
    the good think that makes me feel better is that i had a feeling i will need to use Panal

    now i started thinking
    thanks
    hannah

  4. #4
    Join Date
    Oct 2005
    Posts
    5
    Hi Sjalle, I tried running your code, the compilation is ok, but the applet wont start with the ff error:

    java.lang.ClassCastException

    thanks

  5. #5
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560

    Applet ?

    Hi Sjalle, I tried running your code, the compilation is ok, but the applet wont start with the ff error:

    java.lang.ClassCastException
    You are not running my code. I posted an application, not an applet,
    and there is no place in that application where a class cast is even attempted.



    eschew obfuscation

  6. #6
    Join Date
    Oct 2005
    Posts
    5
    Ooopppss, sorry Sjalle, my fault, too many windows and I compiled the wrong code. Sorry, your application is running great...

    thanks and my apologies...

Similar Threads

  1. JavaMail applet problem
    By Tataroz T. in forum Java
    Replies: 1
    Last Post: 10-20-2005, 06:19 AM
  2. Replies: 3
    Last Post: 08-23-2001, 11:01 AM
  3. applet and thread problems
    By aneesha in forum Java
    Replies: 0
    Last Post: 05-06-2000, 10:38 PM
  4. Applet and thread problems
    By Aneesha in forum Java
    Replies: 0
    Last Post: 05-06-2000, 10:36 PM
  5. Replies: 0
    Last Post: 03-28-2000, 01:52 AM

Bookmarks

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


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links