Re: update doesnt´t work ?
From: gzell (gzell_at_gmx.de)
Date: 09/19/04
- Next message: Andrew Thompson: "Re: Displaying PDF files using servlets"
- Previous message: matthew parker: "Re: > > > > matt parker registers domains with the name of his clients to impersonate them matt parker alias ericvonlindt matt parker alias smachines matt parker makes false accusations to make others seem guilty of his criminal activities matt parke"
- In reply to: Babu Kalakrishnan: "Re: update doesnt´t work ?"
- Next in thread: gzell: "Re: update doesnt´t work ?"
- Reply: gzell: "Re: update doesnt´t work ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 19 Sep 2004 04:52:04 -0700
hmm, did some changes as suggestet but still missing
my further lines ...
//----------------------- class Frame04 ---------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Frame04 extends JFrame{
Parabeln myC = new Parabeln();
JMenuBar menubar = new JMenuBar();
ActionListener myListener;
JTextField txt01= new JTextField("Please use Option:
'Gerade-Parabel'");
public Frame04(){
getContentPane().setLayout(null);
myC.setBounds(10,10,400,400);
txt01.setBounds(450,10,250,30);
getContentPane().add(myC);
getContentPane().add(txt01);
myListener=new ActionListener(){
public void actionPerformed(ActionEvent e) {
JMenuItem source = (JMenuItem)(e.getSource());
if(source.getText().equals("Gerade-Parabel")){
afg01();
}
if(source.getText().equals("Clear")){
Point myPoint = new Point(200,200);
myC.mpKsystem(myPoint);
}
}};
menubar.add(createFileMenu());
setJMenuBar(menubar);
// getContentPane().add(menubar);
Point myPoint = new Point(200,200);
myC.mpKsystem(myPoint);
}
private void afg01(){
Point p1 = new Point(-10,+5);
Point p2 = new Point(10,-7);
myC.zeichneLinie(p1,p2); //first Line
p1.x=-10; p1.y=0; p2.x=10; p2.y=7;
myC.zeichneLinie(p1,p2); // second Line
p1.x=-50; p1.y=4; p2.x=10; p2.y=-7;
myC.zeichneLinie(p1,p2); //third Line
p1 = new Point(-8,-3);
p2 = new Point(10,3);
myC.zeichneLinie(p1,p2); // fourth Line
p1 = new Point(-3,2);
myC.zeichneParabel(p1);
}
private JMenu createFileMenu()
{
JMenu ret = new JMenu("Aufgaben");
ret.setMnemonic('D');
JMenuItem mi;
mi = new JMenuItem("Gerade-Parabel", 'p');
setCtrlAccelerator(mi, 'P');
mi.addActionListener(myListener);
ret.add(mi);
mi = new JMenuItem("Clear", 'c');
setCtrlAccelerator(mi, 'C');
mi.addActionListener(myListener);
ret.add(mi);
//Separator
ret.addSeparator();
mi = new JMenuItem("Beenden", 'e');
mi.addActionListener(myListener);
ret.add(mi);
return ret;
}
private void setCtrlAccelerator(JMenuItem mi, char acc)
{
KeyStroke ks = KeyStroke.getKeyStroke(
acc, Event.CTRL_MASK
);
mi.setAccelerator(ks);
}
public static void main(String[] args){
Frame04 myF = new Frame04();
myF.setSize(800,500);
myF.setVisible(true);
}
}
//-------------------------- class Parabeln ---------------------
import java.awt.*;
import javax.swing.*;
import java.util.*;
public class Parabeln extends JPanel{
boolean ksystem=false;
boolean bGeradezeichnen = false;
boolean bParabelzeichnen = false;
boolean zeichne = false;
Image offScreenImage;
Graphics offScreenGraphics;
int mpx, mpy;
int xS,yS;
Color f;
Point pkt1 = new Point(0,0);
Point pkt2 = new Point(0,0);
ArrayList aLines = new ArrayList();
public void paintComponent(Graphics g){
if(offScreenImage==null){
offScreenImage =
createImage(this.getSize().width,this.getSize().height);
offScreenGraphics = offScreenImage.getGraphics();
}
if (ksystem) {
offScreenGraphics.setColor(new Color(150,150,150));
offScreenGraphics.fillRect(0,0,this.getSize().width,
this.getSize().height );
koordinatensystem(offScreenGraphics);
ksystem=false;
}
if (bGeradezeichnen) {
addLine(offScreenGraphics);
bGeradezeichnen=false;
}
if (bParabelzeichnen) {
myParabel(offScreenGraphics);
bParabelzeichnen=false;
}
g.drawImage(offScreenImage,0,0,this);
}
public void mpKsystem(Point p){
mpx=p.x; mpy=p.y;
ksystem=true;
repaint();
}
private void ksystemgrid(Graphics h){
Color grid = new Color(199,199,199);
h.setColor(grid);
for(int i=1;i<20;i++) h.drawLine(20*i,0,20*i,400);
for(int i=1;i<20;i++) h.drawLine(0,20*i,400,20*i);
}
private void koordinatensystem(Graphics h){
ksystemgrid(h);
h.setColor(Color.black);
h.drawLine(0,mpy,400,mpy);
h.drawLine(mpx,0,mpx,400);
}
private void addLine(Graphics h){
int k=0;
h.setColor(new Color(255,0,0));
while(k<aLines.size()){
pkt1=(Point)aLines.get(k); // 01 23 45 67
pkt2=(Point)aLines.get(k+1);
h.drawLine(pkt1.x+10,pkt1.y+10,pkt2.x+10,pkt2.y+10);
k=k+2;
}
}
private void myParabel(Graphics h){
int i = 0;
double x[] = new double[80];
double y[] = new double[80];
int px[] = new int[60];
int py[] = new int[60];
while(i<60){
// Punktepaare ermitteln
x[i]=(xS-3)+0.1*i;
y[i]= (x[i]-xS)*(x[i]-xS)+yS;
//in Bildschirmkoordinaten umrechnen
x[i]=(x[i]+10)*20;
if (y[i]>0) y[i]=(10-y[i])*20;
else y[i]=(y[i]*(-1)+10)*20;
// in Integerwerte umwandeln
px[i] = (int)x[i];
py[i] = (int)y[i];
i++;
}
h.setColor(new Color(0,0,255));
h.drawPolyline(px,py,60);
repaint();
}
public void zeichneLinie(Point p1, Point p2){
//umrechnen der Punkte in Bildschirmkoordinaten
pkt1.x=(p1.x+10)*20;
if (p1.y>0) pkt1.y=(10-p1.y)*20;
else pkt1.y=(p1.y*(-1)+10)*20;
pkt2.x=(p2.x+10)*20;
if (p2.y>0) pkt2.y=(10-p2.y)*20;
else pkt2.y=(p2.y*(-1)+10)*20;
aLines.add(pkt1);
aLines.add(pkt2);
bGeradezeichnen=true;
}
public void zeichneParabel(Point p1){
xS=p1.x; yS=p1.y;
bParabelzeichnen=true;
}
}
- Next message: Andrew Thompson: "Re: Displaying PDF files using servlets"
- Previous message: matthew parker: "Re: > > > > matt parker registers domains with the name of his clients to impersonate them matt parker alias ericvonlindt matt parker alias smachines matt parker makes false accusations to make others seem guilty of his criminal activities matt parke"
- In reply to: Babu Kalakrishnan: "Re: update doesnt´t work ?"
- Next in thread: gzell: "Re: update doesnt´t work ?"
- Reply: gzell: "Re: update doesnt´t work ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|