Beruflich Dokumente
Kultur Dokumente
Selection Structure
SO BEFORE WE START YOU MUST HAVE COURAGE AND PATIENCE TO
UNDERGO THIS TOPIC. IF YOU HAVE THIS TWO YOU MAY LISTEN
ATTENTIVELY OR ELSE JUST DO WHAT YOU WANT TO DO!
CONFIRMATION DIALOG
DO YOU WANT TO CONTINUE?
public static void main(String[] args) {
int input;
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (input == JOptionPane.NO_OPTION){
System.out.println("Option Close");
}
OUTPUT
DO YOU WANT TO PROCEED?
• ConfirmDialog2b.java
package com.mkyong.confirmDialog;
import javax.swing.JOptionPane;
public class ConfirmDialog2b {
public static void main(String[] args) {
int input = JOptionPane.showConfirmDialog(null,
"Do you want to proceed?", "Select an Option...",JOptionPane.YES_NO_CANCEL_OPTION);
// 0=yes, 1=no, 2=cancel
System.out.println(input);
}
}
OUTPUT
SO ARE YOU CATCHING UP?
DEBUGGING
• Breakpoint is a marker that you can set to specify where execution should pause when your are running
your application in the IDE debugger. With Breakpoints you can :
• Monitor the values of variables
• Take control of program execution by stepping through code line by line.
• Detect if an object is created.
• Detect when the value of a variable is changed.
FOLLOWING THINGS YOU CAN PERFORM WITH
NEATBEANS DEBUGGER:
Debugger Interface
LAYER 1
Neatbeans debugger allows you to enable remote debugging to already running in Java application. For
this, you must run your application in debug mode, which requires below parameters.
-Xdebug –Xrunjdwp:transport=dt_socket, server=y, address=<<port number>>, suspend=n
Example:
Java Xdebug - Xrunjdwp:transport=dt_socket, server=y address=65535, suspend= n
PARAMETER DESCRIPTION
• F7 – Step Into : Executes each sources line, if it has method call, and source code is available, pointer
moves to that method and executes it, other wise pointer moves to the next line in the file.
• F8 – Step Over : Executes each source line without stepping through the individual
instructions/commands.
• F4 – Run to Cursor : Execute the program from the current line.
• F5 – Continue : Resume debugging until it searches a next breakpoint or exception or until the program
terminates normally.
FIXING CODE DURING A DEBUGGING SESSION
• Apply Code Changes – It’s a useful feature. This can save a lot of time, otherwise waiting for source to be rebuilt and
restarting the server/debugging session.
It is useful for:
1. Fine-tune the code. (fixing minor issues)
2. Change the logic within a method.
This does not work for the following changes:
1. Add/remove methods or fields.
2. Change the access modifiers of a class, method, field.
3. Refactor the class hierarchy
• In the simplest form , it should not accept skeleton changes.
• NOTE : Once restarted the server, applied code changes are not taking effect for next time because “
Apply code changes” works on particular JVM instance only.
• For fixing code on the fly while debugging session, you must attach your application source code and jar
files properly.
ADVANTAGES OF USING DEBUGGER