• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

JeTmAn81

Member
Everything sees to be a challenge for me. I'm actually completely stuck now. I'm still getting a 92% in the class, but I feel like I don't understand what's being asked alot of the time or why I'm doing the things I'm doing. The instructions for the mutate are

mutate – This method will take no parameters. It will select at random (use the Math.random method) a position for a character in its dNACode and replace it with the character ‘X’. The method will return the current object (return this).

I feel like I'm close with this.

Code:
int r1 = (int) (Math.random() * dNACode.length());
		dNACode.replace(dNACode.charAt(r1), 'X');
		this.dNACode = dNACode;
		return this.dNACode;

but probably not. I know I need to make a new string.

The next step after reverse is to create a new ComputerMicrobe.

reproduce – This method takes another ComputerMicrobe as a parameter and creates a new ComputerMicrobe. This new ComputerMicrobe will have a name that is the concatenation of the name of “this” ComputerMicrobe with the name of the other ComputerMicrobe. The dNACode of the new ComputerMicrobe will take half of the dNACode of “this” ComputerMicrobe concatenated with half of the dNACode of the other ComputerMicrobe. The method will return the newly created ComputerMicrobe.

The driver won't compile if the class is wrong, so I've been using that to help steer me in the right direction. I can't even find any examples of the "reproduce" method. I guess that's what programming is about. I'm not worried about passing the class. I'm worried about moving from here to Programming Fundamentals and being completely lost.

Your mutate seems fine to me except you're told to return the whole object rather than the DNA code member.

To do reproduce, break down the steps needed for the method as far as you need to understand what's going on. If it seems too complex, test each statement to make sure it's doing what you want it to.
 
Your mutate seems fine to me except you're told to return the whole object rather than the DNA code member.

To do reproduce, break down the steps needed for the method as far as you need to understand what's going on. If it seems too complex, test each statement to make sure it's doing what you want it to.

See that's why I get confused. Everything compiles with that code, but nothing changes.

This worked for reverse though.

Code:
public String reverse()
	{
       if(dNACode == null || dNACode.isEmpty()){
	   	return dNACode;
	   		}
				String reverse = "";
				for(int i = dNACode.length() -1; i>=0; i--){
				reverse = reverse + dNACode.charAt(i);
	   		}

	   	this.dNACode = reverse;
		return this.dNACode;
	}
 

JeTmAn81

Member
See that's why I get confused. Everything compiles with that code, but nothing changes.

This worked for reverse though.

Code:
public String reverse()
	{
       if(dNACode == null || dNACode.isEmpty()){
	   	return dNACode;
	   		}
				String reverse = "";
				for(int i = dNACode.length() -1; i>=0; i--){
				reverse = reverse + dNACode.charAt(i);
	   		}

	   	this.dNACode = reverse;
		return this.dNACode;
	}

For mutate the instructions say to return this, so return this.

Notice any optimization you could do on reverse? How much code could you eliminate with a method that only has one return statement?
 
For mutate the instructions say to return this, so return this.

Notice any optimization you could do on reverse? How much code could you eliminate with a method that only has one return statement?

Sorry I don't follow.
If I change the mutation to

Code:
public String mutate()
	{
			int r1 = (int) (Math.random() * dNACode.length());
			dNACode.replace(dNACode.charAt(r1), 'X');
			this.dNACode = dNACode;
			return this;
	}

I get this error

.java:70: error: incompatible types: ComputerMicrobe cannot be converted to String
return this;
^
 
"public String mutate()" declares that mutate() returns a string, which it does in the code that compiles. When you return 'this', it is no longer a string but the object. I don't remember enough Java to tell you what to replace 'string' with, but that is what the compiler is telling you.
 
"public String mutate()" declares that mutate() returns a string, which it does in the code that compiles. When you return 'this', it is no longer a string but the object. I don't remember enough Java to tell you what to replace 'string' with, but that is what the compiler is telling you.

That sums up my problem. public String mutate/reverse allows the driver to compile. I have no idea what to use to make reproduce compile.
 

dabig2

Member
That sums up my problem. public String mutate/reverse allows the driver to compile. I have no idea what to use to make reproduce compile.

