private static JInternalFrame[] filterFrame(JInternalFrame[] frames) {
        int n = 0;
        for (int i = 0; i < frames.length; i++) {
            if (frames[i].isVisible() && !frames[i].isIcon()) {
                n++;
            }
        }

        JInternalFrame[] newfs = new JInternalFrame[n];
        for (int i = 0, j = 0; i < frames.length; i++) {
            if (frames[i].isVisible() && !frames[i].isIcon()) {
                newfs[j++] = frames[i];
            }
        }
        return newfs;
    }