Sunday, July 16, 2023

The TextEvent Class

 

The TextEvent Class Instances of this class describe text events. These are generated by text fields and text areas when characters are entered by a user or program. TextEvent defines the integer constant TEXT_VALUE_CHANGED. 

The one constructor for this class is shown here: TextEvent(Object src, int type) Here, src is a reference to the object that generated this event. The type of the event is specified by type.

The MouseEvent Class

 




Here, src is a reference to the component that generated the event.  The system time at which the mouse event occurred is passed in when. 

The modifiers argument indicates which modifiers were pressed when a mouse event occurred. The coordinates of the mouse are passed in x and y. The click count is passed in clicks. 

The triggersPopup flag indicates if this event causes a pop-up menu to appear on this platform.

 Two commonly used methods in this class are getX( ) and getY( ). 

These return the X and Y coordinates of the mouse within the component when the event occurred. 


Point getPoint( ) It returns a Point object that contains the X,Y coordinates in its integer members: x and y. 

The translatePoint( ) method changes the location of the event. Its form is shown here: void translatePoint(int x, int y) Here, the arguments x and y are added to the coordinates of the event. 

The getClickCount( ) method obtains the number of mouse clicks for this event. Its signature is shown here: int getClickCount( ) 

The isPopupTrigger( ) method tests if this event causes a pop-up menu to appear on this platform. Its form is shown here:  boolean isPopupTrigger( ) 

 int getButton( ) It returns a value that represents the button that caused the event. The return value will be one of these constants defined by MouseEvent: 

NOBUTTON 

BUTTON1

 BUTTON2 

BUTTON3 

The NOBUTTON value indicates that no button was pressed or released. Java SE 6 added three methods to MouseEvent that obtain the coordinates of the mouse relative to the screen rather than the component. 

They are shown here: 

Point getLocationOnScreen( ) 

int getXOnScreen( )

 int getYOnScreen( ) 

The getLocationOnScreen( ) method returns a Point object that contains both the X and Y coordinate. The other two methods return the indicated coordinate

























The ComponentEvent Class

 


The AdjustmentEvent Class



Main Event Classes in java.awt.event

 

Event ClassDescription
ActionEventGenerated when a button is pressed, a list item is double-clicked, or a menu item is selected.
AdjustmentEventGenerated when a scroll bar is manipulated.
ComponentEventGenerated when a component is hidden, moved, resized, or becomes visible.
ContainerEventGenerated when a component is added to or removed from a container.
FocusEventGenerated when a component gains or loses keyboard focus.
InputEvent Abstract superclass for all component input event classes.
ItemEventGenerated when a check box or list item is clicked; also occurs when a choice selection is made or a checkable menu item is selected or deselected.
KeyEventGenerated when input is received from the keyboard.
MouseEventGenerated when the mouse is dragged, moved, clicked, pressed, or released; also generated when the mouse enters or exits a component.
MouseWheelEventGenerated when the mouse wheel is moved
TextEventGenerated when the value of a text area or text field is changed.
WindowEventGenerated when a window is activated, closed, deactivated, deiconified, iconified, opened, or quit.

Events

 Events

an event is an object that describes a state change in a source. It can be generated as a consequence of a person interacting with the elements in a graphical user interface. Some of the activities that cause events to be generated are pressing a button, entering a character via the keyboard, selecting an item in a list, and clicking the mouse.

Events may also occur that are not directly caused by interactions with a user interface. For example, an event may be generated when a timer expires, a counter exceeds a value, software or hardware failure occurs, or an operation is completed.

 

Event Sources

A source is an object that generates an event. This occurs when the internal state of that object changes in some way. Sources may generate more than one type of event.

A source must register listeners in order for the listeners to receive notifications about a specific type of event. Each type of event has its own registration method. Here is the general form:

public void addTypeListener(TypeListener el)

Here, Type is the name of the event, and el is a reference to the event listener.

For example, the method that registers a keyboard event listener is called addKeyListener( ).

The method that registers a mouse motion listener is called addMouseMotionListener( ).

