ayuda con graficador!!!
a ver , el prble ma radica que necesito graficar de acurdo con unvalorqu recivo, pero nose pede, porque el objeto grafics no es instanciable, necesito saber de que manera puedo hacerlo, aqui les dejo el codigo del problemita, espero que me qyude, gracias.
package dataSource1;
import javax.swing.JDialog;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JPanel;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class pruebagraph extends JDialog implements ActionListener{
int v[]=new int[2];
JPanel panel;
JComboBox x;
Graphics w;
JButton but;
boolean xw;
public pruebagraph(){
v[0]=10;
v[1]=0;
setTitle("Prueba Graficador Rendimiento");
setContentPane(panel());
}
public void paint(final Graphics gr){
super.paint(gr);
gr.setColor(Color.black);
gr.drawLine(0,250,400,250);
gr.drawLine(10,0,10,400);
}
private JPanel panel(){
panel=new JPanel();
panel.setLayout(null);
panel.setBackground(Color.white);
textFields();
botones();
anade();
return panel;
}
private void textFields(){
String[] xsel=new String[2];
xsel[0]="Positivo";
xsel[1]="Negativo";
x=new JComboBox(xsel);
x.setBounds(50,10,100,20);
}
private void botones(){
but=new JButton("ok");
but.setBounds(160,10,80,20);
but.addActionListener(this);
}
private void anade(){
panel.add(x);
panel.add(but);
}
public static void main(String[] args) {
pruebagraph y=new pruebagraph();
y.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
y.pack();
y.setBounds(200,100,400,400);
y.setVisible(true);
}
public void paint(Graphics gr,boolean xw){
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==but){
if (x.getSelectedIndex()==0){
xw=true;
}
if (x.getSelectedIndex()==1){
xw=false;
}
}
}
package dataSource1;
import javax.swing.JDialog;
import java.awt.Graphics;
import java.awt.Color;
import javax.swing.JPanel;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
public class pruebagraph extends JDialog implements ActionListener{
int v[]=new int[2];
JPanel panel;
JComboBox x;
Graphics w;
JButton but;
boolean xw;
public pruebagraph(){
v[0]=10;
v[1]=0;
setTitle("Prueba Graficador Rendimiento");
setContentPane(panel());
}
public void paint(final Graphics gr){
super.paint(gr);
gr.setColor(Color.black);
gr.drawLine(0,250,400,250);
gr.drawLine(10,0,10,400);
}
private JPanel panel(){
panel=new JPanel();
panel.setLayout(null);
panel.setBackground(Color.white);
textFields();
botones();
anade();
return panel;
}
private void textFields(){
String[] xsel=new String[2];
xsel[0]="Positivo";
xsel[1]="Negativo";
x=new JComboBox(xsel);
x.setBounds(50,10,100,20);
}
private void botones(){
but=new JButton("ok");
but.setBounds(160,10,80,20);
but.addActionListener(this);
}
private void anade(){
panel.add(x);
panel.add(but);
}
public static void main(String[] args) {
pruebagraph y=new pruebagraph();
y.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
y.pack();
y.setBounds(200,100,400,400);
y.setVisible(true);
}
public void paint(Graphics gr,boolean xw){
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==but){
if (x.getSelectedIndex()==0){
xw=true;
}
if (x.getSelectedIndex()==1){
xw=false;
}
}
}