This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Table in AWT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Table in AWT" Watch "Table in AWT" New topic
Author

Table in AWT

Ali Hassaan
Ranch Hand

Joined: May 16, 2001
Posts: 103
Can v made table in AWT.
I didnt find any class name Table in AWT.
Another problem i hav is of using Tab Pane ,v dont hav any utility of tabpane in awt.
Is CardLayout replacment for TabPane,If than how can v use it.
Pls help me out.
Sandeep Jain
Ranch Hand

Joined: Oct 25, 2000
Posts: 124
Hello,
There is no such component as Tables in AWT .What u can do is u can simulate the tables by ceating all TextField array . and can make to some extent say as tables.
The answer to the second question is yes , You can implement the functionalty of Tab Pane with CardLayout .How ever the problem come only as to the Look and Feel .
I am pasting a simple example.
Where there are two buttons On click of first Button u get some screen and On click of Second Button u get the Other Screen.

import java.awt.*;
import java.awt.event.*;
public class CardLayoutExample extends Frame implements ActionListener
{
Panel main,pan1,pan2;
TextField name_Text;
TextField age_Text;
Button first=new Button("first");
Button second=new Button("second");
Panel butt=new Panel();
CardLayout cardLayout=new CardLayout();
Choice choiceBox;

public CardLayoutExample()
{
butt.add(first);
butt.add(second);
Label name=new Label("Name");
name_Text=new TextField();
Label age=new Label("Age");
age_Text=new TextField();
pan1=new Panel();
pan1.setLayout(new GridLayout(2,2));
pan1.add(name);
pan1.add(name_Text);
pan1.add(age);
pan1.add(age_Text);
choiceBox=new Choice();
choiceBox.addItem("x1");
choiceBox.addItem("x2");
choiceBox.addItem("x3");
choiceBox.addItem("x4");
pan2=new Panel();
pan2.add(choiceBox);
setListeners();
setLayout(new BorderLayout());
main=new Panel();
main.setLayout(cardLayout);
main.add(pan1,"first");
main.add(pan2,"second");
add(butt,BorderLayout.SOUTH);
add(main,BorderLayout.CENTER);

}
private void setListeners()
{
first.addActionListener(this);
second.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==first)
{
cardLayout.next(main);
cardLayout.show(main,"first");
}
else
{
cardLayout.next(main);
cardLayout.show(main,"second");
}
}
public static void main(String arghs[])
{
CardLayoutExample c=new CardLayoutExample();
c.setVisible(true);
c.setSize(200,200);
}
}
------------------
Try and Try Till u succeed
Sandeep Jain


Try and Try Till u succeed<br /> <br />Sandeep Jain
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Table in AWT