SlideShare a Scribd company logo
1 of 14
CS3135/CS2135
Object Oriented Programming (Java)
BSCS-3 / MCS-3
Lecture # 10
Jtable
JTabbedPane
LayoutManagers
javax.swing.JTable
• JTable()
• JTable(int, int) //rows, columns
• JTable(Object[][], Object[]) // data values, headings
• JTable(TableModel) // structure of table
javax.swing.table.DefaultTableModel
• DefaultTableModel() // zero columns and zero rows
• DefaultTableModel(int, int) // total rows, total columns with null values
• DefaultTableModel(Object[][], Object[]) // data values, column names
• DefaultTableModel(Object[], int) // column names, total rows with null data values
GUI Components  JFrame  JTable
Instructor: Tanzila Kehkashan
2
• void addColumn(Object) // column name
• void addColumn(Object, Object[]) //column name, column data
• void addRow(Object[]) //row data
• int getColumnCount()
• void setColumnCount(int) // total columns
• String getColumnName(int) //column index
• int getRowCount()
• void setRowCount(int) //total rows
• Object getValueAt(int, int) //row, column
• void insertRow(int, Object[]) //row index, row data
• void removeRow(int) //row index
• void setValueAt(Object, int, int) //value, row index, column index
GUI Components  JFrame  JTable
Instructor: Tanzila Kehkashan
3
Instructor: Tanzila Kehkashan
4
javax.swing.JTabbedPane
• JTabbedPane()
• JTabbedPane(int)
• TOP
• BOTTOM
• LEFT
• RIGHT
• Component add(Component)
• Component add(Component, int) // index
• void add(String, Component) //title
• void addTab(String, Component) //title
• int getSelectedIndex()
• int getTabCount()
• void removeTabAt(int index)
• void setBackgroundAt(int, Color) // tab index, color
• int setSelectedIndex(int) //index
• setTitleAt(int, String) index, title
GUI Components  JFrame  JTabbedPane
Instructor: Tanzila Kehkashan
5
• Ways of Arranging Components in GUI
• Uses Container class setLayout() method
1. Absolute Positioning
• Provides greatest level of control by setting setLayout method to null. But it can be
tedious to set absolute positioning.
• Methods like setSize, setLocation, and setBounds are used.
2. Layout Managers
• FlowLayout
• BorderLayout
• GridLayout
3. Visual Programming in an IDE
• Provides GUI design tool.
• Supports drag and drop.
Layout Managers
Instructor: Tanzila Kehkashan
6
java.awt.FlowLayout
• Default for javax.swing.JPanel
• Components are placed from left to right in order they are added.
• Automatically places components onto next row, if row is full.
• FlowLayout()
• FlowLayout(int) // alignment
Alignment Constants
• FlowLayout.LEFT
• FlowLayout.RIGHT
• FlowLayout.CENTER (default)
• void setAlignment(int)// alignment
• int getAlignment()
Layout Managers  FlowLayout
Instructor: Tanzila Kehkashan
7
java.awt.BorderLayout
• Default for javax.swing.JFrame
• Arranges components in five regions
• Places upto five components in a container one in each region.
• Automatically displaces previous component, if component is already occupied in the position.
• BorderLayout()
• BorderLayout(int, int) // horizontal gap, vertical gap
Regions
• BorderLayout.NORTH
• BorderLayout.SOUTH
• BorderLayout.EAST
• BorderLayout.WEST
• BorderLayout.CENTER
Layout Managers  BorderLayout
Instructor: Tanzila Kehkashan
8
java.awt.GridLayout
• Divides container into a grid so that components can be placed in rows and columns.
• Each component has same width and height.
• GridLayout()
• GridLayout(int, int) // rows, columns
• GridLayout(int, int, int, int) // rows, columns, horizontal gap, vertical gap
• int getColumns()
• int getHgap()
• int getRows()
• int getVgap()
• void setColumns(int cols)
• void setHgap(int hgap)
• void setRows(int rows)
• void setVgap(int vgap)
Layout Managers  GridLayout
Instructor: Tanzila Kehkashan
9
Instructor: Tanzila Kehkashan
10
Instructor: Tanzila Kehkashan
11
Instructor: Tanzila Kehkashan
12
Instructor: Tanzila Kehkashan
13
Instructor: Tanzila Kehkashan
14

More Related Content

Similar to OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx

