alexander-r
1/21/2017 - 3:45 PM

Snippets

Snippets

//  Make button default
JRootPane rootPane = SwingUtilities.getRootPane(/* Your JButton  */); 
rootPane.setDefaultButton(/* Your JButton  */);

//  Array to set
Set<T> mySet = new HashSet<T>(Arrays.asList(someArray));

//  Lock table columns
data_table.getTableHeader().setReorderingAllowed(false);

//  Do not allow table column reordering
getTableHeader().setReorderingAllowed(false);

//  Disable row sorting 
setRowSorter(null);

//  Swing runnable
		SwingUtilities.invokeLater(new Runnable() {
			
			public void run() {
				
        //  Code to run
			}
		});	

//  Safe file name
String name = s.replaceAll("\\W+", "");

//  Position frame in the center of the screen
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(dim.width/2-this.getSize().width/2, dim.height/2-this.getSize().height/2);