SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
Swing
Advanced
 Controls
JColorChooser
JColorChooser
     Constructors
           public JColorChooser()
           public JColorChooser(Color clr)
                  | Color clr = new Color(25,135,200);
JColorChooser
     Event Handling
           Retrieve ColorSelectionModel
                  Register ChangeListener object
                         Handle stateChanged method
JColorChooser
     Method
          Color getColor()
          void setColor()
          showDialog(Component, String, Color)
JList
JList
        Constructors
              public JList()
              public Jlist(Object[] items)
              public Jlist(Vector vecItems)
JList
        Event Handling
              Create Jlist
              Create JScrollPane and pass JList
              Add JScrollPane to container
JList
        Method
             public void setSelectionMode(int selectMode)
JList
        Method
             public void setLayoutOrientation(layoutOrient)
JList
        Method
             public void setVisibleRowCount(int count)
JList
        Event Handling
              Register ListSelectionListener
              Handle valueChanged() method
JList
        Method
             public void clearSelection()
             public int getSelectedIndex()
             public int[] getSelectedIndices()
             public boolean isSelectionEmpty()
JList
        Set and Select
               public void setListData(Object[] items)
               public void setSelectedIndex(int index)
               public void setSelectedIndices(int[]
indices)
JComboBox
JComboBox
    Constructors
          public JComboBox()
          public JComboBox(Object[] items)
          public JComboBox(Vector vecItems)
JComboBox
    Steps
            Create a instance of JComboBox
            Add it into container
JComboBox
    Event Handling
          Register ActionListener
                 Handle actionPerformed() method
          Register ItemListener
                 Handle itemStateChanged() method
JComboBox
    Method
         public void addItem(Object item)
         public int getItemCount()
         public int getSelectedIndex()
         public object getSelectedItem()
JComboBox
    Method
         public void setEditable(Boolean editable)
         public void setSelectedIndex(int index)
         public void setSelectedItem(Object item)
JTable
JTable
      Constructors
            public JTable()
            public JTable(int numRows, int numColumns)
            public JTable(Object[][] data, Object[]
column)
            public JTable(Vector data, Vector columns)
            public JTable(TableModel model)
JTable
     Display
JTable
      Drawbacks
             All columns are of same width by default
             Ellipsis is used for displaying data
             Horizontal scrolling will not be activated
because of ellipsis
JTable
     Creating a Custom JTable
           AbstractTableModel
           DefaultTableModel
AbstractTableModel
      public int getRowCount()
      public int getColumnCount()
      public Object getValueAt(int row, int column)

      fireTableDataChanged()
Steps:
         Instantiate data model class
         Instantiate JTable object
         setData()
Event Handling
      Register a MouseListener
             Handle mouseClicked() method
JTree
Constructing a JTree
       Create an instance of DefaultMutableTreeNode
       Create an instance of a JTree
Constructing a JTree
       Create DefaultMutableTreeNode instance
       Add branch nodes
       Add leaf nodes
       Enclose the tree in scrollpane
       Add scrollpane to frame
Constructing a JTree
Event Handling
      Register a TreeSelectionListener
             Handle valueChanged() method
      Register a TreeExpansionListener
             Handle treeExpanded() method
             Handle treeCollapsed() method
      Register a TreeWillExpandListener
             Handle treeWillExpand() method
             Handle treeWillCollapse() method
JTabbedPane
Constructing a JTabbedPane
      public JTabbedPane()
      public JTabbedPane(int placement)
Adding Tabs
        Create JTabbedPane instance
        Create JPanel instance for each tab
        Add the component in the respective panels
        Use the addTab() method of JTabbedPane to add the
panel
Event Handling
      Register a ChangeListener
             Handle stateChanged() method
JSplitPane
Constructing a JSplitPane
       public JSplitPane()
       public JSplitPane(int orientation)
       public JSplitPane(int, boolean)
       public JSplitPane(int, boolean, Component,
Component)
Methods
     void setOneTouchExpandable(boolean)
     void setDividerLocation(int)

Contenu connexe

En vedette

Grammar book Raquel
Grammar book RaquelGrammar book Raquel
Grammar book Raquel
raquel63485
 
เบาหวาน+~..
เบาหวาน+~..เบาหวาน+~..
เบาหวาน+~..
maygaclever
 
