SlideShare a Scribd company logo
1 of 47
1
Topics
JFrame
JTextArea
JScrollPane
Lecture By:- Mr. Akaash
2
Open NetBeans IDE 8.1
Lecture By:- Mr. Akaash
3
Open File Menu
Lecture By:- Mr. Akaash
4
Click on New Project
Lecture By:- Mr. Akaash
5
Select Category “Java”
Lecture By:- Mr. Akaash
6
Select Project Java Application
Lecture By:- Mr. Akaash
7
Click on Next Button
Lecture By:- Mr. Akaash
8
Write Project Name
Lecture By:- Mr. Akaash
9
Create Main Class
Lecture By:- Mr. Akaash
10
Click on Finish Button
Lecture By:- Mr. Akaash
11
What is Jframe?
A frame, implemented as an instance of the JFrame
class, is a window that has decorations such as a
border, a title, and supports button components that
close or iconify the window. Applications with a GUI
usually include at least one frame
Lecture By:- Mr. Akaash
12
Create JFrame
13
Coding of JFrame
import java.awt.FlowLayout;
import javax.swing.JFrame;
public class JTextAreaTest {
public static void main(String[] args) {
JFrame frame = new JFrame("JTextArea Test");
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Built_in Packages of Java
Programming Language
Lecture By:- Mr. Akaash
14
Coding of JFrame
import java.awt.FlowLayout;
import javax.swing.JFrame;
public class JTextAreaTest {
public static void main(String[] args) {
JFrame frame = new JFrame("JTextArea Test");
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Built_in Packages of Java
Programming Language
Main Class
Lecture By:- Mr. Akaash
15
Coding of JFrame
import java.awt.FlowLayout;
import javax.swing.JFrame;
public class JTextAreaTest {
public static void main(String[] args) {
JFrame frame = new JFrame("JTextArea Test");
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Built_in Packages of Java
Programming Language
Main Class
Main Function
Lecture By:- Mr. Akaash
16
Coding of JFrame
import java.awt.FlowLayout;
import javax.swing.JFrame;
public class JTextAreaTest {
public static void main(String[] args) {
JFrame frame = new JFrame("JTextArea Test");
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Built_in Packages of Java
Programming Language
Main Class
Main Function
Class
Lecture By:- Mr. Akaash
17
Coding of JFrame
import java.awt.FlowLayout;
import javax.swing.JFrame;
public class JTextAreaTest {
public static void main(String[] args) {
JFrame frame = new JFrame("JTextArea Test");
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Built_in Packages of Java
Programming Language
Main Class
Main Function
Class Object
Lecture By:- Mr. Akaash
18
Coding of JFrame
import java.awt.FlowLayout;
import javax.swing.JFrame;
public class JTextAreaTest {
public static void main(String[] args) {
JFrame frame = new JFrame("JTextArea Test");
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Built_in Packages of Java
Programming Language
Main Class
Main Function
Class Object Keyword
Lecture By:- Mr. Akaash
19
Coding of JFrame
import java.awt.FlowLayout;
import javax.swing.JFrame;
public class JTextAreaTest {
public static void main(String[] args) {
JFrame frame = new JFrame("JTextArea Test");
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Built_in Packages of Java
Programming Language
Main Class
Main Function
Class Object Keyword Constructor
Lecture By:- Mr. Akaash
20
Coding of JFrame
import java.awt.FlowLayout;
import javax.swing.JFrame;
public class JTextAreaTest {
public static void main(String[] args) {
JFrame frame = new JFrame("JTextArea Test");
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Built_in Packages of Java
Programming Language
Main Class
Main Function
Class Object Keyword Constructor Value
Lecture By:- Mr. Akaash
21
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object
Lecture By:- Mr. Akaash
22
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method
Lecture By:- Mr. Akaash
23
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width
Lecture By:- Mr. Akaash
24
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Lecture By:- Mr. Akaash
25
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object
Lecture By:- Mr. Akaash
26
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object Method
Lecture By:- Mr. Akaash
27
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object Method Keyword
Lecture By:- Mr. Akaash
28
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object Method Keyword Method
Lecture By:- Mr. Akaash
29
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object Method Keyword Method
Object
Lecture By:- Mr. Akaash
30
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object Method Keyword Method
Object Method
Lecture By:- Mr. Akaash
31
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object Method Keyword Method
Object Method Boolean value
Lecture By:- Mr. Akaash
32
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object Method Keyword Method
Object Method Boolean value
Object
Lecture By:- Mr. Akaash
33
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object Method Keyword Method
Object Method Boolean value
Object Method
Lecture By:- Mr. Akaash
34
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object Method Keyword Method
Object Method Boolean value
Object Method Class
Lecture By:- Mr. Akaash
35
Coding of JFrame
frame.setSize(280, 150);
frame.setLayout(new FlowLayout());
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
Object Method Width Height
Object Method Keyword Method
Object Method Boolean value
Object Method Value Class Method
Lecture By:- Mr. Akaash
36
Explanation of Previously Used
Methods
setSize(). Method allows you to set the size like Width & height of JFrame
setResizable(). One method for ensuring that a graphical interface looks the way you intend is
to prevent the user from re-sizing it, using this method of JFrame :
setLayout(). Method allows you to set the layout of the container, often a JPanel, to say
FlowLayout(), BorderLayout(), GridLayout(), null layout(), or
whatever layout desired. The layout manager helps lay out the components held
by this container
setDefaultCloseOperation() method is used to specify one of several options for the close
button. Use one of the following constants to specify your choice:
 JFrame.EXIT_ON_CLOSE — Exit the application.
 JFrame.HIDE_ON_CLOSE — Hide the frame, but keep the application running.
 JFrame.DISPOSE_ON_CLOSE — Dispose of the frame object, but keep the application running.
 JFrame.DO_NOTHING_ON_CLOSE — Ignore the click.
If you forget to call setDefaultCloseOperation() you will get JFrame.HIDE_ON_CLOSE by default.
This can be frustrating, because it looks like you have "killed" the program, but it keeps on running,
and you see no frame.
Lecture By:- Mr. Akaash
37
What is JTextArea?
A JTextArea is a multi-line area that displays plain
text. It is intended to be a lightweight component that
provides source compatibility with the
java.awt.TextArea class where it can reasonably do
so.
Lecture By:- Mr. Akaash
38
Add “JTextArea” on Frame
39
Coding of JTextArea
JTextArea textArea1 = new JTextArea(text);
textArea1.setPreferredSize(new Dimension(100, 100));
textArea1.setLineWrap(true);
frame.add(textArea1);
Class Object Keyword Constructor Value
Object Method Keyword Method Width Height
Object Method Boolean value
Object Method Object
Lecture By:- Mr. Akaash
40
Constructors and Description
JTextArea()
Constructs a new TextArea.
JTextArea(Document doc)
Constructs a new JTextArea with the given document model, and defaults for all of the other
arguments (null, 0, 0).
JTextArea(Document doc, String text, int rows, int columns)
Constructs a new JTextArea with the specified number of rows and columns, and the given model.
JTextArea(int rows, int columns)
Constructs a new empty TextArea with the specified number of rows and columns.
JTextArea(String text)
Constructs a new TextArea with the specified text displayed.
JTextArea(String text, int rows, int columns)
Constructs a new TextArea with the specified text and number of rows and columns.
Lecture By:- Mr. Akaash
41
Methods
Modifier and Type Method and Description
void
append(String str)
Appends the given text to the end of the document.
protected
Document
createDefaultModel()
Creates the default implementation of the model to be used at
construction if one isn't explicitly given.
AccessibleContext
getAccessibleContext()
Gets the AccessibleContext associated with this JTextArea.
int
getColumns()
Returns the number of columns in the TextArea.
protected int
getColumnWidth()
Gets column width.
int
getLineCount()
Determines the number of lines contained in the area.
int
getLineEndOffset(int line)
Determines the offset of the end of the given line.
Lecture By:- Mr. Akaash
42
Methods
Modifier and Type Method and Description
boolean
getLineWrap()
Gets the line-wrapping policy of the text area.
Dimension
getPreferredScrollableViewportSize()
Returns the preferred size of the viewport if this component is embedded in a
JScrollPane.
Dimension
getPreferredSize()
Returns the preferred size of the TextArea.
protected int
getRowHeight()
Defines the meaning of the height of a row.
int
getRows()
Returns the number of rows in the TextArea.
boolean
getScrollableTracksViewportWidth()
Returns true if a viewport should always force the width of this Scrollable to
match the width of the viewport.
int
getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
Components that display logical rows or columns should compute the scroll
increment that will completely expose one new row or column, depending on
the value of orientation.
Lecture By:- Mr. Akaash
43
Methods
Modifier & Type Method and Description
Int getTabSize()
Gets the number of characters used to expand tabs.
String getUIClassID()
Returns the class ID for the UI.
Boolean getWrapStyleWord()
Gets the style of wrapping used if the text area is wrapping lines.
Void insert(String str, int pos)
Inserts the specified text at the specified position.
protected String paramString()
Returns a string representation of this JTextArea.
Void replaceRange(String str, int start, int end)
Replaces text from the indicated start to end position with the new
text specified.
Void setColumns(int columns)
Sets the number of columns for this TextArea.
Void setTabSize(int size)
Sets the number of characters to expand tabs to.
Void setWrapStyleWord(boolean word)
Sets the style of wrapping used if the text area is wrapping lines.
44
JTextArea with ScrollPane
45
Coding of JTextArea with
ScrollPane
JTextArea textArea2 = new JTextArea(text, 5, 10);
textArea2.setLineWrap(true);
JScrollPane scrollPane = new
JScrollPane(textArea2,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
frame.add(scrollPane);
Lecture By:- Mr. Akaash
46
Why JScrollPane used with
JTextArea?
A JTextArea object represents a multiline area for displaying
text. If Text is too large from JTextArea Boundaries(Width,
Height) then You can also put your JTextArea in a
JScrollPane to make it scrollable.
Lecture By:- Mr. Akaash
47Lecture By:- Mr. Akaash

More Related Content

What's hot

Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Victor Rentea
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontendHeiko Hardt
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignVictor Rentea
 
Introducing Drools
Introducing DroolsIntroducing Drools
Introducing DroolsMario Fusco
 
Pyconie 2012
Pyconie 2012Pyconie 2012
Pyconie 2012Yaqi Zhao
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit TestingMike Lively
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbookManusha Dilan
 
Advanced Java - Praticals
Advanced Java - PraticalsAdvanced Java - Praticals
Advanced Java - PraticalsFahad Shaikh
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습DoHyun Jung
 

What's hot (19)

Clean coding-practices
Clean coding-practicesClean coding-practices
Clean coding-practices
 
Test driven development_for_php
Test driven development_for_phpTest driven development_for_php
Test driven development_for_php
 
Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021Pure functions and immutable objects @dev nexus 2021
Pure functions and immutable objects @dev nexus 2021
 
Byte code field report
Byte code field reportByte code field report
Byte code field report
 
Testing the frontend
Testing the frontendTesting the frontend
Testing the frontend
 
Java custom annotations example
Java custom annotations exampleJava custom annotations example
Java custom annotations example
 
The Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable DesignThe Art of Unit Testing - Towards a Testable Design
The Art of Unit Testing - Towards a Testable Design
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 
Introducing Drools
Introducing DroolsIntroducing Drools
Introducing Drools
 
Pyconie 2012
Pyconie 2012Pyconie 2012
Pyconie 2012
 
Advanced PHPUnit Testing
Advanced PHPUnit TestingAdvanced PHPUnit Testing
Advanced PHPUnit Testing
 
Java 10, Java 11 and beyond
Java 10, Java 11 and beyondJava 10, Java 11 and beyond
Java 10, Java 11 and beyond
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 
Spock framework
Spock frameworkSpock framework
Spock framework
 
PHPUnit testing to Zend_Test
PHPUnit testing to Zend_TestPHPUnit testing to Zend_Test
PHPUnit testing to Zend_Test
 
UPC Testing talk 2
UPC Testing talk 2UPC Testing talk 2
UPC Testing talk 2
 
Advanced Java - Praticals
Advanced Java - PraticalsAdvanced Java - Praticals
Advanced Java - Praticals
 
모던자바의 역습
모던자바의 역습모던자바의 역습
모던자바의 역습
 
Exceptions
ExceptionsExceptions
Exceptions
 

Similar to jframe, jtextarea and jscrollpane

شرح مقرر البرمجة 2 لغة جافا - الوحدة التاسعة
شرح مقرر البرمجة 2   لغة جافا - الوحدة التاسعةشرح مقرر البرمجة 2   لغة جافا - الوحدة التاسعة
شرح مقرر البرمجة 2 لغة جافا - الوحدة التاسعةجامعة القدس المفتوحة
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningCarol McDonald
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APIcaswenson
 
Hotspot & hotswap, who and who are best freinds
Hotspot & hotswap, who and who are best freindsHotspot & hotswap, who and who are best freinds
Hotspot & hotswap, who and who are best freinds亚军 汪
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsMuhammadTalha436
 
Execution flow of main() method inside jvm
Execution flow of main() method inside jvmExecution flow of main() method inside jvm
Execution flow of main() method inside jvmsaurav uniyal
 
College management system.pptx
College management system.pptxCollege management system.pptx
College management system.pptxManujArora3
 
Logic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing ApplicationsLogic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing Applicationskjkleindorfer
 
New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancementRakesh Madugula
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1PRN USM
 
Groovy-er desktop applications with Griffon
Groovy-er desktop applications with GriffonGroovy-er desktop applications with Griffon
Groovy-er desktop applications with GriffonEric Wendelin
 
Groovy-er Desktop Applications With Griffon
Groovy-er Desktop Applications With GriffonGroovy-er Desktop Applications With Griffon
Groovy-er Desktop Applications With GriffonMatthew McCullough
 
What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.Mark Rees
 
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...Stephen Chin
 

Similar to jframe, jtextarea and jscrollpane (20)

Lecture7 oopj
Lecture7 oopjLecture7 oopj
Lecture7 oopj
 
SWING.pptx
SWING.pptxSWING.pptx
SWING.pptx
 
شرح مقرر البرمجة 2 لغة جافا - الوحدة التاسعة
شرح مقرر البرمجة 2   لغة جافا - الوحدة التاسعةشرح مقرر البرمجة 2   لغة جافا - الوحدة التاسعة
شرح مقرر البرمجة 2 لغة جافا - الوحدة التاسعة
 
Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
 
Oop lecture2
Oop lecture2Oop lecture2
Oop lecture2
 
Learning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security APILearning Java 4 – Swing, SQL, and Security API
Learning Java 4 – Swing, SQL, and Security API
 
Hotspot & hotswap, who and who are best freinds
Hotspot & hotswap, who and who are best freindsHotspot & hotswap, who and who are best freinds
Hotspot & hotswap, who and who are best freinds
 
Object Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ ExamsObject Oriented Solved Practice Programs C++ Exams
Object Oriented Solved Practice Programs C++ Exams
 
Execution flow of main() method inside jvm
Execution flow of main() method inside jvmExecution flow of main() method inside jvm
Execution flow of main() method inside jvm
 
College management system.pptx
College management system.pptxCollege management system.pptx
College management system.pptx
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
Logic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing ApplicationsLogic and Coding of Java Interfaces & Swing Applications
Logic and Coding of Java Interfaces & Swing Applications
 
New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancement
 
Mastering Java ByteCode
Mastering Java ByteCodeMastering Java ByteCode
Mastering Java ByteCode
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Groovy-er desktop applications with Griffon
Groovy-er desktop applications with GriffonGroovy-er desktop applications with Griffon
Groovy-er desktop applications with Griffon
 
Groovy-er Desktop Applications With Griffon
Groovy-er Desktop Applications With GriffonGroovy-er Desktop Applications With Griffon
Groovy-er Desktop Applications With Griffon
 
What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.What do you mean it needs to be Java based? How jython saved the day.
What do you mean it needs to be Java based? How jython saved the day.
 
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
JavaFX 2.0 With Alternative Languages - Groovy, Clojure, Scala, Fantom, and V...
 

Recently uploaded

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...ZurliaSoop
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 

Recently uploaded (20)

Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 

jframe, jtextarea and jscrollpane

  • 2. 2 Open NetBeans IDE 8.1 Lecture By:- Mr. Akaash
  • 3. 3 Open File Menu Lecture By:- Mr. Akaash
  • 4. 4 Click on New Project Lecture By:- Mr. Akaash
  • 6. 6 Select Project Java Application Lecture By:- Mr. Akaash
  • 7. 7 Click on Next Button Lecture By:- Mr. Akaash
  • 9. 9 Create Main Class Lecture By:- Mr. Akaash
  • 10. 10 Click on Finish Button Lecture By:- Mr. Akaash
  • 11. 11 What is Jframe? A frame, implemented as an instance of the JFrame class, is a window that has decorations such as a border, a title, and supports button components that close or iconify the window. Applications with a GUI usually include at least one frame Lecture By:- Mr. Akaash
  • 13. 13 Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Built_in Packages of Java Programming Language Lecture By:- Mr. Akaash
  • 14. 14 Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Built_in Packages of Java Programming Language Main Class Lecture By:- Mr. Akaash
  • 15. 15 Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Built_in Packages of Java Programming Language Main Class Main Function Lecture By:- Mr. Akaash
  • 16. 16 Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Built_in Packages of Java Programming Language Main Class Main Function Class Lecture By:- Mr. Akaash
  • 17. 17 Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Built_in Packages of Java Programming Language Main Class Main Function Class Object Lecture By:- Mr. Akaash
  • 18. 18 Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Built_in Packages of Java Programming Language Main Class Main Function Class Object Keyword Lecture By:- Mr. Akaash
  • 19. 19 Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Built_in Packages of Java Programming Language Main Class Main Function Class Object Keyword Constructor Lecture By:- Mr. Akaash
  • 20. 20 Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Built_in Packages of Java Programming Language Main Class Main Function Class Object Keyword Constructor Value Lecture By:- Mr. Akaash
  • 21. 21 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Lecture By:- Mr. Akaash
  • 22. 22 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Lecture By:- Mr. Akaash
  • 23. 23 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Lecture By:- Mr. Akaash
  • 24. 24 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Lecture By:- Mr. Akaash
  • 25. 25 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Lecture By:- Mr. Akaash
  • 26. 26 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Method Lecture By:- Mr. Akaash
  • 27. 27 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Method Keyword Lecture By:- Mr. Akaash
  • 28. 28 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Method Keyword Method Lecture By:- Mr. Akaash
  • 29. 29 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Method Keyword Method Object Lecture By:- Mr. Akaash
  • 30. 30 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Method Keyword Method Object Method Lecture By:- Mr. Akaash
  • 31. 31 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Method Keyword Method Object Method Boolean value Lecture By:- Mr. Akaash
  • 32. 32 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Method Keyword Method Object Method Boolean value Object Lecture By:- Mr. Akaash
  • 33. 33 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Method Keyword Method Object Method Boolean value Object Method Lecture By:- Mr. Akaash
  • 34. 34 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Method Keyword Method Object Method Boolean value Object Method Class Lecture By:- Mr. Akaash
  • 35. 35 Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } } Object Method Width Height Object Method Keyword Method Object Method Boolean value Object Method Value Class Method Lecture By:- Mr. Akaash
  • 36. 36 Explanation of Previously Used Methods setSize(). Method allows you to set the size like Width & height of JFrame setResizable(). One method for ensuring that a graphical interface looks the way you intend is to prevent the user from re-sizing it, using this method of JFrame : setLayout(). Method allows you to set the layout of the container, often a JPanel, to say FlowLayout(), BorderLayout(), GridLayout(), null layout(), or whatever layout desired. The layout manager helps lay out the components held by this container setDefaultCloseOperation() method is used to specify one of several options for the close button. Use one of the following constants to specify your choice:  JFrame.EXIT_ON_CLOSE — Exit the application.  JFrame.HIDE_ON_CLOSE — Hide the frame, but keep the application running.  JFrame.DISPOSE_ON_CLOSE — Dispose of the frame object, but keep the application running.  JFrame.DO_NOTHING_ON_CLOSE — Ignore the click. If you forget to call setDefaultCloseOperation() you will get JFrame.HIDE_ON_CLOSE by default. This can be frustrating, because it looks like you have "killed" the program, but it keeps on running, and you see no frame. Lecture By:- Mr. Akaash
  • 37. 37 What is JTextArea? A JTextArea is a multi-line area that displays plain text. It is intended to be a lightweight component that provides source compatibility with the java.awt.TextArea class where it can reasonably do so. Lecture By:- Mr. Akaash
  • 39. 39 Coding of JTextArea JTextArea textArea1 = new JTextArea(text); textArea1.setPreferredSize(new Dimension(100, 100)); textArea1.setLineWrap(true); frame.add(textArea1); Class Object Keyword Constructor Value Object Method Keyword Method Width Height Object Method Boolean value Object Method Object Lecture By:- Mr. Akaash
  • 40. 40 Constructors and Description JTextArea() Constructs a new TextArea. JTextArea(Document doc) Constructs a new JTextArea with the given document model, and defaults for all of the other arguments (null, 0, 0). JTextArea(Document doc, String text, int rows, int columns) Constructs a new JTextArea with the specified number of rows and columns, and the given model. JTextArea(int rows, int columns) Constructs a new empty TextArea with the specified number of rows and columns. JTextArea(String text) Constructs a new TextArea with the specified text displayed. JTextArea(String text, int rows, int columns) Constructs a new TextArea with the specified text and number of rows and columns. Lecture By:- Mr. Akaash
  • 41. 41 Methods Modifier and Type Method and Description void append(String str) Appends the given text to the end of the document. protected Document createDefaultModel() Creates the default implementation of the model to be used at construction if one isn't explicitly given. AccessibleContext getAccessibleContext() Gets the AccessibleContext associated with this JTextArea. int getColumns() Returns the number of columns in the TextArea. protected int getColumnWidth() Gets column width. int getLineCount() Determines the number of lines contained in the area. int getLineEndOffset(int line) Determines the offset of the end of the given line. Lecture By:- Mr. Akaash
  • 42. 42 Methods Modifier and Type Method and Description boolean getLineWrap() Gets the line-wrapping policy of the text area. Dimension getPreferredScrollableViewportSize() Returns the preferred size of the viewport if this component is embedded in a JScrollPane. Dimension getPreferredSize() Returns the preferred size of the TextArea. protected int getRowHeight() Defines the meaning of the height of a row. int getRows() Returns the number of rows in the TextArea. boolean getScrollableTracksViewportWidth() Returns true if a viewport should always force the width of this Scrollable to match the width of the viewport. int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation. Lecture By:- Mr. Akaash
  • 43. 43 Methods Modifier & Type Method and Description Int getTabSize() Gets the number of characters used to expand tabs. String getUIClassID() Returns the class ID for the UI. Boolean getWrapStyleWord() Gets the style of wrapping used if the text area is wrapping lines. Void insert(String str, int pos) Inserts the specified text at the specified position. protected String paramString() Returns a string representation of this JTextArea. Void replaceRange(String str, int start, int end) Replaces text from the indicated start to end position with the new text specified. Void setColumns(int columns) Sets the number of columns for this TextArea. Void setTabSize(int size) Sets the number of characters to expand tabs to. Void setWrapStyleWord(boolean word) Sets the style of wrapping used if the text area is wrapping lines.
  • 45. 45 Coding of JTextArea with ScrollPane JTextArea textArea2 = new JTextArea(text, 5, 10); textArea2.setLineWrap(true); JScrollPane scrollPane = new JScrollPane(textArea2,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); frame.add(scrollPane); Lecture By:- Mr. Akaash
  • 46. 46 Why JScrollPane used with JTextArea? A JTextArea object represents a multiline area for displaying text. If Text is too large from JTextArea Boundaries(Width, Height) then You can also put your JTextArea in a JScrollPane to make it scrollable. Lecture By:- Mr. Akaash

Editor's Notes

  1. What is Jframe? A frame, implemented as an instance of the JFrame class, is a window that has decorations such as a border, a title, and supports button components that close or iconify the window. Applications with a GUI usually include at least one frame.
  2. Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  3. Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  4. Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  5. Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  6. Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  7. Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  8. Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  9. Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  10. Coding of JFrame import java.awt.FlowLayout; import javax.swing.JFrame; public class JTextAreaTest { public static void main(String[] args) { JFrame frame = new JFrame("JTextArea Test"); frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  11. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  12. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  13. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  14. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  15. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  16. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  17. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  18. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  19. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  20. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  21. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  22. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  23. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  24. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  25. Coding of JFrame frame.setSize(280, 150); frame.setLayout(new FlowLayout()); frame.setResizable(false); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }
  26. What is JTextArea? A JTextArea is a multi-line area that displays plain text. It is intended to be a lightweight component that provides source compatibility with the java.awt.TextArea class where it can reasonably do so.
  27. Coding of JTextArea JTextArea textArea1 = new JTextArea(text); textArea1.setPreferredSize(new Dimension(100, 100)); textArea1.setLineWrap(true); frame.add(textArea1);
  28. Constructors and Description JTextArea() Constructs a new TextArea. JTextArea(Document doc) Constructs a new JTextArea with the given document model, and defaults for all of the other arguments (null, 0, 0). JTextArea(Document doc, String text, int rows, int columns) Constructs a new JTextArea with the specified number of rows and columns, and the given model. JTextArea(int rows, int columns) Constructs a new empty TextArea with the specified number of rows and columns. JTextArea(String text) Constructs a new TextArea with the specified text displayed. JTextArea(String text, int rows, int columns) Constructs a new TextArea with the specified text and number of rows and columns.
  29. Methods Modifier and Type Method and Description Void append(String str) Appends the given text to the end of the document. protected Document createDefaultModel() Creates the default implementation of the model to be used at construction if one isn't explicitly given. AccessibleContext getAccessibleContext() Gets the AccessibleContext associated with this JTextArea. Int getColumns() Returns the number of columns in the TextArea. protected int getColumnWidth() Gets column width. Int getLineCount() Determines the number of lines contained in the area. Int getLineEndOffset(int line) Determines the offset of the end of the given line.
  30. Methods Modifier and Type Method and Description Boolean getLineWrap() Gets the line-wrapping policy of the text area. Dimension getPreferredScrollableViewportSize() Returns the preferred size of the viewport if this component is embedded in a JScrollPane. Dimension getPreferredSize() Returns the preferred size of the TextArea. protected int getRowHeight() Defines the meaning of the height of a row. Int getRows() Returns the number of rows in the TextArea. Boolean getScrollableTracksViewportWidth() Returns true if a viewport should always force the width of this Scrollable to match the width of the viewport. Int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) Components that display logical rows or columns should compute the scroll increment that will completely expose one new row or column, depending on the value of orientation.
  31. Methods Modifier and Type Method and Description Int getTabSize() Gets the number of characters used to expand tabs. String getUIClassID() Returns the class ID for the UI. Boolean getWrapStyleWord() Gets the style of wrapping used if the text area is wrapping lines. Void insert(String str, int pos) Inserts the specified text at the specified position. protected String paramString() Returns a string representation of this JTextArea. Void replaceRange(String str, int start, int end) Replaces text from the indicated start to end position with the new text specified. Void setColumns(int columns) Sets the number of columns for this TextArea. Void setTabSize(int size) Sets the number of characters to expand tabs to. Void setWrapStyleWord(boolean word) Sets the style of wrapping used if the text area is wrapping lines.
  32. Coding of JTextArea with ScrollPane JTextArea textArea2 = new JTextArea(text, 5, 10); textArea2.setLineWrap(true); JScrollPane scrollPane = new JScrollPane(textArea2,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); frame.add(scrollPane);
  33. Why JScrollPane used with JTextArea? A JTextArea object represents a multiline area for displaying text. If Text is too large from JTextArea Boundaries(Width, Height) then You can also put your JTextArea in a JScrollPane to make it scrollable.