• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

scrollbars in a canvas-urgent

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 found some pretty shells, some sea glass and this lovely tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic