/ Forside / Teknologi / Udvikling / Java / Nyhedsindlæg
Login
Glemt dit kodeord?
Brugernavn

Kodeord


Reklame
Top 10 brugere
Java
#NavnPoint
molokyle 3688
Klaudi 855
strarup 740
Forvirret 660
gøgeungen 500
Teil 373
Stouenberg 360
vnc 360
pmbruun 341
10  mccracken 320
Indsæt grafik i et TabbedPanel
Fra : Guster D


Dato : 17-12-00 11:19

Jeg er ved at lave nogle grafer, de skal sættes ind i et tabbedpanel.
Jeg har 3 tab's panel1, panel2, panel3.

Jeg har en klasse DrawBars som tegner grafen, men det kan jeg kun få den til
hvis jeg laver et helt nyt JFrame. Her er koden for DrawBars:

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.Vector;
import java.awt.Point;

class DrawBars extends JFrame
{
public DrawBars()//Core currentCore, JPanel panel)
{
// this.currentCore=currentCore;
super("Map");
setSize(640,480);

SimPane corePane=new SimPane();
getContentPane().add(corePane);
}
}



/***************************************************************************
**********************************
*This method is used by the GUI monitor Thread to make object of all the
nodes and draw a graph for the load
****************************************************************************
*********************************/


class SimPane extends JPanel
{
private Core currentCore;
private Vector gV = new Vector();
private JPanel panel=new JPanel();
private int pointCal1, pointCal2;
public void paintComponent(Graphics comp)
{
Graphics2D comp2D = (Graphics2D)comp;
comp2D.drawRect(32,22,167,147);

//Convert the currentCore values to that of the graph
// currentCore.getBufferInLoad();
// pointCal1 = 150;
pointCal1 = (int) ((147 - (147 * 0.50)));
// pointCal1 = (147 - (int) (147 * currentCore.getBufferInLoad()));


pointCal2 = (int) ((147 * 0.50));
// pointCal2 = (int) ((147 * currentCore.getBufferInLoad()));
//
Point cul = new Point(pointCal1,pointCal2);
gV.add(cul);
//
//
//
//
int xAkseBar = 35;
// int numberOfBars = 8;


//Draws the graph window
// Graphics2D comp2D = (Graphics2D)comp;
comp2D.drawString("Node" +"1", 90, 15);
comp2D.drawString("0%",0,172);
comp2D.drawString("25%",0,136);
comp2D.drawString("50%",0,100);
comp2D.drawString("75%",0,62);
comp2D.drawString("100%",0,28);

Color brush = new Color(0,0,255);
comp2D.setColor(brush);
setBackground(Color.white);

comp2D.drawRect(32,22,167,147);


comp2D.fillRect(35,(int)((Point)
gV.firstElement() ).getX(),5,(int)((Point) gV.firstElement() ).getY());




 
 
Søg
Reklame
Statistik
Spørgsmål : 177558
Tips : 31968
Nyheder : 719565
Indlæg : 6408929
Brugere : 218888

Månedens bedste
Årets bedste
Sidste års bedste