SlideShare uma empresa Scribd logo
1 de 7
JFrame Class
The JFrame class is slightly incompatible with Frame. Like all other JFC/Swing top-level
containers, a JFrame contains a JRootPane as its only child. The content pane provided by the
root pane should, as a rule, contain all the non-menu components displayed by the JFrame.
This is different from the AWT Frame case. As a conveniance add and its variants, remove
and setLayout have been overridden to forward to the contentPane as necessary. This means
you can write:

   frame.add(child);

The JFrame class have a lot of methods.

                       Method Name                       Description
                 showConfirmDialog Asks a confirming question, like yes/no/cancel.
                 showInputDialog      Prompt for some input.
                 showMessageDialog Tell the user about something that has happened.
                 showOptionDialog     The Grand Unification of the above three.




Parameters:
The parameters to these methods follow consistent patterns:

parentComponent:
            Defines the Component that is to be the parent of this dialog box. It is used in
            two ways: the Frame that contains it is used as the Frame parent for the
            dialog box, and its screen coordinates are used in the placement of the
            dialog box. In general, the dialog box is placed just below the component.
            This parameter may be null, in which case a default Frame is used as the
            parent, and the dialog will be centered on the screen (depending on the
            L&F).
message:
            A descriptive message to be placed in the dialog box. In the most common
            usage, message is just a String or String constant. However, the type of this
            parameter is actually Object. Its interpretation depends on its type:
            Object[]
            An array of objects is interpreted as a series of messages (one per object)
            arranged in a vertical stack. The interpretation is recursive -- each object in
            the array is interpreted according to its type.
            Component
The Component is displayed in the dialog.
               Icon
               The Icon is wrapped in a JLabel and displayed in the dialog.
               others
               The object is converted to a String by calling its toString method. The result is
               wrapped in a JLabel and displayed.
messageType:
               Defines the style of the message. The Look and Feel manager may lay out
               the dialog differently depending on this value, and will often provide a
               default icon. The possible values are:

                      ERROR_MESSAGE
                      INFORMATION_MESSAGE
                      WARNING_MESSAGE
                      QUESTION_MESSAGE
                      PLAIN_MESSAGE

optionType:
               Defines the set of option buttons that appear at the bottom of the dialog
               box:

                      DEFAULT_OPTION
                      YES_NO_OPTION
                      YES_NO_CANCEL_OPTION
                      OK_CANCEL_OPTION

               You aren't limited to this set of option buttons. You can provide any
               buttons you want using the options parameter.
options:
               A more detailed description of the set of option buttons that will appear at
               the bottom of the dialog box. The usual value for the options parameter is
               an array of Strings. But the parameter type is an array of Objects. A button is
               created for each object depending on its type:
               Component
               The component is added to the button row directly.
               Icon
               A JButton is created with this as its label.
               other
               The Object is converted to a string using its toString method and the result is
               used to label a JButton.
icon:
               A decorative icon to be placed in the dialog box. A default value for this is
               determined by the messageType parameter.
title:
               The title for the dialog box.
initialValue:
                The default selection (input value).

When the selection is changed, setValue is invoked, which generates a PropertyChangeEvent.

If a JOptionPane has configured to all input setWantsInput the bound property
JOptionPane.INPUT_VALUE_PROPERTY can also be listened to, to determine when the user has
input or selected a value.

When one of the showXxxDialog methods returns an integer, the possible values are:

        YES_OPTION
        NO_OPTION
        CANCEL_OPTION
        OK_OPTION
        CLOSED_OPTION




JOptionPane
  JOptionPane.showConfirmDialog() :
JOptionPane.showMessageDialog() :




JOptionPane.showInputDialog() ;
JOptionPane.showOptionDialog() :




JCheckBox
JPanel Class
The JPanel class provides general-purpose containers for lightweight components. By
default, panels do not add colors to anything except their own background; however, you
can easily add borders to them and otherwise customize their painting.