Are you asking what the method signature should be to compile? If you're returning the class object itself, just make it:
public ComputerMicrobe mutate(){code here}
 

Two Words

Member
Been working a few days as a CS tutor at my university. After just a few days, it is becoming abundantly clear, pointers confuse people a lot. I'm really glad I was introduced to pointers almost immediately. A lot of people who learned programming in things like Java seem to have a big problem with getting how pointers work.
 

cyborg009

Banned
Been working a few days as a CS tutor at my university. After just a few days, it is becoming abundantly clear, pointers confuse people a lot. I'm really glad I was introduced to pointers almost immediately. A lot of people who learned programming in things like Java seem to have a big problem with getting how pointers work.

I'm having that a bit with C at the moment and had issues with C++.
 

Mr.Mike

Member
Been working a few days as a CS tutor at my university. After just a few days, it is becoming abundantly clear, pointers confuse people a lot. I'm really glad I was introduced to pointers almost immediately. A lot of people who learned programming in things like Java seem to have a big problem with getting how pointers work.

Have you had anyone come to you and basically ask you to do their homework for them yet ? :p
 
Been working a few days as a CS tutor at my university. After just a few days, it is becoming abundantly clear, pointers confuse people a lot. I'm really glad I was introduced to pointers almost immediately. A lot of people who learned programming in things like Java seem to have a big problem with getting how pointers work.

Yeah it threw me for a loop a bit at the beginning (Although luckily a lot of friends of mine warned about pointers when I began learning C++). I'm just glad I began with a statically typed language like Java rather than dynamically typed one (supposedly Python is the starting programming languages in some schools).
 

Two Words

Member
Have you had anyone come to you and basically ask you to do their homework for them yet ? :p

I've walked people through their homework. I try not to do any writing for them. I'll explain how things work I try to look at what their assignment needs them to do, then I'll start a new program that exercises those things.
 

JeTmAn81

Member
Are you asking what the method signature should be to compile? If you're returning the class object itself, just make it:
public ComputerMicrobe mutate(){code here}

Exactly. Typically in these homework assignments you'll be provided with the skeleton of an API, so if Beerman got that it should show a return type of ComputerMicrobe. The instructions he mentioned explicitly say to return this, which in the context of this code will refer to the current instance of the ComputerMicrobe object the code is running in.

Edit: changing the return type on mutate shouldn't affect the driver code since it's not doing anything with mutate's return type anyway.

Been working a few days as a CS tutor at my university. After just a few days, it is becoming abundantly clear, pointers confuse people a lot. I'm really glad I was introduced to pointers almost immediately. A lot of people who learned programming in things like Java seem to have a big problem with getting how pointers work.

I may have misunderstood pointers for literally 10+ years. They're an incredibly simple concept that is almost always poorly explained and comes with confusing syntax.
 

cyborg009

Banned
Exactly. Typically in these homework assignments you'll be provided with the skeleton of an API, so if Beerman got that it should show a return type of ComputerMicrobe. The instructions he mentioned explicitly say to return this, which in the context of this code will refer to the current instance of the ComputerMicrobe object the code is running in.

Edit: changing the return type on mutate shouldn't affect the driver code since it's not doing anything with mutate's return type anyway.



I may have misunderstood pointers for literally 10+ years. They're an incredibly simple concept that is almost always poorly explained and comes with confusing syntax.

DO you mind giving us the explanation?
 

NotBacon

Member
I've always gotten by with: it stores the address of a memory location that can hold a certain data type (the type of the pointer).
 

dabig2

Member
I always find visual representations to be very helpful in explaining pointers/references and such. To steal from Cplusplus:
The code:
Code:
myvar = 25;
foo = &myvar;
bar = myvar;
can be seen by the following image:
reference_operator.png

So the foo variable is literally storing the physical memory address where myvar is stored.

Furthermore,
Code:
myvar = 25;
foo = &myvar;
bar = myvar;
[B]baz = *foo;[/B] //new line added
can be seen by:
dereference_operator.png


I think most people get tripped up by that one honestly. baz = foo would give you the memory address that was stored (1776) instead of the value pointed to it.
 

Koren

Member
I'm just glad I began with a statically typed language like Java rather than dynamically typed one (supposedly Python is the starting programming languages in some schools).
Python is indeed the starting programming language here.