When an event occurs, all registered listeners are notified and receive a copy of the event object. This is known as multicasting the event. In all cases, notifications are sent only to listeners that register to receive them.

 

Event Listeners

A listener is an object that is notified when an event occurs. It has two major requirements. First, it must have been registered with one or more sources to receive notifications about specific types of events. Second, it must implement methods to receive and process these notifications. The methods that receive and process events are defined in a set of interfaces found in java.awt.event.

For example, the MouseMotionListener interface defines two methods to receive notifications when the mouse is dragged or moved. Any object may receive and process one or both of these events if it provides an implementation of this interface.

Event Handling

 

1. Events,Event Sources,Event Listeners--  LINK

2. Main Event Classes in java.awt.event--LINK

3.The AdjustmentEvent Class--LINK

4.The ComponentEvent Class--LINK

5.The MouseEvent ClassLINK

6.The TextEvent Class LINK

7.Sources of Events link

8.Event Listener Interfaces LINK

9.AWT Classes LINK

10.Container class  LINK

Friday, July 14, 2023

FOL


Every child loves Santa.

∀ x (CHILD(x) → LOVES(x,Santa))

Everyone who loves Santa loves any reindeer.

∀ x (LOVES(x,Santa) → ∀ y (REINDEER(y) → LOVES(x,y)))

Rudolph is a reindeer, and Rudolph has a red nose.

REINDEER(Rudolph) ∧ REDNOSE(Rudolph)

Anything which has a red nose is weird or is a clown.

∀ x (REDNOSE(x) → WEIRD(x) ∨ CLOWN(x))

No reindeer is a clown.

¬ ∃ x (REINDEER(x) ∧ CLOWN(x))

Scrooge does not love anything which is weird.

∀ x (WEIRD(x) → ¬ LOVES(Scrooge,x))

(Conclusion) Scrooge is not a child.

¬ CHILD(Scrooge)


Anyone who buys carrots by the bushel owns either a rabbit or a grocery store.

∀ x (BUY(x) → ∃ y (OWNS(x,y) ∧ (RABBIT(y) ∨ GROCERY(y))))

Every dog chases some rabbit.

∀ x (DOG(x) → ∃ y (RABBIT(y) ∧ CHASE(x,y)))

Mary buys carrots by the bushel.

BUY(Mary)

Anyone who owns a rabbit hates anything that chases any rabbit.

∀ x ∀ y (OWNS(x,y) ∧ RABBIT(y) → ∀ z ∀ w (RABBIT(w) ∧ CHASE(z,w) → HATES(x,z)))

John owns a dog.

∃ x (DOG(x) ∧ OWNS(John,x))

Someone who hates something owned by another person will not date that person.

∀ x ∀ y ∀ z (OWNS(y,z) ∧ HATES(x,z) → ¬ DATE(x,y))

(Conclusion) If Mary does not own a grocery store, she will not date John.

(( ¬ ∃ x (GROCERY(x) ∧ OWN(Mary,x))) → ¬ DATE(Mary,John))



Every Austinite who is not conservative loves some armadillo.

∀ x (AUSTINITE(x) ∧ ¬ CONSERVATIVE(x) → ∃ y (ARMADILLO(y) ∧ LOVES(x,y)))

Anyone who wears maroon-and-white shirts is an Aggie.

∀ x (WEARS(x) → AGGIE(x))

Every Aggie loves every dog.

∀ x (AGGIE(x) → ∀ y (DOG(y) → LOVES(x,y)))

Nobody who loves every dog loves any armadillo.

¬ ∃ x ((∀ y (DOG(y) → LOVES(x,y))) ∧ ∃ z (ARMADILLO(z) ∧ LOVES(x,z)))

Clem is an Austinite, and Clem wears maroon-and-white shirts.

AUSTINITE(Clem) ∧ WEARS(Clem)

(Conclusion) Is there a conservative Austinite?

∃ x (AUSTINITE(x) ∧ CONSERVATIVE(x)).




Anyone whom Mary loves is a football star.

∀ x (LOVES(Mary,x) → STAR(x))

Any student who does not pass does not play.

