Skip to content

Instantly share code, notes, and snippets.

@chalos
Created January 12, 2017 14:53
Show Gist options
  • Save chalos/c484f2dbffdea50c8b28cf5425870778 to your computer and use it in GitHub Desktop.
Save chalos/c484f2dbffdea50c8b28cf5425870778 to your computer and use it in GitHub Desktop.
Accessing package and protected class members
package java.awt
public class AwtHelper {
public static Component getChild(BorderLayout layout, String key) {
Component result = null;
if(key == BorderLayout.NORTH) result = layout.north;
else if(key == BorderLayout.SOUTH) result = layout.south;
else if(key == BorderLayout.WEST) result = layout.west;
else if(key == BorderLayout.EAST) result = layout.east;
else if(key == BorderLayout.CENTER) result = layout.center;
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment