jQuery in Action, 2nd edition*
The moose likes Applets and the fly likes scrollbars in a canvas-urgent Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "scrollbars in a canvas-urgent" Watch "scrollbars in a canvas-urgent" New topic
Author

scrollbars in a canvas-urgent

Samiullah Aazam
Greenhorn

Joined: Jul 02, 2001
Posts: 7
Hello everybody!
Here is an applet java file which displays the user texts(entered via text field) in its upper text area. Now i wnat this text area to be replaced by a canvas and this canvas must contain a scrollbar.
If anyone of u could be able to that then plz. mention your code at this forum or mail me at
amu_guy@hotmail.com
Its vrey urgent.
Thankx!
----------------------------------------------------------------
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*
<applet code="dd1.java" width=400 height=400>
</applet>
*/
public class dd1 extends Applet implements
ActionListener,ItemListener{
TextArea textarea1;
TextField text1;
Button button1;
Panel down,down1;
Label l=new Label("Applet for Fonts & Colors");
Choice ch1=new Choice();
Choice ch2=new Choice();
Choice ch3=new Choice();


public void init(){

down=new Panel();
down.setLayout(new BorderLayout());
this.setLayout(new BorderLayout());
down1=new Panel();

add("North",l);

textarea1=new TextArea("",5,20,1);
add("Center",textarea1);

text1=new TextField(50);
down.add("North",text1);
text1.addActionListener(this);

button1=new Button("Click Me");
down.add("South",down1);
button1.addActionListener(this);

down1.add("North", button1);
add("South", down);
down1.setLayout(new GridLayout(1,3));
ch1.add("Select a font type");
ch2.add("Select a font style");
ch3.add("Select a font size");
ch1.add("SansSerif");
ch1.add("Serif");
ch1.add("Monospaced");
ch2.add("PLAIN");
ch2.add("BOLD");
ch2.add("ITALIC");

ch3.add("25");
ch3.add("30");
ch3.add("40");
ch1.addItemListener(this);
ch2.addItemListener(this);
ch3.addItemListener(this);
down1.add("South",ch1);
down1.add("West",ch2);
down1.add("East",ch3);
}

public void actionPerformed(ActionEvent e)
{

if(e.getSource()==button1){

String gg=text1.getText();
textarea1.append(gg);
text1.setText("");
}
else if(e.getSource()==text1)
{
String gg=text1.getText();
textarea1.append(gg);
text1.setText("");
}
}
public void itemStateChanged(ItemEvent e1)
{
if(e1.getSource()==ch1)
{
int a=0;
String ss=ch2.getSelectedItem();
ss=ss.trim();

if(ss.equals("BOLD")) a=Font.BOLD;
if(ss.equals("PLAIN")) a=Font.PLAIN;
if(ss.equals("ITALIC")) a=Font.ITALIC;

int aa=Integer.parseInt(ch3.getSelectedItem());
Font f=new Font(ch1.getSelectedItem(),a,aa);
textarea1.setFont(f);

}
}
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: scrollbars in a canvas-urgent
 
Similar Threads
Frame Attack!
Some of you are experts this could be your next problem!
for Applet
Need ur suggestion... Urgent!
TEXTFIELDS TO INT