|
i am searching a java project plz help me
zzzzzzzzzzzzzzzzzz
|
|
|
|
|
...and I want a beer. do you think you can help ?
|
|
|
|
|
Hey folks,
I have a question about writing the koch snowflake in java. When I compile my code I only get the snowflake on one side(so im guessing this is the koch curve instead) and I was wondering how do I get it to all the sides in order to form the snowflake? Here is my code, I know I am missing something but i'm not so sure what. thanks for the help:
import javax.swing.*;
import java.awt.*;
public class drawSnowflake extends JApplet
{
int level=0;
public void init()
{
String levelStr= JOptionPane.showInputDialog("Enter the recursion depth: ");
level = Integer.parseInt(levelStr);
}
public void paint(Graphics g)
{
int pointOne = 60;
int pointTwo = 120;
int pointThree = 160;
int pointFour = 140;
drawKochSide(g, level, pointOne, pointTwo, pointThree, pointFour);
}
private void drawKochSide(Graphics g,int lev, int x1, int y1, int x5, int y5)
{
int deltaX, deltaY, x2, x3, x4, y2,y3, y4;
if (lev<1)
g.drawLine(x1, y1, x5, y5);
else{
deltaX = x5-x1;
deltaY = y5-y1;
x2 = x1 + deltaX / 3;
y2 = y1+ deltaY / 3 ;
x3=(int) ((x1+x5)/2 + Math.sqrt(3.0)*(y1-y5)/6);
y3=(int) ((y1+y5)/2+ Math.sqrt(3.0)* (x5-x1)/6);
x4 = x1 + 2 * deltaX / 3 ;
y4 = y1 + 2 * deltaY / 3 ;
drawKochSide(g, lev-1, x1, y1, x2, y2);
drawKochSide(g, lev-1, x2, y2, x3, y3);
drawKochSide(g, lev-1, x3, y3, x4, y4);
drawKochSide(g, lev-1, x4, y4, x5, y5);
}
}
}
|
|
|
|
|
Hi vultron, I don't know if you really understand your code.
In your code, you clearly defined two points (only two), let's say point A and point B.
Coordinates of point A are given by :
int pointOne = 60;
int pointTwo = 120;
Coordinates of point B are given by :
int pointThree = 160;
int pointFour = 140;
Then you draw one side of the snowflake (the side A-B) by :
drawKochSide(g, level, pointOne, pointTwo, pointThree, pointFour);
What you have to do is to define a third point C and to draw the two other sides (B-C) and (A-C), so there's the final code of the paint method :
public void paint(Graphics g)
{
int pointOne = 50;
int pointTwo = 100;
int pointThree = 150;
int pointFour = 100;
int pointFive = 100;
int pointSix = 14;
drawKochSide(g, level, pointOne, pointTwo, pointThree, pointFour);
drawKochSide(g, level, pointFive, pointSix, pointOne, pointTwo);
drawKochSide(g, level, pointThree, pointFour, pointFive, pointSix);
}
Notice that in this example, the triangle ABC is not exactly equilateral because coordinates are integers.
|
|
|
|
|
Given the following classes, write the delete() method, which will delete all nodes equal() to Node n. delete() should return true if at least one node could be removed, and return false otherwise. Use Java syntax.Don’t use java API.
Public class DS {
public Node getStart() {
/* This method is written for you – it will return the first node */
}
public void setStart(Node n) {
/* This method is written for you – it will set the first node */
}
public boolean delete(Node n) { /* Provide code for this method */ }
class Node {
public boolean equal(Node n) { /* This method is written for you */ }
public Node getNext() {
/* This method is written for you – it will return the next node*/
}
public Node getPrevious() {
/* This method is written for you – it will return the previous node*/
}
public void setNext(Node n) {
/* This method is written for you – it will set the next node*/
}
public void setPrevious(Node n) {
/* This method is written for you – it will set the previous node*/
}
}
}
|
|
|
|
|
Read the posting guidelines.
1. we don't do homeworks here.
2. your code is not even formatted
3. you don't ask specific questions.
|
|
|
|
|
actually i forgot to submit my code here.
here is my code for delete(Node n)
----------------------------------
public boolean delete(Node n) { }
{
int var = 0;
Node head = new DS().getStart();
if (head.equal(n) )
{
head = head.getNext();
setStart(head);
var++;
}
Node n1 = null;
for (Node l = new DS().getStart() ; l != null; l = l.getNext())
{ if n1==null
if (l.equal(n))
{
n1.setNext(l.getNext());
var++;
}
}
if (var > 0)
return true;
else
return false;
}
modified on Thursday, September 25, 2008 9:02 AM
|
|
|
|
|
your code is still not formatted... don't you just see the code block button below the typing area ?
also, WTF is your question ???
|
|
|
|
|
Hi guys,
I'm trying to build a Swing application. It's all gone well enough so far but now I want to refactor my main form as I've got hundreds of controls on it and hundreds of corresponding methods.
In a few cases I've got UI elements that should be grouped together into a single class and resused. An example of this is a countdown timer. Basically three aligned labels containing 2 digits per label with colons in between ie 00:10:15.
I've tried to extend from JPanel and this allows me to add the component to the palette in NetBeans but I can't get the labels to be visible on screen. I changed the background colour of my control in its constructor and I can see that so I'm sure the component is being instantiated properly.
Unfortunately my router broke at home last night so I haven't got my source to hand but the important Method goes something like this.
private void DrawLabels()
{
labels[0] = new JLabel("00");
labels[1] = new JLabel("00");
labels[2] = new JLabel("00");
this.add(label[0]);
this.add(label[1]);
this.add(label[2]);
}
I've tried overriding paint(Graphics) and doing a drawstring in there but i don't see anything from that either. I've also tried deriving from JComponent with no success.
I can't find any info about creating your own controls and suspect they might be called something different or i'm going about build one the wrong way.
Can anyone give me any pointers?
Cheers
Russell
|
|
|
|
|
I seem to have fixed this myself using paintComponent() rather than paint()
It mostly seems to work now.
Thanks
Russell
|
|
|
|
|
I've found something strange with Java that I wanted to verify if it is expected behavior or not. Consider:
class MyClass
{
public String m_strName;
public String m_strAge;
public MyClass()
{
m_strName = "David";
m_strAge = "";
}
}
Vector<MyClass> vect = new Vector<MyClass>();
vect.add(new MyClass());
MyClass m = vect.get(0);
System.out.println(m.m_strName.length());
System.out.println(m.m_strAge.length());
When I add a MyClass object to the vector, it's two member variables are non-null. However, when I pull that object back out, the one empty member variable is now null, thus a NullPointerException is thrown. Is this something that can easily be rectified?
-DC
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
modified on Friday, September 19, 2008 2:35 PM
|
|
|
|
|
David, i'm sorry to say that I don't reproduce that (as expected, thanksfully)...
System.out.println(m.m_strAge.length()) gives me 0 (not "", because you're doing a length() on it)...
here is my exact code:
main.java:
package test;
import java.util.Vector;
public class Main {
public static void main(String[] args) {
Vector<MyClass> vect = new Vector<MyClass>();
vect.add(new MyClass());
MyClass m = vect.get(0);
System.out.println(m.m_strName.length());
System.out.println(m.m_strAge.length());
System.out.println("");
}
}
MyClass.java
package test;
public class MyClass {
public String m_strName;
public String m_strAge;
public MyClass() {
m_strName = "David";
m_strAge = "";
}
}
the Output of the debug console is:
5
0
So the question that comes to my mind : what compiler (IDE ?) do you use ?
ps: you code smells like a C++ coder is behind this ^^ (the m_ is not kinda java habits)
|
|
|
|
|
toxcct wrote: David, i'm sorry to say that I don't reproduce that...
Don't be, as I'm not able to either unless it's under very specific circumstances. I tried to trim the actual code down to the bare minimum, but it must be something else.
toxcct wrote: So the question that comes to my mind : what compiler (IDE ?) do you use ?
The IDE is Visual Editor within Eclipse. I'm using Jave SE6.
toxcct wrote: ps: you code smells like a C++ coder is behind this ^^ (the m_ is not kinda java habits)
Yep!
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
hi i have a below code which was supposed to record every 100ms and send the data to pc via bluetooth but every time the loop starts i asks for permission to access mic and also permission to store the recorded data but i need to supress this message is it possible if so please help me
this is my code
public void recordData()
{
dips = Display.getDisplay(this);
m_CmdStop = new Command("stop", Command.SCREEN, 1);
form = new Form("record");
form.addCommand(m_CmdStop);
dips.setCurrent(form);
try
{
DataOutputStream dos = m_Con.openDataOutputStream();
Player p = Manager.createPlayer("capture://audio");
p.realize();
p.prefetch();
RecordControl rc = (RecordControl)p.getControl("RecordControl");
p.start();
while(m_EndNow != true)
{
ByteArrayOutputStream output = new ByteArrayOutputStream();
rc.setRecordStream(output);
rc.startRecord();
//p.start();
Thread.sleep(100);
rc.commit();
//p.stop();
rc.stopRecord();
dos.writeUTF(output.toString());
}
p.stop();
dos.close();
}
catch(Exception e)
{
Log.log(e.getMessage());
}
}
|
|
|
|
|
hi,
I am a newbie java developer and I am struggling to setup a simple, a very simple, webcam chat application.
All I want is a web page that opens and shows two video controls - the one on the left shows the current users webcam, the one on the right shows the other users webcam. Sounds simple, right? No matter what I try it does not seem to work and there does not appear to be any solution to assist me.
I have been trawling this site and seen some code that might be useful but no completed program that actually meets my needs. I do not want it to use windows media player or open up another application to chat. I want it all contained in the one webpage.
Basically, the process is as follows:
1. Client logs into the website
2. Client requests webcam chat
3. Website owner (who is the person I am developing the site for) logs into the website
4. Website owner starts chat with client
5. End webchat when finished
My problem seems to be that I either have to have FMS or RED5 installed on a server, or the solutions are only LAN based, or I have to purchase some application that has public rooms, or I need to register with the original creators website before chatting.
This is not for an adult chat service. This application is for a not-for-profit organisation and the people they need to speak with will not want to talk with them if they have to register their details on another site. I find it hard to believe that there is no simple client-to-client webcam application that does what I need it to do over TCP/IP.
Please forgive me for going on, but if there is anyone who can help out in any way I would truly appreciate your assistance.
Regards
Matt
|
|
|
|
|
It seems I have reached the end of my leash with the personal financial software available... thus, I am considering writing my own. I am confident that I know enough and have enough experience to accomplish the entire project except for one major detail: I have no idea how to gain access to a bank in order to download a specific account's data, nor where to find such info. I have google'd and not come up with anything relevant.
I'm hoping that even if no one here has a concrete answer, some will at least know a bit about this, enough to enlighten me and point me in the right direction to figuring it out.
Thank You for Your Help!
|
|
|
|
|
I am trying to set the background color of a JDialog(object extends JDialog) using setBackground(Color.orange) but it is not working...
Can anyone help.
|
|
|
|
|
what you can do is not painting directly on the dialog but on its background panel.
make a new class inheriting from javax.swing.JPanel , and overload the method paintComponent() :
public void paintComponent(Graphics gr) {
super.paintComponents(gr);
gr.setColor(new Color(255, 255, 255));
gr.drawRect(0, 0, this.getSize().width, this.getSize().height);
}
then, in your dialog, just use this class as the Content Pane (in the constructor, or in the initialize() method if you use any):
JPanel panel = new YourJPane();
this.getContentPane().add(panel);
|
|
|
|
|
Can any one post me the ssn validation code which was already there in this website in ASP.net.I need to write the code for the same rules and implementaion(Flow chart).
|
|
|
|
|
hi i have the below code to start bluetooth over PC to accept data from mobile
but when i compile i will get the following errors
i have widcom bluetooth stack and bluecove.jar and intelbth.dll(i placed this in system32)
<br />
<br />
public class PC_Bluetooth implements Runnable<br />
{<br />
private LocalDevice m_LocalDevice;<br />
String connectionURL = "btspp://localhost:393a84ee7cd111d89527000bdb544cb1;" + "authenticate=false;encrypt=false;name=RFCOMM Server";<br />
StreamConnectionNotifier server = null;<br />
StreamConnection conn = null;<br />
public Thread t1 = null;<br />
<br />
public void startServer()<br />
{<br />
if (t1 != null)<br />
return;<br />
t1 = new Thread(this);<br />
t1.start(); <br />
}<br />
public void PC_Bluetooth()<br />
{<br />
<br />
}<br />
public void config_bluetooth()<br />
{<br />
try<br />
{<br />
m_LocalDevice = LocalDevice.getLocalDevice();<br />
m_LocalDevice.setDiscoverable(DiscoveryAgent.GIAC);<br />
server = (StreamConnectionNotifier)<br />
Connector.open(connectionURL);<br />
conn = server.acceptAndOpen(); <br />
}<br />
catch (Exception e)<br />
{<br />
System.out.println(e.getMessage());<br />
}<br />
<br />
}<br />
public void run()<br />
{<br />
try<br />
{<br />
config_bluetooth();<br />
<br />
}<br />
catch (Exception e)<br />
{<br />
System.out.println(e.getMessage());<br />
}<br />
<br />
}<br />
<br />
}<br />
<br />
<br />
and the exceptions are:<br />
init:<br />
deps-jar:<br />
compile:<br />
run:<br />
here to do..all<br />
BlueCove version 2.0.2 on widcomm<br />
Exception in thread "Thread-0" java.lang.UnsatisfiedLinkError: getProperty0<br />
at com.sun.midp.Configuration.getProperty0(Native Method)<br />
at com.sun.midp.Configuration.getProperty(Configuration.java:34)<br />
at com.sun.midp.io.InternalConnector.<clinit>(InternalConnector.java:91)<br />
at javax.microedition.io.Connector.open(Connector.java:158)<br />
at javax.microedition.io.Connector.open(Connector.java:138)<br />
at javax.microedition.io.Connector.open(Connector.java:120)<br />
at pc_interface.PC_Bluetooth.config_bluetooth(PC_Bluetooth.java:42)<br />
at pc_interface.PC_Bluetooth.run(PC_Bluetooth.java:56)<br />
at java.lang.Thread.run(Thread.java:595)<br />
BlueCove stack shutdown completed<br />
BUILD SUCCESSFUL (total time: 3 seconds)<br />
<br />
<br />
please suggest me...<br />
<br />
|
|
|
|
|
I have been studying and Googling Abstract Data Types in Java, and I don't get it. The examples all seem to be overly complicated.
Can someone point out or provide a simple code example of an ADT in Java?
Thanks
Everything makes sense in someone's mind
|
|
|
|
|
what don't you understand ?
the use of templates ?
|
|
|
|
|
I don't understand what an ADT is. A code example would be nice.
Everything makes sense in someone's mind
|
|
|
|
|
have you googled for it first ?
did you read this[^] nice article ?
for what I uuderstand (but i'm not used to this denomination of "Abstract Data Type"), ADT are types (classes) which are data sets and provide generic operation on the objects it contains.
what don't you understand in this ?
|
|
|
|
|
|