And it's really not an issue that it's dynamically typed. Virtually all beginners have no troubles that names aren't associated statically to a type (I mean, it's not even variables, it's names, or labels...). The only people barely surprised are the ones that come from a statically-typed language.

I'd say the main issue is mutable / non mutable, and how can names can refer to different things depending on the context. See for example :
Code:
def foo(L) :
    L[0] = 3
    L = [ 4, 5 ]
    L[1] = 6

L = [ 1, 2 ]
foo(L)
When I managed to explain why L contains [ 3, 2 ] at the end of the snippet (with force drawings), I know the worse part is behind.

(the next hurdle is why T[1], T[2] = T[2], T[1] don't swap lines of a numpy.array, and that one is hard)



I woudn't have chosen Python myself as a beginner language (would probably have went to Ada, even if it isn't widely used... but I think a language chosen to teach the basics of coding don't have to be an industry standard, especially since the industry standard can change three times before they reach the industry!)

On the other end of the spectrum, I've also experienced CaML as a beginner language, the difference is really small (but the syntax is far less friendly, and enforcing indentation for beginners has its merits).
 

Water

Member
Been working a few days as a CS tutor at my university. After just a few days, it is becoming abundantly clear, pointers confuse people a lot. I'm really glad I was introduced to pointers almost immediately. A lot of people who learned programming in things like Java seem to have a big problem with getting how pointers work.

Pointers are just one instance of the more general concept of references. That concept is the hard thing, and a solid intro course should hammer it into the students regardless of language used. If students aren't learning the concept, that's on them or the teachers, not the language. The specifics of pointers (as opposed to other types of references) are irrelevant for a general purpose intro class. Trying to teach them early anyway comes at a high cost since it probably means using C or C++, both of which are awful intro languages.
I also actively dislike Java as an intro language (and otherwise...), but lack of pointers is not the reason.
 

Somnid

Member
Pointers are just one instance of the more general concept of references. That concept is the hard thing, and a solid intro course should hammer it into the students regardless of language used. If students aren't learning the concept, that's on them or the teachers, not the language. The specifics of pointers (as opposed to other types of references) are irrelevant for a general purpose intro class. Trying to teach them early anyway comes at a high cost since it probably means using C or C++, both of which are awful intro languages.
I also actively dislike Java as an intro language (and otherwise...), but lack of pointers is not the reason.

I think it's because pointers conflate the underlying architecture with the abstract model used to for logic (also the unfortunate C syntax). I want to operate on objects, not the representation of those objects in memory.
 

Water

Member
I think it's because pointers conflate the underlying architecture with the abstract model used to for logic (also the unfortunate C syntax). I want to operate on objects, not the representation of those objects in memory.

Yes, that's a decent summary of the reasons against teaching pointers to programming beginners. They are useless and a huge roadblock to learning if introduced early. Only those programmers who end up working in very specific environments (C language, ...) ever need to use pointers, and picking them up is trivial once you already understand the concepts of references and iterators.
 

Somnid

Member
Remove pointer arithmetics and I don't see how you need the underlying architecture to understand pointers.

Without arithmetic you don't really have pointers, you have references which are more intuitive and virtually all languages have these.

If so, I'm not sure C is the best language choice...

Right, it's not, but furthermore major languages outside of C/C++ don't use them. So on the topic of learning high-level programming languages I'm not sure you need to learn them until you get to a more advanced level of optimization/foundational understanding of languages.
 

marmoka

Banned
Does anybody know a good website and Twitter account about news of different programming languages? That would help me being up to date.

Thanks GAF!!
 

Koren

Member
I think even beginner programmers should be taught a bit about how memory works.
I agree, but you can learn how it works without being able to do micro-management of memory.

Without arithmetic you don't really have pointers, you have references which are more intuitive
Not sure there's really a difference in terms of intuitiveness... (having learned pointers first, I've had a hard time getting used to references, since in many language it's far less clear than & and * to me...)

But most of the time, you indeed only use references, so you can present pointers like references and don't talk about arithmetics. Algorithms often "need" references, but not pointers anyway.

Right, it's not, but furthermore major languages outside of C/C++ don't use them.
That's because pointers arithmetics are only interesting when you're doing low-level stuff... It's not needed at first, I'd say.

So on the topic of learning high-level programming languages I'm not sure you need to learn them until you get to a more advanced level of optimization/foundational understanding of languages.
I agree, but I don't think C is a good language to learn high-level programming...
 
Part of the problem with pointers is that it's never motivated by a use case in which pointers are the only solution. People often start by saying "ok now we're gonna learn about pointers", and then blindly just start introducing the syntax, or some lead in about addresses and mailboxes, or talking about memory. But they never answer the question of what problem pointers solve, or if they do it's done far too late.

People teaching pointers should start off by saying "here's a problem, solve it using what you know". Examples include

* a function that takes a value optionally and behaves differently if the value is specified (the non pointer solution probably includes an extra bool parameter)

* a function that takes a struct and intereprets its members differently depending on what type of struct it is (car, motorcycle, bus, etc)

* a function that returns multiple values

Then you can start by showing how to solve these problems with pointers (null and inheritance), while leaving the details of what everything means until after people get comfortable with a few basic scenarios of when to use them
 

Slavik81

Member
When I was a kid, I did plenty of summer camps with various sorts of programming. They pretty much all want over 'This is how you print. This is how you declare variable. This is how you do math.'

It actually wasn't until my first year intro to programming course where somebody explained how things existed in memory, and how pointers worked.

That was actually the first time I felt like I understood anything about software. It transformed from magic into something real.
 

Koren

Member
I've used pointers in Pascal and C for the first time with linked lists, I think it's a good example, easy to explain, with many possible examples of variable difficulties.
 
Pointers finally completely clicked for me when I took a class that dealt with Assembly language.

actually that class was super informative and definitely helped make a lot of things programming wise click for me.
 

JeTmAn81

Member
All programmers should be taught about how memory works.

Certainly, but when? And how much? Obviously if you take a class like Nand2Tetris you're going to learn a heck of a lot about how things work at the lower level, but that's no good for a beginner. I think for a true beginner, just explaining the concept that info is stored in little spaces in the computer's memory which have unique addresses is probably enough.
 

Ambitious

Member
Man, I didn't know how incredibly frustrating it can be to help amateurs with their programming homework. My brother has a programming class in his first year at highschool. Up until now, he didn't have any big issues, but he just can't figure out how to solve his current homework. I tried to carefully guide him towards the solution, but he just wasn't able to connect the dots.

We're now at a point where all that's left to do is to fill in an if condition, but there are no more hints I could give him.
I guess I'm gonna give him some more time to think about it, then I'll reveal the solution and try to make him understand how and why it works.
 
Yay I got my OCA Java SE 7 Programmer I certification :v
71%, I'm a bit surprised as it was really hard. Luck was on my side today :p

I wish I could see where I answered incorrectly tho, they just gave me the "objectives" I failed...
 

Gurrry

Member
Question for any Unity 5 users:

Do any of you have intellisense (or code completion in MonoDevelop) for Unityscript?

I just installed Unity 5 and I only have intellisense for C#. Is there a way to get a code completion for JS/Unityscript?
 

Makai

Member
Question for any Unity 5 users:

Do any of you have intellisense (or code completion in MonoDevelop) for Unityscript?

I just installed Unity 5 and I only have intellisense for C#. Is there a way to get a code completion for JS/Unityscript?
You can use whatever IDE you want.
 

Joni

Member
So I have been looking around for some API to help a Gaf trophy topic and I found some. I just have no idea how or what I would need to install on what.

https://github.com/xseillier/psn-api
http://macbury.ninja/2014/8/scrappi...-playstation-profile-using-ruby-and-phantomjs
https://github.com/jhewt/gumer-psn

I have learned one thing: I should have paid more attention in school to learn this stuff. I'm in IT but in a non programming branch. Basically I can code real slow but I usually have no idea what environment I need.

Edit: Looking into it more, I could probably achieve the same by parsing PSNProfiles user pages, finding the right lines in the HTML. Time to brush up on Java to get that info. That at least I should be able to handle. :)
 

