forked from Coded/SIPRP
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
1.7 KiB
90 lines
1.7 KiB
/*
|
|
* EtiquetaChooserPanel.java
|
|
*
|
|
* Created on 27 de Fevereiro de 2006, 11:21
|
|
*
|
|
* To change this template, choose Tools | Template Manager
|
|
* and open the template in the editor.
|
|
*/
|
|
|
|
package siprp.clientes;
|
|
|
|
import java.awt.*;
|
|
import java.awt.event.*;
|
|
import javax.swing.*;
|
|
import java.util.*;
|
|
|
|
import com.evolute.utils.ui.*;
|
|
|
|
/**
|
|
*
|
|
* @author Frederico
|
|
*/
|
|
public class EtiquetaChooserDialog extends CustomJDialog
|
|
implements ActionListener
|
|
{
|
|
private int rows;
|
|
private int cols;
|
|
private final Hashtable<JButton,int[]> positionHash = new Hashtable<JButton,int[]>();
|
|
|
|
private int choice[];
|
|
|
|
/** Creates a new instance of EtiquetaChooserPanel */
|
|
public EtiquetaChooserDialog( JFrame owner, int rows, int cols )
|
|
{
|
|
super( owner, true );
|
|
this.rows = rows;
|
|
this.cols = cols;
|
|
setupComponents();
|
|
if( owner != null )
|
|
{
|
|
centerSuper();
|
|
}
|
|
else
|
|
{
|
|
center();
|
|
}
|
|
}
|
|
|
|
private void setupComponents()
|
|
{
|
|
setTitle( "Escolha a posi\u00e7\u00e3o" );
|
|
setSize( cols * 200, rows * 50 );
|
|
setLayout( new GridLayout( rows, cols ) );
|
|
for( int r = 0; r < rows; r++ )
|
|
{
|
|
for( int c = 0; c < cols; c++ )
|
|
{
|
|
JButton button = new JButton( "( " + ( r + 1 ) + " , " + ( c + 1 ) + " )" );
|
|
add( button );
|
|
positionHash.put( button, new int[]{ r, c } );
|
|
button.addActionListener( this );
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void close()
|
|
{
|
|
SwingUtilities.invokeLater( new Runnable(){
|
|
public void run()
|
|
{
|
|
setVisible( false );
|
|
dispose();
|
|
}
|
|
} );
|
|
}
|
|
|
|
public int[] choose()
|
|
{
|
|
setVisible( true );
|
|
return choice;
|
|
}
|
|
|
|
public void actionPerformed( ActionEvent e )
|
|
{
|
|
Object source = e.getSource();
|
|
choice = positionHash.get( ( JButton ) source );
|
|
close();
|
|
}
|
|
}
|