001package jmri.jmrit.operations.rollingstock.tools; 002 003import java.awt.Dimension; 004import java.awt.GridBagLayout; 005 006import javax.swing.JButton; 007import javax.swing.JComboBox; 008 009import jmri.jmrit.operations.*; 010import jmri.jmrit.operations.setup.Control; 011 012/** 013 * Frame for editing attribute maximum length. 014 * 015 * @author Daniel Boudreau Copyright (C) 2025 016 */ 017public class AttributeCharacterLengthFrame extends OperationsFrame { 018 019 // major buttons 020 public JButton saveButton = new JButton(Bundle.getMessage("ButtonSave")); 021 022 JComboBox<Integer> comboBox; 023 024 public AttributeCharacterLengthFrame() { 025 initComponents(); 026 } 027 028 @Override 029 public void initComponents() { 030 setTitle(Bundle.getMessage("ChangeCharLength")); 031 getContentPane().setLayout(new GridBagLayout()); 032 033 comboBox = new JComboBox<Integer>(); 034 // allow user to select 4 to 20 characters 035 for (int i = 4; i < 21; i++) { 036 comboBox.addItem(i); 037 } 038 OperationsPanel.padComboBox(comboBox, 3); 039 comboBox.setSelectedItem(Control.max_len_string_attibute); 040 addItem(comboBox, 0, 0); 041 addItem(saveButton, 1, 0); 042 043 addButtonAction(saveButton); 044 045 initMinimumSize(new Dimension(Control.panelWidth500, Control.panelHeight100)); 046 } 047 048 @Override 049 public void buttonActionPerformed(java.awt.event.ActionEvent ae) { 050 // the only button is save 051 Control.setMaxCharLength((int) comboBox.getSelectedItem()); 052 OperationsXml.save(); 053 } 054 055 // private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(CarAttributeEditFrame.class); 056}