- 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?
3 2104
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
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
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
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David Eynon |
last post by:
I know that the basic methods that can be overwritten for class JApplet are
init, and paint. However, the API does not specifically state this, and
JApplet does not describe this right away.. How...
|
by: - ions |
last post by:
Hello, i am relatively new to programming, Java being the first
language im learning. At the moment im having trouble changing the
setEnable value of a button, relative to the state of a JTextArea,...
|
by: Kookymon1 |
last post by:
This is an attempt to respond to an older question (several months).
Date: 2002-03-07 13:10:23 PST
Subject: On the Common DOM API and Applets.
The original message was:
>LiveConnect and the...
|
by: Chris Williams |
last post by:
I haven't done any Java programming for a good long bit, so this is probably
something really silly but anyways, can anyone tell me why my JTextArea is
not appearing when I run this?
public...
|
by: Aurel |
last post by:
Hi,
I developped an applet (JApplet class) and now I'd like to integrate it in
another application which is a JFrame one...
Does anyone can help ?
Thanks in advance...
AureL
|
by: Colibasi |
last post by:
I would like to have a JTextArea with a background white and text should be
readonly.
The way I tried is something like this:
JTextArea text = new JTextArea();
text.setEditable(false);...
|
by: - |
last post by:
I have googled and learned that there are limitations with JApplet
writing to files on remote host. However, I am unsure as to whether it
is possible to do so on the same computer. Please advice....
|
by: James Barrett |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi all, I am experimenting with JApplet and JPanel.
My JApplet contains a JPanel called jpanel1 size 210x210.
I created a class myPanel which...
|
by: chanshaw |
last post by:
Ok my problem is that when it loads the JTextArea, it does not show the full component's width and height. I've tried specifying it with setrow, setcolumn, setprefferedsize, all of that. It does...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |