OK aimgo. Vou tentar esse.
[quote=Carlos Martins]Nao sei se entendi mais olhe este codigo ai talves te ajude;
import javax.swing.;
import java.awt.event.;
import java.awt.*;
class PanelMatriz extends JPanel
{
static final int NODE_WIDTH = 40;
static final int NODE_HEIGHT = 20;
static final int ARC_WIDTH = 10;
static final int ARC_HEIGHT = 10;
protected int[][] matriz;
public PanelMatriz(int[][] matriz)
{
setBackground(Color.white);
setLayout(new GridLayout(1,1));
this.matriz = matriz;
}
public void paint(Graphics g)
{
super.paint(g);
for(int index1=0;index1 < matriz.length;index1++)
{
for(int index2=0;index2 < matriz.length;index2++)
{
drawNode(g,30+(index1*(NODE_WIDTH+7)),30+(index2*(NODE_HEIGHT+7)),
Integer.toString(matriz[index1][index2]));
}
}
}
public void drawNode(Graphics g, int x, int y, String label)
{
g.setColor(new Color(255,255,204));
g.fillRoundRect(x,y,NODE_WIDTH,NODE_HEIGHT,ARC_WIDTH,ARC_HEIGHT);
g.setColor(Color.red);
g.drawRoundRect(x,y,NODE_WIDTH,NODE_HEIGHT,ARC_WIDTH,ARC_HEIGHT);
g.setColor(Color.black);
Font mono = new Font("Monospaced",Font.BOLD,15);
g.setFont(mono);
FontMetrics newFM = g.getFontMetrics(mono);
int xLength = newFM.stringWidth(label);
g.drawString(label,(x+(NODE_WIDTH/2)-(xLength/2)),y+14);
}
}
public class Janela2 extends JFrame implements ActionListener
{
private JButton bntSair,bntExecuta;
public Janela2()
{
super(“MinhaJanela”);
setSize(500,400);
Container c = getContentPane();
c.setLayout(new BorderLayout());
bntSair = new JButton(“Sair”);
bntExecuta = new JButton(“Executa”);
bntSair.addActionListener(this);
bntExecuta.addActionListener(this);
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(1,3,5,5));
panel.add(bntSair);
panel.add(new JLabel());
panel.add(bntExecuta);
c.add(new JLabel(),BorderLayout.CENTER);
c.add(panel,BorderLayout.SOUTH);
show();
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == bntSair)
{
int escolha = JOptionPane.showConfirmDialog(null,"Deseja SAIR desta aplicaçao","",JOptionPane.YES_NO_OPTION);
if(escolha == JOptionPane.YES_OPTION)
{
dispose();
}
}
if(e.getSource() == bntExecuta)
{
int[][] matriz = MetodoQueCalculaAMultiplicacaoDasMatriz();
PanelMatriz panelMat = new PanelMatriz(matriz);
JFrame frame = new JFrame("Matriz");
frame.setLocation(50,130);
frame.setSize(400,300);
Container c = frame.getContentPane();
c.add(panelMat);
frame.setResizable(false);
frame.show();
}
}
public int[][] MetodoQueCalculaAMultiplicacaoDasMatriz()
{
int[][] matriz = new int[5][5];
for(int index1=0;index1 < matriz.length;index1++)
{
for(int index2=0;index2 < matriz.length;index2++)
{
if(index1 <index2)
matriz[index1][index2] = 0;
else
matriz[index1][index2] = 1;
}
}
return matriz;
}
public static void main()
{
new Janela2();
}
}[/quote]>