Java Utililty Methods JFrame

List of utility methods to do JFrame

Description

The list of methods to do JFrame are organized into topic(s).

Method

voidsetFrameTitle(JFrame frame, File file)
Sets the frame title based on the name of the file.
if (file != null) {
    frame.setTitle(file.getName().substring(0, file.getName().lastIndexOf('.')));
    frame.getRootPane().putClientProperty("Window.documentFile", file);
} else
    frame.setTitle("untitled");
voidsetGeneralParameters(final JFrame window)
set General Parameters
window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
window.validate();
window.pack();
window.setVisible(true);
voidsetInfo(String info, JFrame root)
set Info
sumError += 1;
info.equals("");
Component[] components = root.getRootPane().getContentPane().getComponents();
for (int i = 0; i < components.length; i++) {
    if (components[i].getClass().toString().equals("class javax.swing.JScrollPane")) {
        JTextArea textarea = (JTextArea) ((JScrollPane) components[i]).getViewport().getView();
        if (info.equals("")) {
            sumError = 0;
...
voidsetJFrameAlwaysOnTop(JFrame frame, boolean newValue)
set J Frame Always On Top
frame.setAlwaysOnTop(newValue);
voidsetMainWindowLocation(JFrame jfrm, String strPropertiesFilePath, String strPropertiesFileName)
Set the location of a JFrame using the values in a specified properties file at a specified location.
if (props == null) {
    props = new Properties();
    loadProperties(strPropertiesFilePath, strPropertiesFileName);
setMainWindowLocation(jfrm);
voidsetPanel(JPanel parent, JPanel child, JFrame f)
Sets a panel inside a panel and updates the size of the containing window.
parent.removeAll();
parent.add(child);
parent.updateUI();
f.pack();
voidsetPersistentExtendedStateMask(JFrame frame, int persistentExtendedStateMask)
Sets JFrame extended state mask on this frame.
frame.getRootPane().putClientProperty(FRAME_PERSISTENT_EXTENDED_STATE_MASK, persistentExtendedStateMask);
voidsetWindowListenerDispose(JFrame frame)
set Window Listener Dispose
frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent evt) {
        evt.getWindow().dispose();
});
voidsetWindowRightSide(final JFrame frame)
set Window Right Side
frame.setExtendedState(JFrame.NORMAL);
giveFrameHalfScreen(frame);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice defaultScreen = ge.getDefaultScreenDevice();
Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds();
int x = (int) rect.getMaxX() - frame.getWidth();
int y = 0;
frame.setLocation(x, y);
...
voidsetWinVisible(final JFrame win, final boolean vis)
set Win Visible
SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        win.setVisible(vis);
});