-
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
-
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
-
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
-
Hi Sjalle, I tried running your code, the compilation is ok, but the applet wont start with the ff error:
java.lang.ClassCastException
thanks
-
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
-
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
-
By Tataroz T. in forum Java
Replies: 1
Last Post: 10-20-2005, 06:19 AM
-
By Charlie Flynn in forum Java
Replies: 3
Last Post: 08-23-2001, 11:01 AM
-
Replies: 0
Last Post: 05-06-2000, 10:38 PM
-
Replies: 0
Last Post: 05-06-2000, 10:36 PM
-
Replies: 0
Last Post: 03-28-2000, 01:52 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
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
|
Bookmarks