Finds frames with an icon - Java Swing

Java examples for Swing:JFrame

Description

Finds frames with an icon

Demo Code


//package com.java2s;

import java.awt.Frame;

import java.util.ArrayList;

import java.util.List;

public class Main {


    /**/* w ww . ja  v a 2 s . com*/
     * Finds frames with an icon: Frames of {@code Frame#getFrames()} where
     * {@code Frame#getIconImage()} returns not null.
     *
     * @return frames with an icon or an empty list
     */
    public static List<Frame> findFramesWithIcons() {
        List<Frame> frames = new ArrayList<>();
        Frame[] allFrames = Frame.getFrames();

        for (Frame frame : allFrames) {
            if (frame.getIconImage() != null) {
                frames.add(frame);
            }
        }

        return frames;
    }
}

Related Tutorials