есть класс PeerVis
ниже описанны его методы ...
из майна методы работают :
| Код | public class PeerVis { JTextField f1; JTextField f2; JTextField f3;
private static final int PEER_WIDTH = 40; private static final int PEER_HEIGHT = 20; private static final int COEFF = 10; private static final int RADIUS = 300; private static ArrayList<DefaultGraphCell> _cells; private static ArrayList<DefaultGraphCell> _peers; private static ArrayList<DefaultGraphCell> _msgs; private static JGraph _graph; static PeerVis inst=null; @SuppressWarnings("static-access") public static void main(String[] args) { ///New my Button
//
// Construct Model and Graph GraphModel model = new DefaultGraphModel(); _graph = new JGraph(model); // Control-drag should clone selection _graph.setCloneable(false); _graph.setBendable(false); _graph.setSelectionEnabled(false); _graph.setInvokesStopCellEditing(true);
_graph.setJumpToDefaultPort(true);
_cells = new ArrayList<DefaultGraphCell>(); _peers = new ArrayList<DefaultGraphCell>(); PeerVis peerVis = new PeerVis();
// Show in Frame JFrame frame = new JFrame(); frame.getContentPane().add(new JScrollPane(_graph)); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); frame.setSize(1000, 700); inst =new PeerVis(); //peerVis = new PeerVis();
inst.f1 = new JTextField(); inst.f1.setColumns(10); inst.f2 = new JTextField(); inst.f2.setColumns(10); inst.f3 = new JTextField(); inst.f3.setColumns(10); JButton b1 = new JButton("Calculate"); b1.addActionListener(new Handler(inst) );
JPanel frame1 = new JPanel(); frame1.setSize(300,700); frame1.setLocation(700,0); frame1.setBackground(Color.lightGray); frame1.add(inst.f1); frame1.add(inst.f2); frame1.add(b1); frame1.add(inst.f3);
_graph.add(frame1);
frame1.setVisible(true); for (int i = 1; i <= 20; i++) peerVis.addPeer(i); peerVis.connectPeers(2, 10, "msg1"); peerVis.connectPeers(4, 16, "msg1"); peerVis.connectPeers(10, 1, "msg1"); peerVis.deletePeer(8); }
|
если поестить в
| Код | public void soImportantCalculation(int a, int b) { inst.f3.setText("" + (a+b)); peerVis.connectPeers(6, 6, "msg1"); // тут не работет , не может найти символ(метод ) }
|
метод выглядет примерно так
| Код | public void connectPeers(int sourcePeerID, int targetPeerID, String msg) {
........ }
|
если вы меня поняли , подскажите в чём беда ,? |