001package jmri.jmrit.etcs.dmi.swing;
002
003import org.apiguardian.api.API;
004
005/**
006 * Class to represent an ERTMS ETCS DMI Screen within a JFrame.
007 * @author Steve Young Copyright (C) 2024
008 * @since 5.7.4
009 */
010@API(status=API.Status.EXPERIMENTAL)
011public class DmiFrame extends jmri.util.JmriJFrame {
012
013    private final DmiPanel main;
014
015    /**
016     * Create a new DmiFrame with a default title.
017     */
018    public DmiFrame(){
019        this("ETCS DMI Frame");
020    }
021
022    /**
023     * Create a new DmiFrame with a given title.
024     * @param frameName the Frame Title.
025     */
026    public DmiFrame(String frameName){
027        super(frameName, false, true);
028        main = new DmiPanel();
029        add(main);
030        getRootPane().setDefaultButton(null);
031        pack();
032    }
033
034    /**
035     * Get the main DmiPanel which controls the DMI Objects.
036     * @return the DmiPanel.
037     */
038    public DmiPanel getDmiPanel(){
039        return main;
040    }
041
042    @Override
043    public void setVisible(boolean visible){
044        jmri.util.ThreadingUtil.runOnGUI( () -> super.setVisible(visible));
045    }
046
047    @Override
048    public void dispose(){
049        main.dispose();
050        super.dispose();
051    }
052
053}