package siprp.higiene.relatorio; import static com.evolute.utils.strings.UnicodeLatin1Map.aacute; import static com.evolute.utils.strings.UnicodeLatin1Map.atilde; import static com.evolute.utils.strings.UnicodeLatin1Map.ccedil; import static com.evolute.utils.strings.UnicodeLatin1Map.eacute; import static com.evolute.utils.strings.UnicodeLatin1Map.iacute; import static com.evolute.utils.strings.UnicodeLatin1Map.oacute; import static com.evolute.utils.strings.UnicodeLatin1Map.otilde; import info.clearthought.layout.TableLayout; import info.clearthought.layout.TableLayoutConstraints; import java.awt.Component; import java.awt.Cursor; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.EventObject; import java.util.List; import java.util.Vector; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JTabbedPane; import javax.swing.JTextField; import javax.swing.event.CaretEvent; import javax.swing.event.CaretListener; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import leaf.data.Validator; import leaf.ui.LeafButton; import leaf.ui.LeafDialog; import leaf.ui.LeafIconButton; import leaf.ui.LeafTextAreaEditor; import siprp.database.cayenne.objects.Estabelecimentos; import siprp.database.cayenne.objects.HsEmailEstabelecimento; import siprp.database.cayenne.objects.HsRelatorio; import siprp.database.cayenne.objects.MarcacoesEstabelecimento; import siprp.database.cayenne.objects.MarcacoesTecnicosHst; import siprp.higiene.gestao.equipamentos.AdicionarEquipamentosPanel; import siprp.higiene.relatorio.print.RelatorioPDFCreator; import siprp.logic.HigieneSegurancaLogic; import siprp.medicina.processo.mail.MailDialog; import siprp.planoactuacao.print.PlanoActuacaoPDFCreator; import com.evolute.utils.ui.calendar.JCalendarPanel; public class PanelRelatorio extends JPanel implements CaretListener, ChangeListener, ActionListener { private static final long serialVersionUID = 1L; private static final int MAX_NOME_ESTABELECIMENTO_ON_FILENAME = 10; private static final String DEFAULT_FUNCIONARIOS_TEXT = "A empresa supracitada possui ? funcionários, sendo que ? destes exercem actividades na zona de produtos frescos."; private static final String ICON_NAME_SAVE = "siprp/higiene/gestao/riscos/save.png"; private static final String ICON_NAME_REVERT = "siprp/higiene/gestao/riscos/revert.png"; private static final String ICON_NAME_SUBMIT = "siprp/higiene/relatorio/submit.png"; private static final String ICON_NAME_PDF = "siprp/higiene/relatorio/adobe_reader.png"; private static final String ICON_NAME_UNDO = "siprp/higiene/relatorio/revert.png"; private final JCalendarPanel dataRelatorio = new JCalendarPanel( null ); private final JRadioButton radioInicial = new JRadioButton( "Inicial" ); private final JRadioButton radioPeriodica = new JRadioButton( "Peri" + oacute + "dica" ); private final JTextField fieldTecnico = new JTextField(); private final JPanel panelAcompanhantes = new JPanel(); private final JTextField fieldNome1 = new JTextField(); private final JTextField fieldNome2 = new JTextField(); private final JTextField fieldFuncao1 = new JTextField(); private final JTextField fieldFuncao2 = new JTextField(); private final LeafIconButton buttonSave = LeafIconButton.createButton( ICON_NAME_SAVE ); private final LeafIconButton buttonRevertText = LeafIconButton.createButton( ICON_NAME_REVERT ); private final LeafIconButton buttonSubmit = LeafIconButton.createButton( "Submeter", ICON_NAME_SUBMIT ); private final LeafIconButton buttonPdfPlano = LeafIconButton.createButton( "Plano de actua" + ccedil + atilde + "o", ICON_NAME_PDF ); private final LeafIconButton buttonPdfRelatorio = LeafIconButton.createButton( "Relat" + oacute + "rio", ICON_NAME_PDF ); private final LeafButton buttonRevertPlano = LeafIconButton.createButton( "Recarregar", ICON_NAME_UNDO ); private final JTabbedPane tabsRelatorio = new JTabbedPane(); private final AdicionarEquipamentosPanel panelEquipamentos = new AdicionarEquipamentosPanel(); private final LeafTextAreaEditor panelFuncionarios = new LeafTextAreaEditor( new Validator() { @Override public boolean isValid( String text ) { return !DEFAULT_FUNCIONARIOS_TEXT.equals( text ); } }); private final JTabbedPane tabsPlanoActuacao = new JTabbedPane(); private final PlanoActuacaoPanel panelPlano = new PlanoActuacaoPanel(); private final RelatorioLegislacaoPanel panelLegislacao = new RelatorioLegislacaoPanel(); private final RelatorioNormalizacaoPanel panelNormalizacao = new RelatorioNormalizacaoPanel(); ButtonGroup bg = new ButtonGroup(); private HsRelatorio relatorio = null; public PanelRelatorio() { setupListeners(); startupComponents(); startupLayout(); placeComponents(); } private void startupComponents() { dataRelatorio.setPreferredSize( new Dimension( 150, 0 ) ); panelEquipamentos.setPreferredSize( new Dimension( 400, 0 ) ); bg.add( radioInicial ); bg.add( radioPeriodica ); panelAcompanhantes.setBorder( BorderFactory.createTitledBorder( "Pessoas que acompanharam" ) ); tabsRelatorio.addTab( "Funcion" + aacute + "rios", panelFuncionarios ); tabsRelatorio.addTab( "Equipamentos de medi"+ccedil+atilde+"o", panelEquipamentos ); tabsPlanoActuacao.addTab( "Plano de actua" + ccedil + atilde + "o", panelPlano ); tabsPlanoActuacao.addTab( "Legisla" + ccedil + atilde + "o", panelLegislacao ); tabsPlanoActuacao.addTab( "Normaliza" + ccedil + atilde + "o", panelNormalizacao ); buttonSave.setToolTipText( "Guardar" ); buttonRevertText.setToolTipText( "Reverter" ); buttonRevertPlano.setToolTipText( "Carregar dados do estabelecimento" ); } private void startupLayout() { TableLayout layout = new TableLayout( new double[] { TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.PREFERRED }, new double[] { TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL } ); layout.setVGap( 5 ); layout.setHGap( 5 ); setLayout( layout ); layout = new TableLayout( new double[] { TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.FILL }, new double[] { TableLayout.MINIMUM, TableLayout.MINIMUM } ); layout.setVGap( 5 ); layout.setHGap( 5 ); panelAcompanhantes.setLayout( layout ); } private void placeComponents() { panelAcompanhantes.add( new JLabel( "Nome" ), new TableLayoutConstraints( 0, 0 ) ); panelAcompanhantes.add( fieldNome1, new TableLayoutConstraints( 1, 0 ) ); panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 0 ) ); panelAcompanhantes.add( fieldFuncao1, new TableLayoutConstraints( 3, 0 ) ); panelAcompanhantes.add( new JLabel( "Nome" ), new TableLayoutConstraints( 0, 1 ) ); panelAcompanhantes.add( fieldNome2, new TableLayoutConstraints( 1, 1 ) ); panelAcompanhantes.add( new JLabel( "Fun" + ccedil + atilde + "o" ), new TableLayoutConstraints( 2, 1 ) ); panelAcompanhantes.add( fieldFuncao2, new TableLayoutConstraints( 3, 1 ) ); TableLayout layout = new TableLayout( new double[] { TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.FILL, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM, TableLayout.MINIMUM }, new double[] { TableLayout.MINIMUM } ); layout.setVGap( 5 ); layout.setHGap( 5 ); JPanel panel = new JPanel(); panel.setLayout( layout ); panel.add( buttonSave, new TableLayoutConstraints( 0, 0 ) ); panel.add( buttonRevertText, new TableLayoutConstraints( 1, 0 ) ); panel.add( buttonPdfRelatorio, new TableLayoutConstraints( 3, 0 ) ); panel.add( buttonPdfPlano, new TableLayoutConstraints( 4, 0 ) ); panel.add( buttonRevertPlano, new TableLayoutConstraints( 5, 0 ) ); panel.add( buttonSubmit, new TableLayoutConstraints( 6, 0 ) ); add( panel, new TableLayoutConstraints( 0, 0, 7, 0 ) ); add( new JLabel( "Data do relat" + oacute + "rio" ), new TableLayoutConstraints( 0, 1, 2, 1 ) ); add( dataRelatorio, new TableLayoutConstraints( 3, 1 ) ); JLabel labelAvaliacao = new JLabel( "Avalia" + ccedil + atilde + "o" ); labelAvaliacao.setHorizontalAlignment( JLabel.RIGHT ); add( labelAvaliacao , new TableLayoutConstraints( 4, 1 ) ); add( radioInicial, new TableLayoutConstraints( 5, 1 ) ); add( radioPeriodica, new TableLayoutConstraints( 6, 1 ) ); add( new JLabel( "T" + eacute + "cnico Superior de H.S." ), new TableLayoutConstraints( 0, 2, 2, 2 ) ); add( fieldTecnico, new TableLayoutConstraints( 3, 2, 6, 2 ) ); add( tabsRelatorio, new TableLayoutConstraints( 7, 1, 7, 3 ) ); add( panelAcompanhantes, new TableLayoutConstraints( 0, 3, 6, 3 ) ); add( tabsPlanoActuacao, new TableLayoutConstraints( 0, 4, 7, 4 ) ); } private void setupListeners() { fieldFuncao1.addCaretListener( this ); fieldFuncao2.addCaretListener( this ); fieldNome1.addCaretListener( this ); fieldNome2.addCaretListener( this ); dataRelatorio.addChangeListener( this ); radioInicial.addActionListener( this ); radioPeriodica.addActionListener( this ); buttonSave.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { save(); } } ); buttonRevertText.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { revert(); } } ); buttonSubmit.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { if( isValidEmail() || JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog(null, "Emails n" + atilde + "o preenchidos para este estabelecimento!\nContinuar?", "Aviso", JOptionPane.YES_NO_OPTION ) ) { if( isValidPlano() && confirmSubmit() ) { submit(); } } } } ); buttonPdfPlano.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { pdf(true); } } ); buttonPdfRelatorio.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { pdf(false); } } ); buttonRevertPlano.addActionListener( new ActionListener() { @Override public void actionPerformed( ActionEvent e ) { revert(true); } } ); panelFuncionarios.addPropertyChangeListener( LeafTextAreaEditor.ACTION_SAVE, new PropertyChangeListener() { @Override public void propertyChange( PropertyChangeEvent evt ) { try { String text = (String) evt.getNewValue(); if( text != null && relatorio != null ) { text = text.trim(); if( text.length() == 0 ) { text = null; } else if( text.equals( DEFAULT_FUNCIONARIOS_TEXT ) ) { text = null; } } relatorio.setFuncionarios( text ); relatorio.save(); } catch( Exception e ) { LeafDialog.error( e ); } } } ); } protected void revert( boolean ask ) { if( relatorio != null ) { try { setCursor( new Cursor( Cursor.WAIT_CURSOR ) ); int ret = ask == false ? JOptionPane.YES_OPTION : JOptionPane.showConfirmDialog( this, "Todas as altera" + ccedil + otilde + "es ao plano de actua" + ccedil + atilde + "o ser" + atilde + "o perdidas\nTem a certeza?","Carregar dados do estabelecimento",JOptionPane.YES_NO_OPTION); if( JOptionPane.YES_OPTION == ret ) { HigieneSegurancaLogic.reverterRelatorio(relatorio); if( relatorio != null ) { try { relatorio.save(); } catch( Exception e ) { e.printStackTrace(); } } setRelatorio( relatorio, false ); } } finally { setCursor( new Cursor( Cursor.DEFAULT_CURSOR ) ); } } } private boolean isValidEmail() { boolean result = false; List emails = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getHsEmailEstabelecimento(); result = emails != null && emails.size() > 0; return result; } private boolean isValidPlano() { boolean result = false; result = panelPlano.isValidPlano(); if( !result ) { JOptionPane.showMessageDialog( null, "Todos os riscos devem ser preenchidos antes da submiss"+ atilde + "o do plano de actua" + ccedil + atilde+ "o!", "Erro", JOptionPane.ERROR_MESSAGE, null ); } return result; } private boolean confirmSubmit() { return JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog( null, "Ao submeter o Plano de Actua"+ccedil+atilde+"o n"+atilde+"o ser"+aacute+" mais poss"+iacute+"vel alter"+aacute+"-lo. Deseja continuar?" ); } private void submit() { try { setCursor(new Cursor(Cursor.WAIT_CURSOR)); if( relatorio != null ) { if( sendMail( relatorio ) ) { refresh(); relatorio.setIsSubmetido( new Date() ); relatorio.save(); setRelatorio( relatorio, false ); } } } catch( Exception e ) { LeafDialog.error(e); refresh(); } finally { setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } } private boolean confirmDelete( File file ) { boolean result = false; result = JOptionPane.OK_OPTION == JOptionPane.showConfirmDialog( this, "Ficheiro j" + aacute + " existente, deseja substituir?", "Aviso", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null ); return result; } private void pdf(boolean plano) { try { setCursor( new Cursor(Cursor.WAIT_CURSOR) ); byte [] pdf = null; if( plano ) { PlanoActuacaoPDFCreator creator = new PlanoActuacaoPDFCreator(); pdf = creator.createPDF( relatorio.getId(), false ); } else { RelatorioPDFCreator creator = new RelatorioPDFCreator(); pdf = creator.createPDF( relatorio.getId() ); } printToFile( pdf ); } catch( Exception e ) { LeafDialog.error( e ); } finally { setCursor( new Cursor(Cursor.DEFAULT_CURSOR) ); } } private void printToFile( byte [] pdf ) throws IOException { if( pdf != null ) { JFileChooser fileChooser = new JFileChooser( ); if( fileChooser.showSaveDialog( this ) == JFileChooser.APPROVE_OPTION ) { File file = fileChooser.getSelectedFile(); String path = file.getAbsolutePath(); if( !path.toUpperCase().endsWith( ".PDF" ) ) { path += ".pdf"; file = new File( path ); } if( file != null ) { if( file.exists() && confirmDelete( file ) ) { file.delete(); } FileOutputStream a = new FileOutputStream(file); a.write( pdf ); a.close(); } } } } private JFrame getFrame( ) { Component comp = this; JFrame frame = null; while( comp != null ) { if( comp.getParent() instanceof RelatorioHigieneSegurancaWindow ) { frame = (RelatorioHigieneSegurancaWindow) comp.getParent(); break; } comp = comp.getParent(); } return frame; } private boolean sendMail( HsRelatorio relatorio ) throws Exception { boolean result = false; List rels = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getHsEmailEstabelecimento(); String to = ""; String bcc = ""; for( HsEmailEstabelecimento rel : rels ) { if( to.isEmpty() ) { to += rel.getToHsEmail().getEmail(); } else { bcc += rel.getToHsEmail().getEmail() + ", "; } } if(bcc.endsWith( ", " )) { bcc = bcc.substring( 0, bcc.length() - 2 ); } if( to.length() > 0 ) { String nomeEstabelecimento = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getNome(); MarcacoesTecnicosHst tecnico = relatorio.getToHsMarcacoesEstabelecimento().getToMarcacoesTecnicosHst(); String nomeTecnico = tecnico == null ? "" : tecnico.getNome(); Date dataVisita = relatorio.getToHsMarcacoesEstabelecimento().getData(); String dataVisitaString = new SimpleDateFormat("dd/MM/yyyy").format( dataVisita ); String subject = "Relatório da Avaliação de Riscos Laborais e Plano de Actuação de " + nomeEstabelecimento + " - auditoria de " + dataVisitaString; String body = "

Exmos. Senhores" + "
" + "
" + "
" + "Junto enviamos o relatório de avaliação de riscos laborais e " + "respectivo plano de actuação da auditoria realizada no dia " + dataVisitaString + " ao vosso estabelecimento de(o) " + nomeEstabelecimento + ". Aconselhamos que tenham em conta as não conformidades indicadas " + "nestes documentos e que preencham o plano de actuação por forma a " + "auxiliar-vos na planificação das medidas correctivas e para poderem " + "apresentá-los em caso de inspecção da ACT – Autoridade para as Condições do Trabalho." + "
" + "
" + "
" + "Caso pretendam o nosso apoio ou necessitem de qualquer esclarecimento, contactem-nos, por favor, através do telefone (+351) 213 504 540." + "
" + "
" + "
" + "Com os melhores cumprimentos, " + "
" + "
" + "
" + nomeTecnico + "
" + "SIPRP - Sociedade Ibérica de Prevenção de Riscos Profissionais " + "
" + "Atrium Saldanha - Praça Duque de Saldanha, 1 - 9º G - 1050-094 Lisboa " + "
" + "Telefone: (+351) 213 504 540 " + "
" + "Fax: (+351) 213 504 549 " + "
" + "E-mail: geral@siprp.pt " + "
" + "URL: www.siprp.com " + "
" + "
" + "
" + "Esta é uma mensagem gerada automaticamente pelo nosso sistema, por favor não responda.

"; MailDialog md = new MailDialog( getFrame(), to, bcc, subject, body, getRelatoriosTemp(relatorio) ); result = md.wasSent(); } return result; } private String getShortNameForEstabelecimento( Estabelecimentos estabelecimento ) { String result = null; String nome = estabelecimento.getNomePlain(); if( nome != null ) { result = nome.trim(); if( result.length() > MAX_NOME_ESTABELECIMENTO_ON_FILENAME ) { String [] tokens = result.split( " " ); if( tokens != null && tokens.length > 2 ) { result = ""; for ( String token : tokens ) { result += token == null ? "" : token; } } } } return result; } private Vector getRelatoriosTemp(HsRelatorio relatorio) throws Exception { Vector result = new Vector(); byte[] relatorioPDF = new RelatorioPDFCreator().createPDF( relatorio.getId() ); byte[] planoPDF = new PlanoActuacaoPDFCreator().createPDF( relatorio.getId(), false ); if( relatorioPDF != null ) { String data = relatorio.getToHsMarcacoesEstabelecimento().getDataRelatorio() == null ? "" : HsRelatorio.DATE_FORMAT.format( relatorio.getData() ); String estabelecimento = getShortNameForEstabelecimento(relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos()); File relat = File.createTempFile("Relatorio - " + estabelecimento + " - " + data, ".pdf"); if( relat != null ) { FileOutputStream fos = new FileOutputStream(relat); fos.write(relatorioPDF); fos.close(); result.add( relat ); } } if( planoPDF != null ) { String data = relatorio.getToHsMarcacoesEstabelecimento().getDataRelatorio() == null ? "" : HsRelatorio.DATE_FORMAT.format( relatorio.getData() ); String estabelecimento = relatorio.getToHsMarcacoesEstabelecimento().getToEstabelecimentos().getNomePlain(); File plan = File.createTempFile("Plano de actuacao - " + estabelecimento + " - " + data, ".pdf"); if( plan != null ) { FileOutputStream fos = new FileOutputStream(plan); fos.write(planoPDF); fos.close(); result.add( plan ); } } return result; } private void save() { try { if( relatorio != null ) { relatorio.setData( dataRelatorio.getDate() ); relatorio.setAvaliacaoInicial( radioInicial.isSelected() ); } relatorio.setAcompanhante1( fieldNome1.getText() ); relatorio.setAcompanhante2( fieldNome2.getText() ); relatorio.setFuncaoAcompanhante1(fieldFuncao1.getText()); relatorio.setFuncaoAcompanhante2(fieldFuncao2.getText()); relatorio.save(); refresh(); buttonRevertText.setEnabled( false ); buttonSave.setEnabled( false ); } catch( Exception e ) { LeafDialog.error(e); } } private void revert() { refresh(); buttonRevertText.setEnabled( false ); buttonSave.setEnabled( false ); } private void refresh() { dataRelatorio.setDate( relatorio == null ? null : relatorio.getData() ); if( relatorio == null || relatorio.getAvaliacaoInicial() == null ) { bg.clearSelection(); } else { radioInicial.setSelected( relatorio.getAvaliacaoInicial() ); radioPeriodica.setSelected( !relatorio.getAvaliacaoInicial() ); } String tecnicoName = null; if(relatorio != null) { MarcacoesEstabelecimento marcacao = relatorio.getToHsMarcacoesEstabelecimento(); if( marcacao != null ) { MarcacoesTecnicosHst tecnico = marcacao.getToMarcacoesTecnicosHst(); if( tecnico != null ) { tecnicoName = tecnico.getNome(); } } } fieldTecnico.setText( tecnicoName ); fieldNome1.setText( relatorio == null ? null : relatorio.getAcompanhante1() ); fieldNome2.setText( relatorio == null ? null : relatorio.getAcompanhante2() ); fieldFuncao1.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante1() ); fieldFuncao2.setText( relatorio == null ? null : relatorio.getFuncaoAcompanhante2() ); } private void setEnabled() { boolean enabled = relatorio != null && relatorio.getIsSubmetido() == null; dataRelatorio.setEnabled( enabled ); radioInicial.setEnabled( enabled );; radioPeriodica.setEnabled( enabled ); fieldTecnico.setEnabled( false ); fieldNome1.setEnabled( enabled ); fieldNome2.setEnabled( enabled ); fieldFuncao1.setEnabled( enabled ); fieldFuncao2.setEnabled( enabled ); buttonSubmit.setEnabled( enabled ); buttonPdfPlano.setEnabled( relatorio != null ); buttonPdfRelatorio.setEnabled( relatorio != null ); buttonRevertPlano.setEnabled( enabled ); panelFuncionarios.setEnabled( enabled ); } public void setRelatorio( HsRelatorio relatorio,boolean create ) { this.relatorio = relatorio; buttonSave.setEnabled( false ); buttonRevertText.setEnabled( false ); panelEquipamentos.setRelatorio( relatorio ); panelPlano.setRelatorio( relatorio ); panelLegislacao.setRelatorio( relatorio ); panelNormalizacao.setRelatorio( relatorio ); panelFuncionarios.setValue( relatorio == null ? null : ( relatorio.getFuncionarios() == null ? DEFAULT_FUNCIONARIOS_TEXT : relatorio.getFuncionarios() ) ); if( create ) { this.revert(false); } refresh(); setEnabled(); } private void updated( EventObject e ) { Object source = e.getSource(); if( source instanceof Component ) { if( ( (Component) source).isEnabled() ) { buttonSave.setEnabled( true ); buttonRevertText.setEnabled( true ); } } } @Override public void caretUpdate( CaretEvent e ) { updated(e); } @Override public void stateChanged( ChangeEvent e ) { updated(e); } @Override public void actionPerformed( ActionEvent e ) { updated(e); } }