10 planete infricosatoare
10 planete infricosatoare10 planete infricosatoare
10 planete infricosatoare
balada65
 
MONTEFARMACO_INTERNO_Position_Paper_Lactoflorene_DEF_10112016
MONTEFARMACO_INTERNO_Position_Paper_Lactoflorene_DEF_10112016MONTEFARMACO_INTERNO_Position_Paper_Lactoflorene_DEF_10112016
MONTEFARMACO_INTERNO_Position_Paper_Lactoflorene_DEF_10112016
Giorgio Cassarà
 
PDF Scanning environment for startegic intervention for youth
PDF Scanning environment for startegic intervention for youthPDF Scanning environment for startegic intervention for youth
PDF Scanning environment for startegic intervention for youth
Mosharaf Hossain
 

En vedette (16)

Aplicaciones moviles gas
Aplicaciones   moviles gasAplicaciones   moviles gas
Aplicaciones moviles gas
 
leadership theories
leadership theoriesleadership theories
leadership theories
 
Grammar book Raquel
Grammar book RaquelGrammar book Raquel
Grammar book Raquel
 
Dataspace presentatie
Dataspace presentatieDataspace presentatie
Dataspace presentatie
 
La maga mil
La maga mil La maga mil
La maga mil
 
E-democracy: Comparison of opportunities in the Western Balkan countries
E-democracy: Comparison of opportunities in the Western Balkan countriesE-democracy: Comparison of opportunities in the Western Balkan countries
E-democracy: Comparison of opportunities in the Western Balkan countries
 
Rock Solid Deployment of Web Applications
Rock Solid Deployment of Web ApplicationsRock Solid Deployment of Web Applications
Rock Solid Deployment of Web Applications
 
Latin I Lesson 07
Latin I Lesson 07Latin I Lesson 07
Latin I Lesson 07
 
Climate chaos, policy dilemmas
Climate chaos, policy dilemmasClimate chaos, policy dilemmas
Climate chaos, policy dilemmas
 
เบาหวาน+~..
เบาหวาน+~..เบาหวาน+~..
เบาหวาน+~..
 
Question 1
Question 1Question 1
Question 1
 
10 planete infricosatoare
10 planete infricosatoare10 planete infricosatoare
10 planete infricosatoare
 
MONTEFARMACO_INTERNO_Position_Paper_Lactoflorene_DEF_10112016
MONTEFARMACO_INTERNO_Position_Paper_Lactoflorene_DEF_10112016MONTEFARMACO_INTERNO_Position_Paper_Lactoflorene_DEF_10112016
MONTEFARMACO_INTERNO_Position_Paper_Lactoflorene_DEF_10112016
 
Notam 28 set
Notam 28 setNotam 28 set
Notam 28 set
 
Nuova Legge 266 Programma 2011
Nuova Legge 266 Programma 2011Nuova Legge 266 Programma 2011
Nuova Legge 266 Programma 2011
 
PDF Scanning environment for startegic intervention for youth
PDF Scanning environment for startegic intervention for youthPDF Scanning environment for startegic intervention for youth
PDF Scanning environment for startegic intervention for youth
 

Similaire à Module 4

13 advanced-swing
13 advanced-swing13 advanced-swing
13 advanced-swing
Nataraj Dg
 
12advanced Swing
12advanced Swing12advanced Swing
12advanced Swing
Adil Jafri
 
01 Java Is Architecture Neutral
01 Java Is Architecture Neutral01 Java Is Architecture Neutral
01 Java Is Architecture Neutral
rajuglobal
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
sotlsoc
 
Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2
PRN USM
 

Similaire à Module 4 (20)

Advanced java programming
Advanced java programmingAdvanced java programming
Advanced java programming
 
Swing basics
Swing basicsSwing basics
Swing basics
 
13 advanced-swing
13 advanced-swing13 advanced-swing
13 advanced-swing
 
Jp notes
Jp notesJp notes
Jp notes
 
Java awt
Java awtJava awt
Java awt
 
12advanced Swing
12advanced Swing12advanced Swing
12advanced Swing
 
Event handling
Event handlingEvent handling
Event handling
 
Unit-1 awt advanced java programming
Unit-1 awt advanced java programmingUnit-1 awt advanced java programming
Unit-1 awt advanced java programming
 
Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#Lo Mejor Del Pdc2008 El Futrode C#
Lo Mejor Del Pdc2008 El Futrode C#
 
