visualproject
Author: rawan |
12/15/09 03:31 |
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyWindow extends JFrame implements ActionListener
{
public static final int WIDTH=300;
public static final int HEIGHT=200;
private JTextField subjectTextField,startTextField,dueTextField, priorityTextField,
doneTextField,notDoneTextField;
public static final int LINES=2;
public static final int CHAR_PER_LINES=10;
private JTextArea theText,theTic;
public MyWindow()
{
setTitle("Main window" );
setSize(WIDTH,HEIGHT);
getContentPane().setLayout(new FlowLayout());
getContentPane().setBackground(Color.BLUE);
JLabel ttuLab= new JLabel("i");
ImageIcon ttu = new ImageIcon("ttu.gif");
ttuLab.setIcon(ttu);
getContentPane().add(TtuLab,BorderLayout.WEST);
JButton insertButton= new JButton("insert");
insertButton.addActionListener(this);
getContentPane().add(insertButton);
JButton retriveButton = new JButton("Retrive");
retriveButton.addActionListener(this);
getContentPane().add(retriveButton);
}
{
JFrame x2=new JFrame();
x2.setTitle("Hello");
x2.setSize(WIDTH,HEIGHT);
getContentPane().setLayout(new BorderLayout());
getContentPane().setBackground(Color.PINK);
JPanel userPanel = new JPanel();
userPanel.setLayout(new GridLayout(1,1));
userPanel.setBackground(Color.YELLOW);
JLabel subjectName = new JLabel(" subject name:");
userPanel.add(subjectName);
subjectTextField = new JTextField(20);
getContentPane().add(userPanel,BorderLayout.WEST);
JMenu statusMenu= new JMenu("status");
JMenuItem s;
s= new JMenuItem("in progress");
s.addActionListener(this);
statusMenu.add(s);
s= new JMenuItem("completed");
s.addActionListener(this);
statusMenu.add(s);
s= new JMenuItem("deferred");
s.addActionListener(this);
statusMenu.add(s);
JMenuBar sBar= new JMenuBar();
sBar.add(statusMenu);
setJMenuBar(sBar);
JPanel textPanel =new JPanel();
textPanel.setBackground(Color.BLUE);
theText = new JTextArea(LINES,CHAR_PER_LINES);
textPanel.add(theText);
theText.setBackground(Color.WHITE);
JScrollPane ScrolledText = new JScrollPane(theText);
ScrolledText.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
ScrolledText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
textPanel.add(ScrolledText);
getContentPane().add(textPanel,BorderLayout.CENTER);
JPanel myPanel = new JPanel();
myPanel.setBackground(Color.WHITE);
myPanel.setLayout(new GridLayout(3,2));
JLabel startLabel = new JLabel("start date:");
myPanel.add(startLabel);
startTextField = new JTextField(20);
myPanel.add(startTextField);
JLabel dueLabel = new JLabel("Due date:");
myPanel.add(dueLabel);
dueTextField = new JTextField(20);
myPanel.add(dueTextField);
JLabel priorityLabel = new JLabel("priority:");
myPanel.add(priorityLabel);
priorityTextField = new JTextField(20);
myPanel.add(priorityTextField);
getContentPane().add(myPanel,BorderLayout.SOUTH);
}
JFrame x3=new JFrame();
{
x3.setTitle("hello");
x3.setSize(WIDTH,HEIGHT);
x3.getContentPane().setLayout(new BorderLayout());
x3.getContentPane().setBackground(Color.RED);
JLabel subLabel = new JLabel("the subject name you Entered is");
x3.getContentPane().add(subLabel);
x3.getContentPane().add(subLabel,"NORTH");
JMenu chooseMenu = new JMenu("choose");
JMenuItem c;
c = new JMenuItem("done");
c.addActionListener(this);
chooseMenu.add(c);
c = new JMenuItem(" not done");
c.addActionListener(this);
chooseMenu.add(c);
JMenuBar cBar= new JMenuBar();
cBar.add(chooseMenu);
setJMenuBar(cBar);
JPanel ticPanel = new JPanel();
ticPanel.setBackground(Color.YELLOW);
theTic = new JTextArea( LINES,CHAR_PER_LINES);
ticPanel.add(theTic);
x3.getContentPane().add(theTic,BorderLayout.EAST);
}
public static void main (String[] args)
{
JFrame x3= new JFrame();
MyWindow object1 = new MyWindow();
object1.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
JFrame x2= new JFrame();
if(e.getActionCommand().equals("insert"))
{
x2.setVisible(true);
{
if (e.getActionCommand().equals(" in progress"))
theText.setText("in progress");
else if (e.getActionCommand().equals("completed"))
theText.setText("completed");
else if (e.getActionCommand().equals("deferrd"))
theText.setText("deferred");
else
theText.setText("error");
}
}
{
if(e.getActionCommand().equals("Retrive"))
{
x3.setVisible(true);
{
if (e.getActionCommand().equals("doing"))
theTic.setText("* doing");
else if (e.getActionCommand().equals("not doing"))
theTic.setText("* not doing");
else
theTic.setText("Error");
}
}
else
System.out.println("Error in button you Pressed");
}
}
}
|
|