• What Do You Need Help With? V6
    7,544 replies, posted
Binary trees are useful. For, like, search trees. For instance. Because each level you go down in a balanced binary search tree halves the amount of elements left to be searched.
[QUOTE=esalaka;39982920]Binary trees are useful. For, like, search trees. For instance. Because each level you go down in a balanced binary search tree halves the amount of elements left to be searched.[/QUOTE] I feel there are more useful ways of doing such a thing though. Binary tree's just seem so... overly complicated for what they are. For instance what I need help with, using them to encode and decode strips of string inputted. It's clever but doesn't seem super efficient to do such a thing.
I don't really see what exactly is so complicated
They are very useful for things that are ordered, like sets.
[QUOTE=esalaka;39983015]I don't really see what exactly is so complicated[/QUOTE] Eh I'm done complaining hahah, they do have there uses like everything else. I'm complaining since I'm having such a terrible time with them and can't figure this out for the life of me hahah.
[QUOTE=esalaka;39982920]Binary trees are useful. For, like, search trees. For instance. Because each level you go down in a balanced binary search tree halves the amount of elements left to be searched.[/QUOTE] Why not 2-3 tree?
[QUOTE=Relaxation;39984980]Why not 2-3 tree?[/QUOTE] Because binary trees specifically were being discussed. If search trees in general had been, I'm sure someone would've brought up 2-3 trees earlier. And apparently, 2-3 trees are isometric with AA trees which are variant red-black trees... Which means that essentially 2-3 trees can be expressed as (possibly strangely shaped) binary trees.
I'm just going to pretend 2-3 trees don't exist... I'm still having trouble with this as is hahah. I'm still having no luck figuring how to do this encode and decode crap... I dunno why...
I'm thinking about picking up some programming language from scratch and learning towards a project I've been thinking about doing lately. What it involves it creating a GUI to display information on weapon info, upgrades, etc from a game, as well as an interactive map of the game world that contains notable locations within the map area as toggleable icons. I would just be doing this for personal use and to learn. Anybody have any suggestions as to what I should try to build this with? There are a ton of options, but I'm not sure what to pick up and run with.
[QUOTE=HellSoldier;39980295]If I've recently started in C++ and want along term project to commit to would it be wise to create my own mashed up game engine and then work from there or use one already acailable to me?[/QUOTE] make something useful
Is there a way to put Jmenuitems into arrays in netbeans?
JMenuItem[] items = new JMenuItem[size]
[QUOTE=jaooe;39989212]JMenuItem[] items = new JMenuItem[size][/QUOTE] this is what i get [img]http://shrani.si/f/3J/Qa/496pLQat/untitled.jpg[/img]
[QUOTE=Uesrname;39987329]I'm thinking about picking up some programming language from scratch and learning towards a project I've been thinking about doing lately. What it involves it creating a GUI to display information on weapon info, upgrades, etc from a game, as well as an interactive map of the game world that contains notable locations within the map area as toggleable icons. I would just be doing this for personal use and to learn. Anybody have any suggestions as to what I should try to build this with? There are a ton of options, but I'm not sure what to pick up and run with.[/QUOTE] Probably C# if you're comfortable with limiting your platform to Windows. Otherwise C++ with some cross-platform GUI library like Qt, or Java which has a variety of GUI tools.
[QUOTE=RandomDexter;39989741]this is what i get [IMG]http://shrani.si/f/3J/Qa/496pLQat/untitled.jpg[/IMG][/QUOTE] Here is my code from a program I recently created. First I created the initial array like this JMenuItem[] menuItem = new JMenuItem[30]; This doesn't actually create JMenuItems though, but rather reserves space for them. You then need to do something like: menuItem[0] = new JMenuItem(parameters here) In my program, I had another array containing Strings and I put the above code in a loop and used the Strings for the button text. So my code looked like: for (i = 0; i < menuItem.length; i++){ menuItem[i] = new JMenuItem(stringVariable[i]) }
[QUOTE=djjkxbox360;39990295]Here is my code from a program I recently created. First I created the initial array like this JMenuItem[] menuItem = new JMenuItem[30]; This doesn't actually create JMenuItems though, but rather reserves space for them. You then need to do something like: menuItem[0] = new JMenuItem(parameters here) In my program, I had another array containing Strings and I put the above code in a loop and used the Strings for the button text. So my code looked like: for (i = 0; i < menuItem.length; i++){ menuItem[i] = new JMenuItem(stringVariable[i]) }[/QUOTE] Can you elaborate a little more please? In my case i tried it like this(doesn't work thou) [code] JMenuItem[] menuItem = new JMenuItem[4]; menuItem[0] = new JMenuItem(jMenuItem5); menuItem[1] = new JMenuItem(jMenuItem6); .... [/code]
Have you tried doing this? [code]JMenuItem[] menuItem; menuItem = {menuItem1, menuItem2, menuItem3[/code]
[QUOTE=Gulen;39990507]Have you tried doing this? [code]JMenuItem[] menuItem; menuItem = {menuItem1, menuItem2, menuItem3[/code][/QUOTE] Yep, with jButton there is no problem, but Jmenuitem[] type doesnt exist apparently
[QUOTE=RandomDexter;39990407]Can you elaborate a little more please? In my case i tried it like this(doesn't work thou) [code] JMenuItem[] menuItem = new JMenuItem[4]; menuItem[0] = new JMenuItem(jMenuItem5); menuItem[1] = new JMenuItem(jMenuItem6); .... [/code][/QUOTE] What is jMenuItem5 and jMenuItem6? A jMenuItem takes the parameters for text and/or an icon, so in the brackets () there should be a reference to an Icon or/and a String (There are some other stuff as well that can be used for parameters)
The error clearly says it cannot find the 'JMenuItem' you're referring to, are you sure you've imported the relevant stuff?
Yeah make sure the stuff is actually imported :v: The easiest way to import all the swing elements is import javax.swing.*; Although you should only import the elements you're using
[QUOTE=Chris220;39990536]The error clearly says it cannot find the 'JMenuItem' you're referring to, are you sure you've imported the relevant stuff?[/QUOTE] doesnt ctrl+shift+i deals with the imports? i did that Edit: looks like this works [code] JMenuItem[] menuItem = new JMenuItem[4]; menuItem[0] = jMenuItem5; menuItem[1] = jMenuItem6; menuItem[2] = jMenuItem7; menuItem[3] = jMenuItem8; [/code]
I prefer to use ctrl+shift+o, that way it gets rid of those you don't use as well (I think it might do some other things as well, not sure about that)
[QUOTE=RandomDexter;39989011]Is there a way to put Jmenuitems into arrays in netbeans?[/QUOTE] Please don't use netbeans :/ [editline]21st March 2013[/editline] [QUOTE=RandomDexter;39990623]doesnt ctrl+shift+i deals with the imports? i did that Edit: looks like this works [code] JMenuItem[] menuItem = new JMenuItem[4]; menuItem[0] = jMenuItem5; menuItem[1] = jMenuItem6; menuItem[2] = jMenuItem7; menuItem[3] = jMenuItem8; [/code][/QUOTE] Just click on the red x on the left side of the row, it'll bring up suggestions to fix it if it's an import issue.
[QUOTE]Please don't use netbeans :/[/QUOTE] i have to, it's in a subject policy New question, why the fuck this doen't work?!? [code] private void Options1(java.awt.event.ActionEvent evt) { JMenuItem[] menuItem = new JMenuItem[4]; menuItem[0] = jMenuItem5; menuItem[1] = jMenuItem6; menuItem[2] = jMenuItem7; menuItem[3] = jMenuItem8; JButton[] button = {jButton1,jButton2,jButton3,jButton4}; char[] Name = {'S','T','A','Š'}; for(int i = 0; i < 4; i++){ if(evt.getSource() == menuItem[i] || evt.getSource()== button[i]){ Messages.setText("Dodajanje &#269;rke "+Name[i]); Textfield.setText(Textfield.getText()+Name[i]); } } } [/code] whenever i click the buttons or menuitems, the letter should appear in jTextField + next to the jLabel a message(about adding a letter) should appear, but that just doens't happen
[QUOTE=mobrockers2;39990743]Please don't use netbeans :/[/QUOTE] Whats wrong with netbeans? Unless you mean the gui designer
[QUOTE=Richy19;39991917]Whats wrong with netbeans? Unless you mean the gui designer[/QUOTE] Netbeans is practically build around the GUI designer, and I dunno, I just had all sorts of trouble with netbeans especially with regards to plugins.
I've always found Netbeans to be fairly decent. I don't know if I prefer it over Eclipse, but it's not bad.
[QUOTE=Chris220;39993368]I've always found Netbeans to be fairly decent. I don't know if I prefer it over Eclipse, but it's not bad.[/QUOTE] I liked it up until I had to switch to eclipse, forced by my college, and I couldn't load my old projects because I found out Netbeans likes to use it's own special frame and panel classes when you use the UI editor. What I also found highly annoying when I used it is that you can't edit any of the code generated by the UI editor.
So I am writing a compiler in C#, and in my Code Generator I have this block of code: [csharp]else if (stmt is ReadInt) { this.il.Emit(Emit.OpCodes.Call, typeof(System.Console).GetMethod("ReadLine", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static, null, new System.Type[] { }, null)); this.il.Emit(Emit.OpCodes.Call, typeof(int).GetMethod("Parse", System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static, null, new System.Type[] { typeof(string) }, null)); this.Store(((ReadInt)stmt).Ident, typeof(int)); }[/csharp] And what this does is allows the user to input an integer when readint <var>; is called in the code. However, I am not sure how to add a check to see if the user is inputting a value that isn't an integer because this happens if the value isn't an int: [img]http://puu.sh/2lEtU[/img] I can think of ways this can be solved, but I am not sure how to actually pull it off. If there are any other sections of code you need to see, please tell me. This is an issue that has made me scratch my head for about 5 days straight. I bet this is something obvious, and that I'll feel really stupid if someone can solve this.
Sorry, you need to Log In to post a reply to this thread.