Commonality and Variability Analysis: Avoiding Duplicate Code
Commonality and Variability Analysis: Avoiding Duplicate CodeCommonality and Variability Analysis: Avoiding Duplicate Code
Commonality and Variability Analysis: Avoiding Duplicate Code
 
Swing
SwingSwing
Swing
 
01 Java Is Architecture Neutral
01 Java Is Architecture Neutral01 Java Is Architecture Neutral
01 Java Is Architecture Neutral
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
 
Java swing
Java swingJava swing
Java swing
 
Model View Intent on Android
Model View Intent on AndroidModel View Intent on Android
Model View Intent on Android
 
【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例
 
Swing_Introduction.ppt
Swing_Introduction.pptSwing_Introduction.ppt
Swing_Introduction.ppt
 
Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2Graphical User Interface (GUI) - 2
Graphical User Interface (GUI) - 2
 
Java: GUI
Java: GUIJava: GUI
Java: GUI
 
Fabric.js @ Falsy Values
Fabric.js @ Falsy ValuesFabric.js @ Falsy Values
Fabric.js @ Falsy Values
 

Plus de Tuan Ngo

Introduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 enIntroduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 en
Tuan Ngo
 
Net framework
Net frameworkNet framework
Net framework
Tuan Ngo
 
15 anonymous methods, partial types and nullable types
15   anonymous methods, partial types and nullable types15   anonymous methods, partial types and nullable types
15 anonymous methods, partial types and nullable types
Tuan Ngo
 
14 generics and iterators
14   generics and iterators14   generics and iterators
14 generics and iterators
Tuan Ngo
 
13 collections
13   collections13   collections
13 collections
Tuan Ngo
 
11 exception handling
11   exception handling11   exception handling
11 exception handling
Tuan Ngo
 
12 events and delegates
12   events and delegates12   events and delegates
12 events and delegates
Tuan Ngo
 
9 properties & indexers
9   properties & indexers9   properties & indexers
9 properties & indexers
Tuan Ngo
 
10 namespace
10  namespace10  namespace
10 namespace
Tuan Ngo
 
8 abstract classes and interfaces
8   abstract classes and interfaces 8   abstract classes and interfaces
8 abstract classes and interfaces
Tuan Ngo
 
7 inheritance and polymorphism
7   inheritance and polymorphism7   inheritance and polymorphism
7 inheritance and polymorphism
Tuan Ngo
 
6 class and methods
6    class and methods6    class and methods
6 class and methods
Tuan Ngo
 
3 statements and operators
3   statements and operators3   statements and operators
3 statements and operators
Tuan Ngo
 
4 c# programming constructs
4   c# programming constructs4   c# programming constructs
4 c# programming constructs
Tuan Ngo
 
1 get started with c#
1   get started with c#1   get started with c#
1 get started with c#
Tuan Ngo
 
2 variables and data types
2   variables and data types2   variables and data types
2 variables and data types
Tuan Ngo
 

Plus de Tuan Ngo (20)

Introduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 enIntroduction of cg program for portal 20120424 en
Introduction of cg program for portal 20120424 en
 
Net framework
Net frameworkNet framework
Net framework
 
15 anonymous methods, partial types and nullable types
15   anonymous methods, partial types and nullable types15   anonymous methods, partial types and nullable types
15 anonymous methods, partial types and nullable types
 
14 generics and iterators
14   generics and iterators14   generics and iterators
14 generics and iterators
 
13 collections
13   collections13   collections
13 collections
 
11 exception handling
11   exception handling11   exception handling
11 exception handling
 
12 events and delegates
12   events and delegates12   events and delegates
12 events and delegates
 
9 properties & indexers
9   properties & indexers9   properties & indexers
9 properties & indexers
 
10 namespace
10  namespace10  namespace
10 namespace
 
8 abstract classes and interfaces
8   abstract classes and interfaces 8   abstract classes and interfaces
8 abstract classes and interfaces
 
7 inheritance and polymorphism
7   inheritance and polymorphism7   inheritance and polymorphism
7 inheritance and polymorphism
 
5 arrays
5   arrays5   arrays
5 arrays
 
6 class and methods
6    class and methods6    class and methods
6 class and methods
 
