JTextArea

JTextArea

View Answers

January 8, 2009 at 8:05 AM

Hi friend,

import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class MainApp extends Frame {

MyTextArea textArea = new MyTextArea("");

public MainApp() {
setLayout(new BorderLayout());
Button button = new Button("Measure");
Button buttonExit = new Button("Exit");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
int width = textArea.getWidth();
Graphics graphics = textArea.getGraphics();
FontMetrics fm = graphics.getFontMetrics();
System.out.println(fm.stringWidth(textArea.getText()));
System.out.println(width);
}
});
buttonExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
System.exit(0);
}
});

addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
System.exit(0);
}

public void windowClosing(WindowEvent e) {
System.exit(0);
}
});

Panel panel = new Panel();
panel.add(button);
panel.add(buttonExit);

add(textArea, BorderLayout.CENTER);
add(panel, BorderLayout.SOUTH);
setSize(400,400);
setLocation(400,400);
setVisible(true);
}

public static void main (String args[]) {
new MainApp();
}

public class MyTextArea extends TextArea {
MyTextArea(String text) {
super(text, 0, 0, SCROLLBARS_NONE);
}
}
}

-----------------------------

Thanks









Related Tutorials/Questions & Answers:
jtextarea
jtextarea   How To: Add line numbers to JTextArea?? help
jTextArea
jTextArea  how to get each/all values from ms access database into jtextarea of a particular entity..??Please Help
Advertisements
jTextArea
jTextArea  can jtextarea have numbers like 1 will be set to default and when the user writes in first line and hits enter the 2nd number should automatically be created??can this be done in netbeans??please help
jtextarea
jtextarea  how to use append function in jtextarea?? i have build an application and i have to display only particular column data which can have multiple rows.it is not working with settext but using using append the value gets
jtextarea
jtextarea  how to use append function in jtextarea?? i have build an application and i have to display only particular column data which can have multiple rows.it is not working with settext but using using append the value gets
AutoCompleteField using JTextArea
AutoCompleteField using JTextArea  How to create an AutoCompleteField in java such as username field using JTextArea
JTextfields working with JTextArea
on a Jtextarea   hi friend, try the following code below : import java.sql.... = new JTextField(); JTextArea textarea=new JTextArea(5,20); JButton b=new
JTextArea - Swing AWT
JTextArea  Dear Sir, I was hoping you could please help me on, how to restrict the maximum characters that the user can Enter in the JTextArea of my Application. I want that the User can Enter only 300 Characters, not more
view data from jTextArea to jtable
view data from jTextArea to jtable  good night Please help senior java all, I want to make a brief program of reading data in the text area and then on the show to the j table. I created a new scrip like below but it does
How to get filename in JTextArea in following case?
How to get filename in JTextArea in following case?  Hi, i'm... is not displayed in the JTextArea, why? [CODE] private void... JFrame { JTextArea JTextAreaOutputDirectory; JButton b; JScrollPane
how to send the content of jtextarea from netbeans IDE to webpage's textarea in java
how to send the content of jtextarea from netbeans IDE to webpage's textarea in java   Hi, i m interested to send the content of my jtextarea which i have developed in netbeans IDE to the webpage's textarea. how can i do
How To Fetch Data From Database Into JTextArea
How To Fetch Data From Database Into JTextArea In this section we will read about how to get the data from database table into JTextArea.... To read detail about JTextArea click here. ExampleADS_TO_REPLACE_1 Here
how to compare text in two jTextarea
how can i display a pdf file in a jtextarea
Java JTextArea
Java JTextArea In this section we will discuss about the javax.swing.JTextArea. javax.swing.JTextArea extends the JTextComponent. JTextArea facilitates... is capable to be placed within the JScrollpane if JtextArea is required to add
JTextArea to Word Document
JTextArea to Word Document Jakarta POI has provided several classes... { JTextArea area; JScrollPane pane; JButton b1, b2; File file = new File("C...()); } } TextAreaInDocument() { area = new JTextArea(5, 30); area.setFont(new Font("courier New
Chatting
Chatting  how to invoke the code from JTextArea to send Socket.getInputStram()&Sockeck.getOutputStream
how to convert doc file into html using java swing
how to convert doc file into html using java swing  i want to convert doc file into html and display it on jtextarea please help me and give the sample code
cursor location
cursor location   hi,please how to change cursor location by java code ,i use this code but not change the location JTextArea a=new JtextArea(); if(resultText.equalsIgnoreCase("class")){ a.append("a { \n }"); PointerInfo
java code for cursor
java code for cursor   hi,please how to change cursor location by java code ,iam use this code but not change the location JTextArea a=new JtextArea(); if(resultText.equalsIgnoreCase("class")){ a.append("a { \n }"); PointerInfo
Unicode - JDBC
Unicode  hi i wanna retrieve Unicode values from the database........when i do so and print the fetched values in java control (JTextArea) or IN doc or RTF or WEB page it get the UNICODE as ????? what can i do so
unicode - Swing AWT
unicode  hi i wanna retrieve Unicode values from the database........when i do so and print the fetched values in java control (JTextArea) or IN doc or RTF or WEB page it get the UNICODE as ????? what can i do so
java - Java Beginners
OperatingSystem extends JFrame{ JLabel label1,label2,label3; JTextArea..."); area1=new JTextArea(2,8); String osName= System.getProperty("os.name...("Opearting System Version"); area2=new JTextArea(2,8); String osVersion
java - Java Beginners
; JTextArea area1, area2, area3,area4,area5,area6,area7; JScrollPane scroll1...("Opearting System Name"); area1 = new JTextArea(2,8); String osName... JTextArea(2,8); String osVersion = System.getProperty("os.version
Java-swings - Java Beginners
BorderLayout()); JTextArea top = new JTextArea(5, 40); top.setDragEnabled(true..., BorderLayout.NORTH); JTextArea bottom = new JTextArea(5, 40
java how to create visual swing editor
java how to create visual swing editor   How do I create a visual swing designer in java ?Meaning that I can "draw" a button,a JTextArea from within my designer program . I just need some basics . I've got no idea how to start
java - Java Beginners
OperatingSystem extends JFrame{ JLabel label1,label2,label3; JTextArea...=new JTextArea(2,8); String osName= System.getProperty("os.name"); area1.setText... Version"); area2=new JTextArea(2,8); String osVersion= System.getProperty
create , edit MS WORD like document file using Java Swing - Swing AWT
program I have JTextArea. Text in JTextArea can be set to selected font, font style etc. I want this text in JTextArea to be saved to MS WORD like... org.apache.poi.hwpf.extractor.WordExtractor; public class TextAreaInDocument extends JFrame{ JTextArea
java - Java Beginners
label1,label2; JTextArea area1,area2; JScrollPane scroll1,scroll2; JButton...(){ label1=new JLabel("Enter Information1"); area1=new JTextArea(2,8); scroll1=new... JTextArea(2,8); scroll2=new JScrollPane(area2); button=new JButton("Submit
java swing - Java Beginners
java swing  hi, I have the jtextfield and jtextarea in the same...{ JPanel panel; JTextField text; JTextArea area; JScrollPane pane; JLabel l1,l2..."); area=new JTextArea(5,5); pane=new JScrollPane(area); text.addKeyListener(new
CLOB example - JDBC
with resultset and display in the JTextArea that fetched text....... thanku ... = clobFile.getSubString(1, (int) length); JFrame f=new JFrame(); JTextArea area=new JTextArea(20,60); area.setText(fileData); JScrollPane pane=new JScrollPane
How to Set Transperent Background Image to Jpanel - Java Beginners
); } } ); JTextArea area=new JTextArea(15,4){ ImageIcon image = new
how to print fasta file into jtable using netbeans IDE
. and sequence "CGGGAAATTATCc..." in jtextarea. i made both jtable and jtextarea
How to create file from input values in Jframe ?
an object for it.my java code is public class submit { JFrame frame; JTextArea... cp=new JPanel(); text1=new JTextArea(); cp.add(text1); frame.add(cp
waltido
JTextArea area=new JTextArea(5,20); JScrollPane pane=new JScrollPane(area
how to sort the text file and display it in jtable
in jtable and sequence like "CGGGAATTAA..." in jtextarea in netbeans . pls suggest
connectivity with access
connectivity with access  how to connect with data base with access sheet. in my application form there is two JTextArea and Two JComboBox.   Is this Access database or excel sheet. Do you want to display the values
Program to read the text from a file and display it on a JFrame.
(); JPanel jp1=new JPanel(); JTextArea t1=new JTextArea(); MegaViewer1() throws...=new JTabbedPane(); JPanel jp1=new JPanel(); JTextArea t1=new JTextArea
java - Java Beginners
ADD=new JButton("Store"); final JTextArea area =new JTextArea(10,25
java - Java Beginners
(); label.setText("File Data:"); final JTextArea area =new JTextArea(10,25
jsplitpane - Java Beginners
(this); description = new JTextArea(); JSplitPane innerPane= new JSplitPane...(); description.setText(value.getDescription()); } private JList list; private JTextArea
java-help - Java Beginners
; JTextArea ta=null; JScrollPane sp=null; File f=null; FileOutputStream...=ca; ta=new JTextArea(); sp=new JScrollPane(ta); clustersOutput
Java swing
JTextArea area=new JTextArea(5,20); JScrollPane pane=new JScrollPane
Java database connectivity
); final JTextArea area=new JTextArea(5,20); JScrollPane pane=new JScrollPane
DATABASE
JTextField text=new JTextField(20); final JTextArea area=new JTextArea(5,20
Synchronization probleam - Java Server Faces Questions
Socket client; private JTextArea textArea; ClientWorker(Socket client, JTextArea textArea) { this.client = client; this.textArea = textArea... over socket:"); JPanel panel; JTextArea textArea = new JTextArea
Java - Java Beginners
to create three JButtons and one JTextArea that implements the undo and redo... Applet{ JButton b1,b2,b3; JTextArea area; ScrollPane pane; Panel p...(manager.canRedo()); } public void init(){ p=new Panel(); area=new JTextArea(5,30
How to Create Text Area In Java
are created and a text area is also created on the panel by using JTextArea class..., constructor of the JTextArea has been used with three arguments. These arguments...;JTextArea jt= new JTextArea("Welcome Roseindia",5,20
Synchronization probleam - Java Server Faces Questions
implements Runnable { private Socket client; private JTextArea textArea; ClientWorker(Socket client, JTextArea textArea) { this.client = client...:"); JPanel panel; JTextArea textArea = new JTextArea(); ServerSocket
swimming pool calculator
() { hotTub = new JPanel(); hotTub.setLayout(null); final JTextArea labelTubStatus = new JTextArea(6,30); final JTextArea textFieldTubResult = new JTextArea(6,30); final JTextArea textFieldTubWidth = new JTextArea

Ads