∀ x (STUDENT(x) ∧ ¬ PASS(x) → ¬ PLAY(x))

John is a student.

STUDENT(John)

Any student who does not study does not pass.

∀ x (STUDENT(x) ∧ ¬ STUDY(x) → ¬ PASS(x))

Anyone who does not play is not a football star.

∀ x (¬ PLAY(x) → ¬ STAR(x))

(Conclusion) If John does not study, then Mary does not love John.

¬ STUDY(John) → ¬ LOVES(Mary,John)



Every coyote chases some roadrunner.

∀ x (COYOTE(x) → ∃ y (RR(y) ∧ CHASE(x,y)))

Every roadrunner who says ``beep-beep'' is smart.

∀ x (RR(x) ∧ BEEP(x) → SMART(x))

No coyote catches any smart roadrunner.

¬ ∃ x ∃ y (COYOTE(x) ∧ RR(y) ∧ SMART(y) ∧ CATCH(x,y))

Any coyote who chases some roadrunner but does not catch it is frustrated.

∀ x (COYOTE(x) ∧ ∃ y (RR(y) ∧ CHASE(x,y) ∧ ¬ CATCH(x,y)) → FRUSTRATED(x))

(Conclusion) If all roadrunners say ``beep-beep'', then all coyotes are frustrated.

