Here you can find the source of setDefaultButton(JButton jButton)
public static void setDefaultButton(JButton jButton)
//package com.java2s; import javax.swing.JButton; public class Main { public static void setDefaultButton(JButton jButton) { if (jButton == null) { throw new IllegalArgumentException(); }/*from ww w. jav a2 s. c o m*/ jButton.getRootPane().setDefaultButton(jButton); } }