Jump to content

double click numa linha de uma JTable + refresh


Recommended Posts

Posted

boas,

tenho uma JTable que lista as mensagens de um user.

precivasa k ao fazer double click numa linha de uma JTable, que abri-se uma JDialog com a mensagem.

tb precisava de fazer um refresh à JHTable de x em x segundos.

alguem ajuda?

segue o metodo que cria a JTable:

	private JPanel caixaEntrada() {
	java.text.SimpleDateFormat dtfGeral = new java.text.SimpleDateFormat("HH:mm dd-MM-yyyy");

	JPanel caixaEntrada = new JPanel(new FlowLayout());

	table1 = new JTable();
	table1.setShowGrid(false);
	table1.setSelectionBackground(new Color(0,0,255));
	table1.setAutoscrolls(true);

	Object[][] mensagens = new Object[user.getCaixaEntrada().size()][4];
	for(int i = 0; i<user.getCaixaEntrada().size(); i++) {
		mensagens[i][0] = user.getCaixaEntrada().get(i).getTo();
		mensagens[i][1] = user.getCaixaEntrada().get(i).getSubject();
		mensagens[i][2] = user.getCaixaEntrada().get(i).getMessage();
		mensagens[i][3] = dtfGeral.format(user.getCaixaEntrada().get(i).getDate());
	}

	table1.setModel(new DefaultTableModel(mensagens,
		 new String [] { "De", "Assunto", "Mensagem", "Data"}){
			 boolean[] canEdit = new boolean []{
				 false, false, false, false
			 };
			 @Override
			 public boolean isCellEditable(int rowIndex, int columnIndex) {
				 return canEdit [columnIndex];
			 }
	});

	//Create the scroll pane and add the table to it.
	JScrollPane scrollPane = new JScrollPane(table1);

	caixaEntrada.add(scrollPane);

	return caixaEntrada;
}

Serviços de WebDesignwww.miguelborges.com

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.