001package jmri.jmrit.throttle; 002 003import java.awt.BorderLayout; 004import java.awt.GridLayout; 005import java.awt.event.ActionEvent; 006 007import javax.swing.*; 008 009import jmri.util.JmriJFrame; 010 011/** 012 * A frame to display and edit Throttles preferences 013 * 014 * @author Lionel Jeanson - 2021 015 * 016 */ 017public final class ThrottlesPreferencesWindow extends JmriJFrame { 018 019 private JButton jbApply; 020 private JButton jbCancel; 021 private JButton jbSave; 022 private ThrottlesPreferencesPane tpP; 023 024 ThrottlesPreferencesWindow(String title) { 025 super(title); 026 initComponents(); 027 } 028 029 @Override 030 public void initComponents() { 031 super.initComponents(); 032 033 tpP = new ThrottlesPreferencesPane(); 034 035 jbCancel = new JButton(); 036 jbSave = new JButton(); 037 jbApply = new JButton(); 038 039 jbSave.setText(Bundle.getMessage("ButtonSave")); 040 jbSave.addActionListener((ActionEvent e) -> { 041 tpP.savePreferences(); 042 setVisible(false); 043 }); 044 045 jbCancel.setText(Bundle.getMessage("ButtonCancel")); 046 jbCancel.addActionListener((ActionEvent e) -> { 047 setVisible(false); 048 }); 049 050 jbApply.setText(Bundle.getMessage("ButtonApply")); 051 jbApply.addActionListener((ActionEvent e) -> { 052 tpP.applyPreferences(); 053 }); 054 055 JPanel buttonsPanel = new JPanel(new BorderLayout()); 056 buttonsPanel.setLayout(new GridLayout(1, 2, 4, 4)); 057 buttonsPanel.add(jbCancel); 058 buttonsPanel.add(jbApply); 059 buttonsPanel.add(jbSave); 060 061 add(tpP, BorderLayout.CENTER); 062 add(buttonsPanel, BorderLayout.SOUTH); 063 } 064 065 public void resetComponents() { 066 tpP.resetComponents(); 067 } 068 069}