Android android layouts
Android android layoutsAndroid android layouts
Android android layouts
perpetrotech
 
Java class 5
Java class 5Java class 5
Java class 5
Edureka!
 

Similar to OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx (20)

KNOWAGE CUSTOM CHART WIDGET: a technical guide
KNOWAGE CUSTOM CHART WIDGET: a technical guideKNOWAGE CUSTOM CHART WIDGET: a technical guide
KNOWAGE CUSTOM CHART WIDGET: a technical guide
 
Creating Dynamic Charts With JFreeChart
Creating Dynamic Charts With JFreeChartCreating Dynamic Charts With JFreeChart
Creating Dynamic Charts With JFreeChart
 
Android android layouts
Android android layoutsAndroid android layouts
Android android layouts
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
Mat lab workshop
Mat lab workshopMat lab workshop
Mat lab workshop
 
Alternatives of JPA/Hibernate
Alternatives of JPA/HibernateAlternatives of JPA/Hibernate
Alternatives of JPA/Hibernate
 
Scala ntnu
Scala ntnuScala ntnu
Scala ntnu
 
Java class 5
Java class 5Java class 5
Java class 5
 
02basics
02basics02basics
02basics
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1Lazy vs. Eager Loading Strategies in JPA 2.1
Lazy vs. Eager Loading Strategies in JPA 2.1
 
Sathya Final review
Sathya Final reviewSathya Final review
Sathya Final review
 
standard template library(STL) in C++
standard template library(STL) in C++standard template library(STL) in C++
standard template library(STL) in C++
 
CAP615-Unit1.pptx
CAP615-Unit1.pptxCAP615-Unit1.pptx
CAP615-Unit1.pptx
 
Python programming
Python programmingPython programming
Python programming
 
Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2Collections Framework Beginners Guide 2
Collections Framework Beginners Guide 2
 
Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2
 

More from Tanzila Kehkashan

More from Tanzila Kehkashan (20)

OOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptxOOP Lecture 25-Network Programming-Part2.pptx
OOP Lecture 25-Network Programming-Part2.pptx
 
OOP Lecture 24-Network Programming-Part1.pptx
OOP Lecture 24-Network Programming-Part1.pptxOOP Lecture 24-Network Programming-Part1.pptx
OOP Lecture 24-Network Programming-Part1.pptx
 
OOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptxOOP Lecture 23-JAR Files.pptx
OOP Lecture 23-JAR Files.pptx
 
OOP Lecture 22-JApplet.pptx
OOP Lecture 22-JApplet.pptxOOP Lecture 22-JApplet.pptx
OOP Lecture 22-JApplet.pptx
 
OOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptxOOP Lecture 21-Graphics, Audio.pptx
OOP Lecture 21-Graphics, Audio.pptx
 
OOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptxOOP Lecture 20-MultiThreading.pptx
OOP Lecture 20-MultiThreading.pptx
 
OOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptxOOP Lecture 19-JMenuBar.pptx
OOP Lecture 19-JMenuBar.pptx
 
OOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptxOOP Lecture 18-DB Connectivity-Part2.pptx
OOP Lecture 18-DB Connectivity-Part2.pptx
 
OOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptxOOP Lecture 17-DB Connectivity-Part1.pptx
OOP Lecture 17-DB Connectivity-Part1.pptx
 
OOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptxOOP Lecture 16-Math,Timer.pptx
OOP Lecture 16-Math,Timer.pptx
 
OOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptxOOP Lecture 15-FileHandling,JFileChooser.pptx
OOP Lecture 15-FileHandling,JFileChooser.pptx
 
OOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptxOOP Lecture 14-ExceptionHandling.pptx
OOP Lecture 14-ExceptionHandling.pptx
 
OOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptxOOP Lecture 13-Color,Font,ImageIcon.pptx
OOP Lecture 13-Color,Font,ImageIcon.pptx
 
OOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptxOOP Lecture 12-EventHandling2.pptx
OOP Lecture 12-EventHandling2.pptx
 
OOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptxOOP Lecture 11-EventHandling1.pptx
OOP Lecture 11-EventHandling1.pptx
 
OOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptxOOP Lecture 9-JComboBox,JList,JPanel.pptx
OOP Lecture 9-JComboBox,JList,JPanel.pptx
 
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptxOOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
OOP Lecture 8-JCheckBox,JRadioButton,JProgressBar.pptx
 
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptxOOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
OOP Lecture 7-JTextField,JTextArea,JPassword,JButton.pptx
 
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptxOOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
OOP Lecture 5-Inheritance,Dialogboxes,Parsing.pptx
 
