P: 1
| - import java.awt.*;
-
import javax.swing.*;
-
import java.awt.event.*;
-
import javax.swing.event.*;
-
import java.io.File;
-
import java.util.*;
-
/*
-
<Applet Code="MyPaint.class" width=400 height=400>
-
</Applet>
-
*/
-
public class MyPaint extends JApplet
-
{
-
/* Declaring the variables.*/
-
JPanel panel;
-
JPanel textAreaPanel;
-
JTextArea drawTextArea;
-
JScrollPane drawScrollPane;
-
JLabel line, color, paint,kid,cil;
-
JButton circle, rect, poly, ellipse;
-
JComboBox cbLine, cbFill;
-
GridBagLayout g;
-
GridBagConstraints gbc;
-
public void init()
-
{
-
g=new GridBagLayout();
-
gbc=new GridBagConstraints();
-
panel= (JPanel)getContentPane();
-
panel.setLayout(g);
-
paint = new JLabel("My Paint Application");
-
gbc.anchor= GridBagConstraints.NORTH;
-
gbc.gridx =2;
-
gbc.gridy = 0;
-
g.setConstraints(paint,gbc);
-
panel.add(paint);
-
rect = new JButton("Rectangle");
-
gbc.ipadx = 2;
-
gbc.ipady = 2;
-
gbc.gridy = 1;
-
gbc.gridx = 1;
-
g.setConstraints(rect,gbc);
-
panel.add(rect);
-
circle = new JButton("Circle");
-
gbc.ipadx = 2;
-
gbc.ipady = 2;
-
gbc.gridy = 1;
-
gbc.gridx = 2;
-
g.setConstraints(circle,gbc);
-
panel.add(circle);
-
poly = new JButton("Polygon");
-
gbc.ipadx = 2;
-
gbc.ipady = 2;
-
gbc.gridy = 1;
-
gbc.gridx = 3;
-
g.setConstraints(poly,gbc);
-
panel.add(poly);
-
ellipse = new JButton("Ellipse");
-
gbc.ipadx = 2;
-
gbc.ipady = 2;
-
gbc.gridy = 1;
-
gbc.gridx = 4;
-
g.setConstraints(ellipse,gbc);
-
panel.add(ellipse);
-
line = new JLabel("select line color");
-
gbc.ipadx = 4;
-
gbc.ipady = 4;
-
gbc.gridy = 2;
-
gbc.gridx = 1;
-
g.setConstraints(line,gbc);
-
panel.add(line);
-
kid = new JLabel("");
-
gbc.ipadx = 4;
-
gbc.ipady = 4;
-
gbc.gridy = 2;
-
gbc.gridx = 2;
-
g.setConstraints(kid,gbc);
-
panel.add(kid);
-
color = new JLabel("select Fill color");
-
gbc.ipadx = 4;
-
gbc.ipady = 4;
-
gbc.gridy = 2;
-
gbc.gridx = 3;
-
g.setConstraints(color,gbc);
-
panel.add(color);
-
String Line[]={"choose the color","Red","Yellow","Green","Blue","Cyan","Mangeta","Orange"};
-
cbLine = new JComboBox(Line);
-
gbc.fill= GridBagConstraints.BOTH;
-
gbc.insets=new Insets(5,5,5,5);
-
gbc.ipadx = 4;
-
gbc.ipady = 4;
-
gbc.gridy = 3;
-
gbc.gridx = 1;
-
g.setConstraints(cbLine,gbc);
-
panel.add(cbLine);
-
cil = new JLabel("");
-
gbc.ipadx = 4;
-
gbc.ipady = 4;
-
gbc.gridy = 3;
-
gbc.gridx = 2;
-
g.setConstraints(cil,gbc);
-
panel.add(cil);
-
String Fill[]={"choose the color","Red","Yellow","Green","Blue","Cyan","Mangeta","Orange"};
-
cbFill = new JComboBox(Fill);
-
gbc.fill= GridBagConstraints.BOTH;
-
gbc.insets=new Insets(5,5,5,5);
-
gbc.ipadx = 4;
-
gbc.ipady = 4;
-
gbc.gridy = 3;
-
gbc.gridx = 3;
-
g.setConstraints(cbFill,gbc);
-
panel.add(cbFill);
-
textAreaPanel = new JPanel(new GridLayout(2,1,5,5));
-
drawTextArea = new JTextArea();
-
drawScrollPane = new JScrollPane(drawTextArea);
-
textAreaPanel.add(drawScrollPane);
-
textAreaPanel.setLayout(g);
-
textAreaPanel= (JPanel)getContentPane();
-
}
-
-
public static void main(String[] args)
-
{
-
MyPaint mp = new MyPaint();
-
mp.setSize(700,500);
-
mp.setVisible(true);
-
}
-
}
-
kindly,assist me on this codes to make the textarea show?
kindly,assist me on this codes to make the textarea show?
| |
Share this Question
Expert 10K+
P: 11,448
|
kindly,assist me on this codes to make the textarea show?
You should add your TextAreaPanel to the content pane of your JApplet.
The last lines of your initialization method are completely wrong.
kind regards,
Jos
| | Expert 100+
P: 1,216
|
Please enclose your posted code in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use [code] tags in future.
MODERATOR
| | Expert 100+
P: 1,216
|
Please remember to provide a meaningful Title for any threads started (see the FAQ entry Use a Good Thread Title).
This helps to ensure that other members, and also the general public, will have a better chance of finding answers to any similar questions.
MODERATOR
| | | | Question stats - viewed: 1745
- replies: 3
- date asked: Jan 23 '08
|