Mijn classpath verwijst naar de dir waar de nl.hen.ict packages staan die ik overal importeer.quote:Op dinsdag 28 februari 2006 23:38 schreef gelly het volgende:
En je ClassPath verwijst ook naar de dir waar de classes staan ?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | A basic extension of the java.applet.Applet class */ import java.awt.*; import java.applet.*; public class Applet1 extends Applet { public void init() { // Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller symantec.itools.lang.Context.setApplet(this); // This code is automatically generated by Visual Cafe when you add // components to the visual environment. It instantiates and initializes // the components. To modify the code, only use code syntax that matches // what Visual Cafe can generate, or Visual Cafe may be unable to back // parse your Java file into its visual environment. //{{INIT_CONTROLS setLayout(null); setBackground(java.awt.Color.lightGray); setSize(426,266); add(decimaalGetalVeld); decimaalGetalVeld.setBounds(228,48,132,42); add(binairGetalVeld); binairGetalVeld.setBounds(228,120,132,42); ConversieButton.setLabel("Decimaal -> Binair"); add(ConversieButton); ConversieButton.setBackground(java.awt.Color.lightGray); ConversieButton.setBounds(36,192,168,49); label1.setText("Decimaal Getal"); add(label1); label1.setFont(new Font("Dialog", Font.PLAIN, 20)); label1.setBounds(24,48,161,34); label2.setText("Binair Getal : "); add(label2); label2.setFont(new Font("Dialog", Font.PLAIN, 20)); label2.setBounds(24,120,161,34); BinDecButton.setLabel("Binair -> Decimaal"); add(BinDecButton); BinDecButton.setBackground(java.awt.Color.lightGray); BinDecButton.setBounds(228,192,168,49); //}} //{{REGISTER_LISTENERS SymAction lSymAction = new SymAction(); ConversieButton.addActionListener(lSymAction); BinDecButton.addActionListener(lSymAction); //}} } //{{DECLARE_CONTROLS java.awt.TextField decimaalGetalVeld = new java.awt.TextField(); java.awt.TextField binairGetalVeld = new java.awt.TextField(); java.awt.Button ConversieButton = new java.awt.Button(); java.awt.Label label1 = new java.awt.Label(); java.awt.Label label2 = new java.awt.Label(); java.awt.Button BinDecButton = new java.awt.Button(); //}} class SymAction implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent event) { Object object = event.getSource(); if (object == ConversieButton) ConversieButton_ActionPerformed(event); else if (object == BinDecButton) BinDecButton_ActionPerformed(event); } } void ConversieButton_ActionPerformed(java.awt.event.ActionEvent event) { int decGetal = Integer.parseInt(decimaalGetalVeld.getText()); String resultaat = "" ; do { if (decGetal % 2==0) resultaat = "0" + resultaat; else { resultaat = "1" + resultaat; decGetal --; } decGetal = decGetal / 2; } while (decGetal >0); binairGetalVeld.setText(resultaat); // Eerst zet hij de int van het gehele decimale getal om in een tekstvorm door middel // van parseInt. Die haalt hij uit het DecimaalGetalVeld. // vervolgens kijkt hij of het resultaat wat je krijgt te delen is door 2 waarna je // een rest getal van 0 krijgt. Is dit zo dan geeft hij het resultaat in het BinairGetalVeld. // Anders doet hij daar nog 1 bij op om hem wel te kunnen converteren in een WEL geheel // binair getal. Dit resultaat komt uiteraard in het het binairGetalVeld. } void BinDecButton_ActionPerformed(java.awt.event.ActionEvent event) { // to do: code goes here. } } |
Gewoon, optellen. Zoiets als hieronder dus.quote:Op woensdag 15 maart 2006 20:11 schreef Messenga het volgende:
Nou, ik kom me ook weer eens melden. Feest
.
Met de volgende code heb ik een leuke code die van Decimaal naar binair gaat.
[ code verwijderd ]
Die werkt ook.
Maar nu moet ik dat andersom doen. Dus van Binair naar Decimaal. Maar ik heb geen idee hoe.
Instructies: Maak gebruik van de String 'lenght(); ' en substring (int,int).
Anyone?
| 1 2 3 4 5 6 7 8 9 10 11 | long decimaal = 0; for ( int i=0; i < bin.length(); i++ ) { if ( bin.substring( i, i+1 ).equals("1") ) { decimaal += Math.round( Math.pow( 2, i ) ); } } return decimaal; } |
Ik zie hier een nobele taak voor jequote:Op woensdag 15 maart 2006 20:46 schreef Messenga het volgende:
Ohja. Was vergeten te zeggen dat het in Actionpeformed moet. Of maakt dat niet uit?
Duh. Natuurlijk vergeet ik dat welquote:Op woensdag 15 maart 2006 20:50 schreef HuHu het volgende:
Vergeet je niet de String om te draaien voordat je het uitrekend Litpho?
Ja goh, maar hoe ziet de code er ongeveer uitquote:Op maandag 10 april 2006 16:42 schreef gelly het volgende:
Door een eventhandler aan je radiobuttongroup te hangen he
Daar zijn meerdere manieren voor...quote:Op maandag 10 april 2006 16:44 schreef Messenga het volgende:
[..]
Ja goh, maar hoe ziet de code er ongeveer uit?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | { public void stateChanged(ChangeEvent e) { mijnRadioButton_stateChanged(e) } }); En dan ergens anders in je applet een methode private void mijnRadioButton_stateChanged(ChangeEvent e) { \\hier de code die de kleur moet veranderen.. } |
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | double px1 = x1 * perspective(z1), px2 = x2 * perspective(z2), py1 = y1 * perspective(z1), py2 = y2 * perspective(z2); int ipx1 = (int)px1; int ipx2 = (int)px2; int ipy1 = (int)py1; int ipy2 = (int)py2; g.drawLine(ipx1,ipy1,ipx2,ipy2); } double perspective(int z) { double p = (double)s/((double)s-(double)z); return p; } |
Wat houdt dit dan in? of heb je misschien een linkje naar een artikel over dit onderwerp?quote:Op dinsdag 11 april 2006 10:35 schreef dikkedorus het volgende:
Werk met transformatie matrices ipv zelf al die vermenigvuldigingen te doen. Als je echt serieus een engine wilt maken.
| Forum Opties | |
|---|---|
| Forumhop: | |
| Hop naar: | |