3 statements and operators
3   statements and operators3   statements and operators
3 statements and operators
 
4 c# programming constructs
4   c# programming constructs4   c# programming constructs
4 c# programming constructs
 
1 get started with c#
1   get started with c#1   get started with c#
1 get started with c#
 
2 variables and data types
2   variables and data types2   variables and data types
2 variables and data types
 
Jdbc 7
Jdbc 7Jdbc 7
Jdbc 7
 
Jdbc 6
Jdbc 6Jdbc 6
Jdbc 6
 
Jdbc 3
Jdbc 3Jdbc 3
Jdbc 3
 

Dernier

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Dernier (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Module 4

  • 3. JColorChooser Constructors public JColorChooser() public JColorChooser(Color clr) | Color clr = new Color(25,135,200);
  • 4. JColorChooser Event Handling Retrieve ColorSelectionModel Register ChangeListener object Handle stateChanged method
  • 5. JColorChooser Method Color getColor() void setColor() showDialog(Component, String, Color)
  • 7. JList Constructors public JList() public Jlist(Object[] items) public Jlist(Vector vecItems)
  • 8. JList Event Handling Create Jlist Create JScrollPane and pass JList Add JScrollPane to container
  • 9. JList Method public void setSelectionMode(int selectMode)
  • 10. JList Method public void setLayoutOrientation(layoutOrient)
  • 11. JList Method public void setVisibleRowCount(int count)
  • 12. JList Event Handling Register ListSelectionListener Handle valueChanged() method
  • 13. JList Method public void clearSelection() public int getSelectedIndex() public int[] getSelectedIndices() public boolean isSelectionEmpty()
  • 14. JList Set and Select public void setListData(Object[] items) public void setSelectedIndex(int index) public void setSelectedIndices(int[] indices)
  • 16. JComboBox Constructors public JComboBox() public JComboBox(Object[] items) public JComboBox(Vector vecItems)
  • 17. JComboBox Steps Create a instance of JComboBox Add it into container
  • 18. JComboBox Event Handling Register ActionListener Handle actionPerformed() method Register ItemListener Handle itemStateChanged() method
  • 19. JComboBox Method public void addItem(Object item) public int getItemCount() public int getSelectedIndex() public object getSelectedItem()
  • 20. JComboBox Method public void setEditable(Boolean editable) public void setSelectedIndex(int index) public void setSelectedItem(Object item)
  • 22. JTable Constructors public JTable() public JTable(int numRows, int numColumns) public JTable(Object[][] data, Object[] column) public JTable(Vector data, Vector columns) public JTable(TableModel model)
  • 23. JTable Display
  • 24. JTable Drawbacks All columns are of same width by default Ellipsis is used for displaying data Horizontal scrolling will not be activated because of ellipsis
  • 25. JTable Creating a Custom JTable AbstractTableModel DefaultTableModel
  • 26. AbstractTableModel public int getRowCount() public int getColumnCount() public Object getValueAt(int row, int column) fireTableDataChanged()
  • 27. Steps: Instantiate data model class Instantiate JTable object setData()
  • 28. Event Handling Register a MouseListener Handle mouseClicked() method
  • 29. JTree
  • 30. Constructing a JTree Create an instance of DefaultMutableTreeNode Create an instance of a JTree
  • 31. Constructing a JTree Create DefaultMutableTreeNode instance Add branch nodes Add leaf nodes Enclose the tree in scrollpane Add scrollpane to frame
  • 33. Event Handling Register a TreeSelectionListener Handle valueChanged() method Register a TreeExpansionListener Handle treeExpanded() method Handle treeCollapsed() method Register a TreeWillExpandListener Handle treeWillExpand() method Handle treeWillCollapse() method
  • 35. Constructing a JTabbedPane public JTabbedPane() public JTabbedPane(int placement)
  • 36. Adding Tabs Create JTabbedPane instance Create JPanel instance for each tab Add the component in the respective panels Use the addTab() method of JTabbedPane to add the panel
  • 37. Event Handling Register a ChangeListener Handle stateChanged() method
  • 39. Constructing a JSplitPane public JSplitPane() public JSplitPane(int orientation) public JSplitPane(int, boolean) public JSplitPane(int, boolean, Component, Component)
  • 40. Methods void setOneTouchExpandable(boolean) void setDividerLocation(int)