Setting the Layout Manager
Like other containers, a panel uses a layout manager to position and size its components.
By default, a panel's layout manager is an instance of FlowLayout, which places the panel's
contents in a row. You can easily make a panel use any other layout manager by invoking
the setLayout method or by specifying a layout manager when creating the panel. The latter
approach is preferable for performance reasons, since it avoids the unnecessary creation
of a FlowLayout object.

Here is an example of how to set the layout manager when creating the panel.

JPanel p = new JPanel(new BorderLayout()); //PREFERRED!

This approach does not work with BoxLayout, since the BoxLayout constructor requires a pre-
existing container. Here is an example that uses BoxLayout.

JPanel p = new JPanel();
p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
Adding Components
When you add components to a panel, you use the add method. Exactly which arguments
you specify to the add method depend on which layout manager the panel uses. When the
layout manager is FlowLayout, BoxLayout, GridLayout, or SpringLayout, you will typically use the
one-argument add method, like this:

aFlowPanel.add(aComponent);
aFlowPanel.add(anotherComponent);

When the layout manager is BorderLayout, you need to provide an argument specifying the
added component's position within the panel. For example:

aBorderPanel.add(aComponent, BorderLayout.CENTER);
aBorderPanel.add(anotherComponent, BorderLayout.PAGE_END);

With GridBagLayout you can use either add method, but you must somehow specify grid bag
constraints for each component.

Mais conteúdo relacionado

Mais procurados

Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Javasuraj pandey
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1PRN USM
 
Graphical User Interface in JAVA
Graphical User Interface in JAVAGraphical User Interface in JAVA
Graphical User Interface in JAVAsuraj pandey
 
Java awt tutorial javatpoint
Java awt tutorial   javatpointJava awt tutorial   javatpoint
Java awt tutorial javatpointRicardo Garcia
 
WPF Graphics and Animations
WPF Graphics and AnimationsWPF Graphics and Animations
WPF Graphics and AnimationsDoncho Minkov
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swingadil raja
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Javasuraj pandey
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Javayht4ever
 
Gui programming a review - mixed content
Gui programming   a review - mixed contentGui programming   a review - mixed content
Gui programming a review - mixed contentYogesh Kumar
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDrRajeshreeKhande
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletraksharao
 
PDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPTPDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPTNAVYA RAO
 

Mais procurados (20)

tL19 awt
tL19 awttL19 awt
tL19 awt
 
Gui
GuiGui
Gui
 
Chapter 1 swings
Chapter 1 swingsChapter 1 swings
Chapter 1 swings
 
Java swing
Java swingJava swing
Java swing
 
Basic using of Swing in Java
Basic using of Swing in JavaBasic using of Swing in Java
Basic using of Swing in Java
 
Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1Graphical User Interface (GUI) - 1
Graphical User Interface (GUI) - 1
 
Graphical User Interface in JAVA
Graphical User Interface in JAVAGraphical User Interface in JAVA
Graphical User Interface in JAVA
 
Java awt tutorial javatpoint
Java awt tutorial   javatpointJava awt tutorial   javatpoint
Java awt tutorial javatpoint
 
WPF Graphics and Animations
WPF Graphics and AnimationsWPF Graphics and Animations
WPF Graphics and Animations
 
The AWT and Swing
The AWT and SwingThe AWT and Swing
The AWT and Swing
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 
GUI Programming In Java
GUI Programming In JavaGUI Programming In Java
GUI Programming In Java
 
GUI components in Java
GUI components in JavaGUI components in Java
GUI components in Java
 
Gui programming a review - mixed content
Gui programming   a review - mixed contentGui programming   a review - mixed content
Gui programming a review - mixed content
 
Dr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWTDr. Rajeshree Khande :Introduction to Java AWT
Dr. Rajeshree Khande :Introduction to Java AWT
 
swingbasics
swingbasicsswingbasics
swingbasics
 
java-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of appletjava-Unit4 chap2- awt controls and layout managers of applet
java-Unit4 chap2- awt controls and layout managers of applet
 