shoreu

Member
Ok guys So I'm writing a JavaFx code in Intelij that wants me to create an Hbox and an Object Called Colorpane. Then i'm to make a couple of event to modify the color of the box as the instructions see fit.

I've done all of this yet the program will not run and the professor Hasn't really put in any time to help me fix this.

Here's the code.For the Rectangle and the Methods for the buttons.

/**
* Created by camjo on 3/3/2016.
*/

import javafx.application.Application;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

public class ColorPane extends Pane {
private Rectangle rekt;



public ColorPane(){
getChildren().addAll(this.rekt);
this.rekt.setX(0);
this.rekt.setY(0);
this.rekt.widthProperty().bind(widthProperty());
this.rekt.heightProperty().bind(heightProperty());

//color set by Hue saturation and brightness
Color rcol = Color.hsb(140.0,0.6,0.3);

this.rekt.setFill(rcol);


}


public static void main(String[] args) {

}

public void Hue_up() {
Color color = (Color)this.rekt.getFill();
double h = color.getHue();
double s = color.getSaturation();
double b = color.getBrightness();
h = (h + 30);

this.rekt.setFill(Color.hsb(h,s,b));
}

public void Hue_dwn() {
Color color = (Color)this.rekt.getFill();
double h = color.getHue();
double s = color.getSaturation();
double b = color.getBrightness();
h = (h - 30);

this.rekt.setFill(Color.hsb(h,s,b));
}

public void More_sat() {
Color color = (Color)this.rekt.getFill();
double h = color.getHue();
double s = color.getSaturation();
double b = color.getBrightness();
s = Math.sqrt(s);
this.rekt.setFill(Color.hsb(h,s,b));
}

public void Less_sat() {
Color color = (Color)this.rekt.getFill();
double h = color.getHue();
double s = color.getSaturation();
double b = color.getBrightness();
s = Math.pow(s,2.0);
this.rekt.setFill(Color.hsb(h,s,b)); }

public void Lighter(){
Color color = (Color)this.rekt.getFill();
color = color.brighter();
this.rekt.setFill(color);
}

public void Darker(){
Color color = (Color)this.rekt.getFill();
color = color.darker();
this.rekt.setFill(color);
}


}