OOP Lecture 4-Arrays, String.pptx
OOP Lecture 4-Arrays, String.pptxOOP Lecture 4-Arrays, String.pptx
OOP Lecture 4-Arrays, String.pptx
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 

OOP Lecture 10-JTable,JTabbedPane,LayoutManagers.pptx

  • 1. CS3135/CS2135 Object Oriented Programming (Java) BSCS-3 / MCS-3 Lecture # 10 Jtable JTabbedPane LayoutManagers
  • 2. javax.swing.JTable • JTable() • JTable(int, int) //rows, columns • JTable(Object[][], Object[]) // data values, headings • JTable(TableModel) // structure of table javax.swing.table.DefaultTableModel • DefaultTableModel() // zero columns and zero rows • DefaultTableModel(int, int) // total rows, total columns with null values • DefaultTableModel(Object[][], Object[]) // data values, column names • DefaultTableModel(Object[], int) // column names, total rows with null data values GUI Components  JFrame  JTable Instructor: Tanzila Kehkashan 2
  • 3. • void addColumn(Object) // column name • void addColumn(Object, Object[]) //column name, column data • void addRow(Object[]) //row data • int getColumnCount() • void setColumnCount(int) // total columns • String getColumnName(int) //column index • int getRowCount() • void setRowCount(int) //total rows • Object getValueAt(int, int) //row, column • void insertRow(int, Object[]) //row index, row data • void removeRow(int) //row index • void setValueAt(Object, int, int) //value, row index, column index GUI Components  JFrame  JTable Instructor: Tanzila Kehkashan 3
  • 5. javax.swing.JTabbedPane • JTabbedPane() • JTabbedPane(int) • TOP • BOTTOM • LEFT • RIGHT • Component add(Component) • Component add(Component, int) // index • void add(String, Component) //title • void addTab(String, Component) //title • int getSelectedIndex() • int getTabCount() • void removeTabAt(int index) • void setBackgroundAt(int, Color) // tab index, color • int setSelectedIndex(int) //index • setTitleAt(int, String) index, title GUI Components  JFrame  JTabbedPane Instructor: Tanzila Kehkashan 5
  • 6. • Ways of Arranging Components in GUI • Uses Container class setLayout() method 1. Absolute Positioning • Provides greatest level of control by setting setLayout method to null. But it can be tedious to set absolute positioning. • Methods like setSize, setLocation, and setBounds are used. 2. Layout Managers • FlowLayout • BorderLayout • GridLayout 3. Visual Programming in an IDE • Provides GUI design tool. • Supports drag and drop. Layout Managers Instructor: Tanzila Kehkashan 6
  • 7. java.awt.FlowLayout • Default for javax.swing.JPanel • Components are placed from left to right in order they are added. • Automatically places components onto next row, if row is full. • FlowLayout() • FlowLayout(int) // alignment Alignment Constants • FlowLayout.LEFT • FlowLayout.RIGHT • FlowLayout.CENTER (default) • void setAlignment(int)// alignment • int getAlignment() Layout Managers  FlowLayout Instructor: Tanzila Kehkashan 7
  • 8. java.awt.BorderLayout • Default for javax.swing.JFrame • Arranges components in five regions • Places upto five components in a container one in each region. • Automatically displaces previous component, if component is already occupied in the position. • BorderLayout() • BorderLayout(int, int) // horizontal gap, vertical gap Regions • BorderLayout.NORTH • BorderLayout.SOUTH • BorderLayout.EAST • BorderLayout.WEST • BorderLayout.CENTER Layout Managers  BorderLayout Instructor: Tanzila Kehkashan 8
  • 9. java.awt.GridLayout • Divides container into a grid so that components can be placed in rows and columns. • Each component has same width and height. • GridLayout() • GridLayout(int, int) // rows, columns • GridLayout(int, int, int, int) // rows, columns, horizontal gap, vertical gap • int getColumns() • int getHgap() • int getRows() • int getVgap() • void setColumns(int cols) • void setHgap(int hgap) • void setRows(int rows) • void setVgap(int vgap) Layout Managers  GridLayout Instructor: Tanzila Kehkashan 9