Notes netbeans
Notes netbeansNotes netbeans
Notes netbeans
 
PDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPTPDF ON JAVA - JFC CONCEPT
PDF ON JAVA - JFC CONCEPT
 
Java swing
Java swingJava swing
Java swing
 

Destaque

Ingles proyecto traducido
Ingles proyecto traducidoIngles proyecto traducido
Ingles proyecto traducidoJoseph Manuelth
 
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...Ameer Chann
 
Coding club meetup10252014
Coding club meetup10252014Coding club meetup10252014
Coding club meetup10252014Eunhee Ha
 
plm business benefits of a plm system
plm business benefits of a plm systemplm business benefits of a plm system
plm business benefits of a plm systemAmeer Chann
 
코딩클럽 왕초보 아두이노따라잡기 1탄
코딩클럽 왕초보 아두이노따라잡기 1탄코딩클럽 왕초보 아두이노따라잡기 1탄
코딩클럽 왕초보 아두이노따라잡기 1탄Eunhee Ha
 

Destaque (6)

Ingles proyecto traducido
Ingles proyecto traducidoIngles proyecto traducido
Ingles proyecto traducido
 
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...
Bincangkan jurang pencapaian matematik murid sekolah rendah atau sekolah mene...
 
Coding club meetup10252014
Coding club meetup10252014Coding club meetup10252014
Coding club meetup10252014
 
plm business benefits of a plm system
plm business benefits of a plm systemplm business benefits of a plm system
plm business benefits of a plm system
 
Propeller
PropellerPropeller
Propeller
 
코딩클럽 왕초보 아두이노따라잡기 1탄
코딩클럽 왕초보 아두이노따라잡기 1탄코딩클럽 왕초보 아두이노따라잡기 1탄
코딩클럽 왕초보 아두이노따라잡기 1탄
 

Semelhante a Graphic Programming

Semelhante a Graphic Programming (20)

13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Chapter 05
Chapter 05Chapter 05
Chapter 05
 
Java Swing
Java SwingJava Swing
Java Swing
 
ch20.pptx
ch20.pptxch20.pptx
ch20.pptx
 
Abstract Window Toolkit
Abstract Window ToolkitAbstract Window Toolkit
Abstract Window Toolkit
 
UNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdfUNIT-2-AJAVA.pdf
UNIT-2-AJAVA.pdf
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)ITS-16163-Module 8-Graphic User Interface (GUI)
ITS-16163-Module 8-Graphic User Interface (GUI)
 
WPF Controls
WPF ControlsWPF Controls
WPF Controls
 
Unit2
Unit2Unit2
Unit2
 
Chap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptxChap 1 - Introduction GUI.pptx
Chap 1 - Introduction GUI.pptx
 
Chap1 1 1
Chap1 1 1Chap1 1 1
Chap1 1 1
 
Chap1 1.1
Chap1 1.1Chap1 1.1
Chap1 1.1
 
Swing jecrc
Swing jecrc Swing jecrc
Swing jecrc
 
Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
 
Swing
SwingSwing
Swing
 
Swing
SwingSwing
Swing
 
Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892Swingpre 150616004959-lva1-app6892
Swingpre 150616004959-lva1-app6892
 

Último

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 

Último (20)

How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 