Here's the code for the Buttons, Pane's, Stages, and Scenes.

/**
* Created by camjo on 3/3/2016.
*/

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;

public class ShowColors extends Application {
private ColorPane colorPane;


public static void main(String[] args) {
launch(args);

}

@Override
public void start(Stage primaryStage) {
colorPane = new ColorPane();
HBox b = new HBox();
b.setSpacing(10);
b.setAlignment(Pos.CENTER);
Button bthu = new Button("Hue up");
Button bthd = new Button("Hue down");
Button btms = new Button("More saturated");
Button btls = new Button("Less saturated");
Button btdk = new Button("darker");
Button btlt = new Button("lighter");
b.getChildren().addAll(btdk,bthd,bthu,btls,btms,btlt);


Pane pane = new Pane();
pane.getChildren().addAll(colorPane);

//register button

//hue up registration
Hue_upHandler hu = new Hue_upHandler();
bthu.setOnAction(hu);

//hue down registration
Hue_dwnHandler hd = new Hue_dwnHandler();
bthd.setOnAction(hd);

//More sat registration
More_SatHandler ms = new More_SatHandler();
btms.setOnAction(ms);

//Less sat registration
Less_SatHandler ls = new Less_SatHandler();
btls.setOnAction(ls);

//Lighter button registration
LighterHandler lt = new LighterHandler();
btlt.setOnAction(lt);

//Darker button registration
DarkerHandler dk = new DarkerHandler();
btdk.setOnAction(dk);




//BorderPane setup
BorderPane bp = new BorderPane();
bp.getChildren().addAll(b,pane);
bp.setCenter(pane);
bp.setBottom(b);
bp.setAlignment(b, Pos.CENTER);


//Scene

Scene sc= new Scene(bp, 500, 500);

primaryStage.setTitle("ShowRectangle"); // Set the stage title

primaryStage.setScene(sc); // Place the scene in the stage

primaryStage.show(); // Display the stage


}
//hue up handler
private class Hue_upHandler implements EventHandler<ActionEvent> {

@Override
public void handle(ActionEvent event) {
colorPane.Hue_up();
}
}
//hue down handler
private class Hue_dwnHandler implements EventHandler<ActionEvent>{

@Override
public void handle(ActionEvent event) {
colorPane.Hue_dwn();
}
}
//More Sat handler
private class More_SatHandler implements EventHandler<ActionEvent>{

@Override
public void handle(ActionEvent event) {
colorPane.More_sat();

}
}
//More Sat handler
private class Less_SatHandler implements EventHandler<ActionEvent>{

@Override
public void handle(ActionEvent event) {
colorPane.Less_sat();

}

}

//Lighter Handler
private class LighterHandler implements EventHandler<ActionEvent>{

@Override
public void handle(ActionEvent event) {
colorPane.Lighter();

}

}

//Darker Handler
private class DarkerHandler implements EventHandler<ActionEvent>{

@Override
public void handle(ActionEvent event) {
colorPane.Darker();

}

}
}