(∀ x (RR(x) → BEEP(x)) → (∀ y (COYOTE(y) → FRUSTRATED(y)))


Anyone who rides any Harley is a rough character.

∀ x ((∃ y (HARLEY(y) ∧ RIDES(x,y))) → ROUGH(x))

Every biker rides [something that is] either a Harley or a BMW.

∀ x (BIKER(x) → ∃ y ((HARLEY(y) ∨ BMW(y)) ∧ RIDES(x,y)))

Anyone who rides any BMW is a yuppie.

∀ x ∀ y (RIDES(x,y) ∧ BMW(y) → YUPPIE(x))

Every yuppie is a lawyer.

∀ x (YUPPIE(x) → LAWYER(x))

Any nice girl does not date anyone who is a rough character.

∀ x ∀ y (NICE(x) ∧ ROUGH(y) → ¬ DATE(x,y))

Mary is a nice girl, and John is a biker.

NICE(Mary) ∧ BIKER(John)

(Conclusion) If John is not a lawyer, then Mary does not date John.

¬ LAWYER(John) → ¬ DATE(Mary,John)



Every child loves anyone who gives the child any present.

∀ x ∀ y ∀ z (CHILD(x) ∧ PRESENT(y) ∧ GIVE(z,y,x) → LOVES(x,z)

Every child will be given some present by Santa if Santa can travel on Christmas eve.

TRAVEL(Santa,Christmas) → ∀ x (CHILD(x) → ∃ y (PRESENT(y) ∧ GIVE(Santa,y,x)))

It is foggy on Christmas eve.

FOGGY(Christmas)

Anytime it is foggy, anyone can travel if he has some source of light.

∀ x ∀ t (FOGGY(t) → ( ∃ y (LIGHT(y) ∧ HAS(x,y)) → TRAVEL(x,t)))

Any reindeer with a red nose is a source of light.

∀ x (RNR(x) → LIGHT(x))

(Conclusion) If Santa has some reindeer with a red nose, then every child loves Santa.

( ∃ x (RNR(x) ∧ HAS(Santa,x))) → ∀ y (CHILD(y) → LOVES(y,Santa))



Every investor bought [something that is] stocks or bonds.

∀ x (INVESTOR(x) → ∃ y ((STOCK(y) ∨ BOND(y)) ∧ BUY(x,y)))

If the Dow-Jones Average crashes, then all stocks that are not gold stocks fall.

DJCRASH → ∀ x ((STOCK(x) ∧ ¬ GOLD(x)) → FALL(x))

If the T-Bill interest rate rises, then all bonds fall.

TBRISE → ∀ x (BOND(x) → FALL(x))

Every investor who bought something that falls is not happy.

∀ x ∀ y (INVESTOR(x) ∧ BUY(x,y) ∧ FALL(y) &rarrm; ¬ HAPPY(x))

(Conclusion) If the Dow-Jones Average crashes and the T-Bill interest rate rises, then any investor who is happy bought some gold stock.

( DJCRASH ∧ TBRISE ) → ∀ x (INVESTOR(x) ∧ HAPPY(x) → ∃ y (GOLD(y) ∧ BUY(x,y)))



Every child loves every candy.

∀ x ∀ y (CHILD(x) ∧ CANDY(y) → LOVES(x,y))

Anyone who loves some candy is not a nutrition fanatic.

∀ x ( (∃ y (CANDY(y) ∧ LOVES(x,y))) → ¬ FANATIC(x))

Anyone who eats any pumpkin is a nutrition fanatic.

∀ x ((∃ y (PUMPKIN(y) ∧ EAT(x,y))) → FANATIC(x))

Anyone who buys any pumpkin either carves it or eats it.

∀ x ∀ y (PUMPKIN(y) ∧ BUY(x,y) → CARVE(x,y) ∨ EAT(x,y))

John buys a pumpkin.

∃ x (PUMPKIN(x) ∧ BUY(John,x))

Lifesavers is a candy.

CANDY(Lifesavers)

(Conclusion) If John is a child, then John carves some pumpkin.

CHILD(John) → ∃ x (PUMPKIN(x) ∧ CARVE(John,x))



REF:::https://www.cs.utexas.edu/

AI THEORY

1. What is AI ?

2. Turing Test  

3. Strong AI,Weak AI,Applied AI,Cognitive AI

4. Agents,Intelligent Agents,Rational Agent - JAVAPOINT LINK

5. ideal agent,autonomous agent

5. Agent Faculties



1.syntax of a language

2.The semantics

3.Sound,complete 

4. tautologies,satisfiable

5.Modus Ponens or Implication-Elimination,Modus tollens

 Resolution,



1.Atomic sentences,Complex sentences,Universal quantification (V),Existential quantification

2.Forward-chaining algorithm,Backward-chaining algorithm

3.Skolemization
4.A Horn clause is a clause with at most one positive literal




1.Semantic Nets
2.Inferential Knowledge
3.Simple relational knowledge 
4.Inferential Knowledge
5.Procedural knowledge





Frames, scriptLINK

Sunday, July 9, 2023

WRAPPER CLASS-CHARACTER

 Constructor

Character(char c)


Methods: 

1. isLetter (): This method returns a boolean value, i.e true or false. It returns true if the argument passed in the method is a letter i.e any character in between a-z and A-Z. Otherwise it returns false.

2.isDigit(): The isDigit method as the name suggests checks whether the parameter passed to it is a digit or not. It returns true if the argument passed is a digit. Else it returns false.

3.sWhitespace(): It checks whether the value of the argument passed is a white space or not. However this method also returns true if the argument is a tab or new line.

4.isUppercase(): This method is primarily used for checking whether the character passed in the argument is an UpperCase character or not. It returns true if the character is in Uppercase. If not, it returns false.

5.isLowercase(): This method is primarily used for checking whether the character passed in the argument is a LowerCase character or not. It returns true if the character is in LowerCase. If not, it returns false.

6.toUpperCase(): This method is a character returning method. This takes the argument and converts it into an uppercase alphabet. It returns an uppercase alphabet.

7.toLowerCase (): Java toLowerCase method converts the arguments passed to it into lowercase. However, if a numeric value i.e ASCII value of an UpperCase letter is passed through it returns the ASCII value of the corresponding lowercase alphabet.

8.toString (): This method has the responsibility of converting the character arguments passed through it, to String objects for manipulation as and when required by the programmer. ASCII values cannot be passed as arguments here.



Escape Sequences in Java

There are some particular characters, which when preceded with a backslash(\), holds special meaning to the compiler. Some of the escape sequences are:


\n- creates a new line

\t- creates a tab space

\b- inserts a single backspace

\r-inserts carriage return

\\- inserts a backslash character

\’- inserts single quote character

\” – inserts double-quote character



REF:https://data-flair.training/