Graphic Programming

  • 1. JFrame Class The JFrame class is slightly incompatible with Frame. Like all other JFC/Swing top-level containers, a JFrame contains a JRootPane as its only child. The content pane provided by the root pane should, as a rule, contain all the non-menu components displayed by the JFrame. This is different from the AWT Frame case. As a conveniance add and its variants, remove and setLayout have been overridden to forward to the contentPane as necessary. This means you can write: frame.add(child); The JFrame class have a lot of methods. Method Name Description showConfirmDialog Asks a confirming question, like yes/no/cancel. showInputDialog Prompt for some input. showMessageDialog Tell the user about something that has happened. showOptionDialog The Grand Unification of the above three. Parameters: The parameters to these methods follow consistent patterns: parentComponent: Defines the Component that is to be the parent of this dialog box. It is used in two ways: the Frame that contains it is used as the Frame parent for the dialog box, and its screen coordinates are used in the placement of the dialog box. In general, the dialog box is placed just below the component. This parameter may be null, in which case a default Frame is used as the parent, and the dialog will be centered on the screen (depending on the L&F). message: A descriptive message to be placed in the dialog box. In the most common usage, message is just a String or String constant. However, the type of this parameter is actually Object. Its interpretation depends on its type: Object[] An array of objects is interpreted as a series of messages (one per object) arranged in a vertical stack. The interpretation is recursive -- each object in the array is interpreted according to its type. Component
  • 2. The Component is displayed in the dialog. Icon The Icon is wrapped in a JLabel and displayed in the dialog. others The object is converted to a String by calling its toString method. The result is wrapped in a JLabel and displayed. messageType: Defines the style of the message. The Look and Feel manager may lay out the dialog differently depending on this value, and will often provide a default icon. The possible values are: ERROR_MESSAGE INFORMATION_MESSAGE WARNING_MESSAGE QUESTION_MESSAGE PLAIN_MESSAGE optionType: Defines the set of option buttons that appear at the bottom of the dialog box: DEFAULT_OPTION YES_NO_OPTION YES_NO_CANCEL_OPTION OK_CANCEL_OPTION You aren't limited to this set of option buttons. You can provide any buttons you want using the options parameter. options: A more detailed description of the set of option buttons that will appear at the bottom of the dialog box. The usual value for the options parameter is an array of Strings. But the parameter type is an array of Objects. A button is created for each object depending on its type: Component The component is added to the button row directly. Icon A JButton is created with this as its label. other The Object is converted to a string using its toString method and the result is used to label a JButton. icon: A decorative icon to be placed in the dialog box. A default value for this is determined by the messageType parameter. title: The title for the dialog box.
  • 3. initialValue: The default selection (input value). When the selection is changed, setValue is invoked, which generates a PropertyChangeEvent. If a JOptionPane has configured to all input setWantsInput the bound property JOptionPane.INPUT_VALUE_PROPERTY can also be listened to, to determine when the user has input or selected a value. When one of the showXxxDialog methods returns an integer, the possible values are: YES_OPTION NO_OPTION CANCEL_OPTION OK_OPTION CLOSED_OPTION JOptionPane JOptionPane.showConfirmDialog() :
  • 6. JPanel Class The JPanel class provides general-purpose containers for lightweight components. By default, panels do not add colors to anything except their own background; however, you can easily add borders to them and otherwise customize their painting. Setting the Layout Manager Like other containers, a panel uses a layout manager to position and size its components. By default, a panel's layout manager is an instance of FlowLayout, which places the panel's contents in a row. You can easily make a panel use any other layout manager by invoking the setLayout method or by specifying a layout manager when creating the panel. The latter approach is preferable for performance reasons, since it avoids the unnecessary creation of a FlowLayout object. Here is an example of how to set the layout manager when creating the panel. JPanel p = new JPanel(new BorderLayout()); //PREFERRED! This approach does not work with BoxLayout, since the BoxLayout constructor requires a pre- existing container. Here is an example that uses BoxLayout. JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
  • 7. Adding Components When you add components to a panel, you use the add method. Exactly which arguments you specify to the add method depend on which layout manager the panel uses. When the layout manager is FlowLayout, BoxLayout, GridLayout, or SpringLayout, you will typically use the one-argument add method, like this: aFlowPanel.add(aComponent); aFlowPanel.add(anotherComponent); When the layout manager is BorderLayout, you need to provide an argument specifying the added component's position within the panel. For example: aBorderPanel.add(aComponent, BorderLayout.CENTER); aBorderPanel.add(anotherComponent, BorderLayout.PAGE_END); With GridBagLayout you can use either add method, but you must somehow specify grid bag constraints for each component.