Here's the List of Errors i'm getting.

Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: Children: child node is null: parent = ColorPane@48aa389d
at javafx.scene.Parent$2.onProposedChange(Parent.java:435)
at com.sun.javafx.collections.VetoableListDecorator.addAll(VetoableListDecorator.java:234)
at com.sun.javafx.collections.VetoableListDecorator.addAll(VetoableListDecorator.java:103)
at ColorPane.<init>(ColorPane.java:17)
at ShowColors.start(ShowColors.java:27)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
... 1 more


I'm stuck and my teacher is being ass for help I have no clue what to do

.
 
See this?
Code:
Caused by: java.lang.NullPointerException: Children: child node is null: parent = ColorPane@48aa389d
at javafx.scene.Parent$2.onProposedChange(Parent.java:435)
at com.sun.javafx.collections.VetoableListDecorator.addAll(VetoableListDecorat or.java:234)
at com.sun.javafx.collections.VetoableListDecorator.addAll(VetoableListDecorat or.java:103)
at [b]ColorPane.<init>(ColorPane.java:17)[/b]
at ShowColors.start(ShowColors.java:27)

Then, this:
Code:
public ColorPane(){
    getChildren().addAll(this.rekt);
this.rekt is probably null when this line runs. You need to make sure it exists before you try to add it.

Possibly something like "private Rectangle rekt = new Rectangle();" where you declare it a few lines above.
 

shoreu

Member
See this?
Code:
Caused by: java.lang.NullPointerException: Children: child node is null: parent = ColorPane@48aa389d
at javafx.scene.Parent$2.onProposedChange(Parent.java:435)
at com.sun.javafx.collections.VetoableListDecorator.addAll(VetoableListDecorat or.java:234)
at com.sun.javafx.collections.VetoableListDecorator.addAll(VetoableListDecorat or.java:103)
at [b]ColorPane.<init>(ColorPane.java:17)[/b]
at ShowColors.start(ShowColors.java:27)

Then, this:
Code:
public ColorPane(){
    getChildren().addAll(this.rekt);
this.rekt is probably null when this line runs. You need to make sure it exists before you try to add it.

Possibly something like "private Rectangle rekt = new Rectangle();" where you declare it a few lines above.

Did this It removed the Null error but their is still a host of errors to deal with.
 

shoreu

Member
The thing you posted is one giant error, you're gonna have to post the new ones if it's still spitting stuff out.

New Errors.
Code:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:917)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Children: duplicate children added: parent = BorderPane@2f07796c
	at javafx.scene.Parent$2.onProposedChange(Parent.java:454)
	at com.sun.javafx.collections.VetoableListDecorator.add(VetoableListDecorator.java:206)
	at javafx.scene.layout.BorderPane$BorderPositionProperty.invalidated(BorderPane.java:680)
	at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
	at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
	at javafx.scene.layout.BorderPane.setCenter(BorderPane.java:260)
	at ShowColors.start(ShowColors.java:75)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$162(LauncherImpl.java:863)
	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$175(PlatformImpl.java:326)
	at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
	... 1 more
 

shoreu

Member
Maybe bp.setCenter(pane); and bp.setBottom(b); are trying to add to the parents children list as well.

Try getting rid of
Code:
bp.getChildren().addAll(b,pane);

Bro It was this. And the fact that I put the color pane into another pane. Thank you so much guys.
 
Top Bottom