Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
HFX
Nov 29, 2004

1337JiveTurkey posted:

You might try flatworm although I haven't personally tried it.

This just might work. Time to try it out on a demo in spare time and then go through legal hell hole.

Adbot
ADBOT LOVES YOU

supermikhail
Nov 17, 2012


"It's video games, Scully."
Video games?"
"He enlists the help of strangers to make his perfect video game. When he gets bored of an idea, he murders them and moves on to the next, learning nothing in the process."
"Hmm... interesting."
I'd like to have a component in my interface that would be almost like JTree, except horizontal. Sort of. Actually JTree is my fall-back idea, but the ideal situation is a JList (or JTable?) in which rows can be grouped, and the grouping indicated by an editable label positioned to the side and center of the group. Sorry, I've looked around for something to illustrate this with but haven't found anything useful quickly.

And I'd dearly wish to preserve standard component functionality, instead of having to go up from textfields and labels. Is there a way?

Volguus
Mar 3, 2009

supermikhail posted:

I'd like to have a component in my interface that would be almost like JTree, except horizontal. Sort of. Actually JTree is my fall-back idea, but the ideal situation is a JList (or JTable?) in which rows can be grouped, and the grouping indicated by an editable label positioned to the side and center of the group. Sorry, I've looked around for something to illustrate this with but haven't found anything useful quickly.

And I'd dearly wish to preserve standard component functionality, instead of having to go up from textfields and labels. Is there a way?

Netbeans has a component like this. The netbeans platform that is. https://netbeans.org/features/platform/download.html

supermikhail
Nov 17, 2012


"It's video games, Scully."
Video games?"
"He enlists the help of strangers to make his perfect video game. When he gets bored of an idea, he murders them and moves on to the next, learning nothing in the process."
"Hmm... interesting."
Oh drat, I hope it works with eclipse projects well. Also, I guess it's good thing that I worked on saving window state manually. Also, maybe my Ubuntu computer has gotten better at handling Netbeans (or Netbeans takes less memory now).

Anyway, thanks.

Edit: Okay, what's it called and how do I get it?

supermikhail fucked around with this message at 16:13 on Aug 24, 2013

Defenestrategy
Oct 24, 2010

So I am taking a Java class this semester and the first project is to take user inputs, display them, and multiply them. When I try the method below, It'll do whole numbers fine, but it hates decimals spitting "java.lang.NumberFormatException" back at me. Any ideas?

code:
 String sold = JOptionPane.showInputDialog("How many sold?");
       String cost = JOptionPane.showInputDialog("How much did they cost each?");
       int y = Integer.parseInt(sold);
       int x = Integer.parseInt(cost);
       System.out.print(x*y);

lamentable dustman
Apr 13, 2007

🏆🏆🏆

Your answer is in your question. Think on this line

code:
int y = Integer.parseInt(sold);
And what NumberFormatException probably means.

Defenestrategy
Oct 24, 2010

lamentable dustman posted:

Your answer is in your question. Think on this line

code:
int y = Integer.parseInt(sold);
And what NumberFormatException probably means.

:psyduck: I forgot what an integer was. Can only use whole numbers. Is there a way to salvage this or should I scrap that and look for something else?

ulmont
Sep 15, 2010

IF I EVER MISS VOTING IN AN ELECTION (EVEN AMERICAN IDOL) ,OR HAVE UNPAID PARKING TICKETS, PLEASE TAKE AWAY MY FRANCHISE

KildarX posted:

:psyduck: I forgot what an integer was. Can only use whole numbers. Is there a way to salvage this or should I scrap that and look for something else?

You're not going to make it work with int x and int y, no, but check out Double.parseDouble.

...or java.text.DecimalFormat.parse, but Double.parseDouble is probably easier.

ulmont fucked around with this message at 19:04 on Aug 26, 2013

Defenestrategy
Oct 24, 2010

ulmont posted:

You're not going to make it work with int x and int y, no, but check out Double.parseDouble.


Thanks for the help man, works well.

Brain Candy
May 18, 2006

FYI, please never use doubles for money in a program that matters.

TheresaJayne
Jul 1, 2011
I know its not really Java but at the weekend i was looking to do some work with minecraftforge and create my own Mod,

I am an Intellij Idea girl and have purchased my own copy.
Could i get it working ? NO

Could i get help in getting it working in Idea? NO

The advice I got from the IRC support was Use Eclipse as we include a preconfigured Workspace

Why can't they be open and tell us how to get it working in ALL IDEs rather than just their favorite version, as I don't want the hassle of 3-4 IDEs on my system when I mainly use 1 .
(3-4 includes, Idea, Eclipse, Netbeans, JCreator(yes i bought this one as well))

Doctor w-rw-rw-
Jun 24, 2008

TheresaJayne posted:

I know its not really Java but at the weekend i was looking to do some work with minecraftforge and create my own Mod,

I am an Intellij Idea girl and have purchased my own copy.
Could i get it working ? NO

Could i get help in getting it working in Idea? NO

The advice I got from the IRC support was Use Eclipse as we include a preconfigured Workspace

Why can't they be open and tell us how to get it working in ALL IDEs rather than just their favorite version, as I don't want the hassle of 3-4 IDEs on my system when I mainly use 1 .
(3-4 includes, Idea, Eclipse, Netbeans, JCreator(yes i bought this one as well))
You asked:
https://www.youtube.com/watch?v=FecJUj6fq9I

Max Facetime
Apr 18, 2009

TheresaJayne posted:


Why can't they be open and tell us how to get it working in ALL IDEs rather than just their favorite version, as I don't want the hassle of 3-4 IDEs on my system when I mainly use 1 .
(3-4 includes, Idea, Eclipse, Netbeans, JCreator(yes i bought this one as well))

Could be for that very reason.

Luckily Eclipse can work completely standalone without having to install anything. Grab a zipped version, unzip it somewhere, copy jre-folder from your Java installation inside its folder, done.

HFX
Nov 29, 2004

Brain Candy posted:

FYI, please never use doubles for money in a program that matters.

I wish more people would get this through their heads. Just the other day, the senior developer on my team was saying I don't know why the currency values in a soap response were not being in \d*.\d{2} format. I pointed out that it was because he was using doubles and you never want to do currency in doubles. Starting to wonder who the real senior developer is....

TheresaJayne posted:

I know its not really Java but at the weekend i was looking to do some work with minecraftforge and create my own Mod,

I am an Intellij Idea girl and have purchased my own copy.
Could i get it working ? NO

Could i get help in getting it working in Idea? NO

The advice I got from the IRC support was Use Eclipse as we include a preconfigured Workspace

Why can't they be open and tell us how to get it working in ALL IDEs rather than just their favorite version, as I don't want the hassle of 3-4 IDEs on my system when I mainly use 1 .
(3-4 includes, Idea, Eclipse, Netbeans, JCreator(yes i bought this one as well))

Speaking as someone who has used multiple IDEs. It can be very hard for me to figure out how to make something work in a new IDE when I'm used to my current one. Being lazy as most programmers are, I will help someone work through getting stuff running on their IDE if I have a license or it is free, and I will appreciate them making a guide. However, I feel no need to help them.

Then again, in terms of Java, I tend to use maven for everything!

HFX fucked around with this message at 19:00 on Aug 27, 2013

Salynne
Oct 25, 2007

TheresaJayne posted:

I know its not really Java but at the weekend i was looking to do some work with minecraftforge and create my own Mod,

I am an Intellij Idea girl and have purchased my own copy.
Could i get it working ? NO

Could i get help in getting it working in Idea? NO

The advice I got from the IRC support was Use Eclipse as we include a preconfigured Workspace

Why can't they be open and tell us how to get it working in ALL IDEs rather than just their favorite version, as I don't want the hassle of 3-4 IDEs on my system when I mainly use 1 .
(3-4 includes, Idea, Eclipse, Netbeans, JCreator(yes i bought this one as well))

Come in #technicdev on synirc sometime and ask around. I'm going to PAX in a couple hours but next week I can be around to step you through it OR someone in the channel might be able to help you anyway. We have a bunch of modders in the channel.

Make sure you stick around and idle though because it's not active at all hours of the day but people will come back and read the logs and ping you/pm you responses.

TheresaJayne
Jul 1, 2011

General Olloth posted:

Come in #technicdev on synirc sometime and ask around. I'm going to PAX in a couple hours but next week I can be around to step you through it OR someone in the channel might be able to help you anyway. We have a bunch of modders in the channel.

Make sure you stick around and idle though because it's not active at all hours of the day but people will come back and read the logs and ping you/pm you responses.

Well i did the easy way and installed Eclipse, at some point i will work out the config and probably post a blog entry showing how to set it up on Idea.

supermikhail
Nov 17, 2012


"It's video games, Scully."
Video games?"
"He enlists the help of strangers to make his perfect video game. When he gets bored of an idea, he murders them and moves on to the next, learning nothing in the process."
"Hmm... interesting."
I'm trying to make it so I would type in a textfield, and get the key event, but without anything actually happening in the textfield, so I could set the text programmatically. My only lead thus far is the KeyEventDispatcher interface, but I'm not sure it's what I want, and even if it were I don't know how to connect it to the textfield. Any help?

Edit: Nevermind, Component's processKeyEvent works splendidly.

supermikhail fucked around with this message at 10:10 on Aug 30, 2013

Danny Glands
Jan 26, 2013

Possible thermal failure (CPU on fire?)
I'm having problems with a stupid little format called VLI, and it's driving me nuts. Here's the link to the so-called specification: http://rpg.hamsterrepublic.com/ohrrpgce/RELOAD#VLI_.28Variable_Length_Integer.29

and here's the code I'm trying to read it in with: http://code.google.com/p/hamsterwrench/source/browse/trunk/src/hamsterwrench/data/reload/ReloadDataManager.java#266

Amarkov
Jun 21, 2010
What precisely is the problem you're having? I'll take a look, but it's hard to debug "my code doesn't work!"

Danny Glands
Jan 26, 2013

Possible thermal failure (CPU on fire?)
I'll get a RELOAD test file uploaded soon. I think the problem lies in readVLI.

e: Here's the file I'm using: https://www.dropbox.com/s/ghzpjmsnh4kftfj/0.rsav
It's a valid RELOAD file since the OHRRPGCE opens it perfectly.

Danny Glands fucked around with this message at 03:58 on Aug 31, 2013

Amarkov
Jun 21, 2010
Okay, but what is the error? What are you trying to do that does not get done, and in what way does it fail?

Danny Glands
Jan 26, 2013

Possible thermal failure (CPU on fire?)
It misjudges node sizes, so that if it runs into a mis-sized node, it starts reading in garbage if the file pointer reads a valid nodetype (if it's a string it shows garbage in the System.out) and it's supposed to crash if the node type is higher than six. If you want a log file I'll gladly produce it.

Amarkov
Jun 21, 2010
No, that's enough information. You're right that the readVLI function is the problem; it's checking some random other value when it tries to check the continuation flag. The check needs to be on the raw byte, not the value after masking the flag and shifting by the current offset.

Danny Glands
Jan 26, 2013

Possible thermal failure (CPU on fire?)
The fix worked, thank you.

supermikhail
Nov 17, 2012


"It's video games, Scully."
Video games?"
"He enlists the help of strangers to make his perfect video game. When he gets bored of an idea, he murders them and moves on to the next, learning nothing in the process."
"Hmm... interesting."
I'm trying to cheat and highlight part of a JLabel with html, but having very sporadic luck so far (it doesn't help that my experience with html is almost non-existent). bgcolor sets what it says to what I want, but it needs a legitimate tag to go with, and everything I've tried newlines the rest of the text (at least <div> which shouldn't). Is there a non-violent solution to this?

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

I don't know specifically, but in html don't you usually use <span> for that?

supermikhail
Nov 17, 2012


"It's video games, Scully."
Video games?"
"He enlists the help of strangers to make his perfect video game. When he gets bored of an idea, he murders them and moves on to the next, learning nothing in the process."
"Hmm... interesting."
Dammit, that's taken some suffering. But thanks... I thought <div> did the same thing! :(

For anyone interested, what I did is

code:
if (s.contains(searchTerm)) {
	s = s.replaceAll(searchTerm, "<span bgcolor=#99CCFF>"
		+ searchTerm + "</span>");
	s = "<html>" + s + "</html>";
}
Edit: unbroke the table, plus it would be better to add <html> after replacing, I figure.

supermikhail fucked around with this message at 20:20 on Sep 2, 2013

Doghouse
Oct 22, 2004

I was playing Harvest Moon 64 with this kid who lived on my street and my cows were not doing well and I got so raged up and frustrated that my eyes welled up with tears and my friend was like are you crying dude. Are you crying because of the cows. I didn't understand the feeding mechanic.
Does anyone know of a video or series of videos that give a sort of "refresher course" on Java basics? I took a Java class a couple years ago and now I'm getting back into it, and I remember some things, but vaguely. I'd love something that is at more of a brisk pace because I'm not learning it for the first time.

Defenestrategy
Oct 24, 2010

So, I'm trying to figure out how to loop a program, and I can't figure it out. The purpose of the below bit of code is to ask for a number, return text based on the number and continue asking for inputs until someone inputs a negative number then it quits. I don't know how to, I guess, erase the previous string and use new inputs.


code:
import java.util.Scanner;


public class project
{
   public static void main(String[] args)
   {
      Scanner input = new Scanner( System.in );
       String z;        
       System.out.print("Enter a number between 1 and 100 to quit type a negative number: ");
                    z = input.next( );
          Double x = Double.parseDouble(z);
     while( x > 0)
    
 {
             

     if ( x > 0  && x < 59)
       System.out.print("you typed a number!");
       
       if ( x > 59 && x < 100)
       System. out.print("you typed another number");
       
       if (x < 0 )
       System.exit(1);
           
    }
    }
    }
       

Defenestrategy fucked around with this message at 21:37 on Sep 9, 2013

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

You can reassign a variable after it is created. z = input.next(); is valid even if z is already set to something else. After that statement, z will be set to the result of input.next(), which will be what the user input that time.

Think about how often you need to get input from the user compared to how often you check the value of that input in those if statements.

Also, it would probably help to clean that code up a bit:
Java code:
import java.util.Scanner;

public class project
{
    public static void main(String[] args)
    {
        Scanner input = new Scanner( System.in );
        String z;        
        System.out.print("Enter a number between 1 and 100 to quit type a negative number: ");
        z = input.next( );
       
        Double x = Double.parseDouble(z);
        while( x > 0)
        {
            if ( x > 0  && x < 59)
            {
                System.out.print("you typed a number!");
            }
       
            if ( x > 59 && x < 100)
            {
                System. out.print("you typed another number");
            }
            if (x < 0 )
            {
                System.exit(1);
            }
        }
    }
}
Tell me, where else in this code should you be asking for input (and converting it!), do you think?

carry on then fucked around with this message at 22:06 on Sep 9, 2013

Amarkov
Jun 21, 2010
e: :argh:

404notfound
Mar 5, 2006

stop staring at me

Hint: in the code you posted, you're only asking for input once

Defenestrategy
Oct 24, 2010

carry on then posted:

Tell me, where else in this code should you be asking for input (and converting it!), do you think?

Probably after the system.exit(1) and still within the while; if I do something like this:

code:
            
            if (x < 0 )
            {
            System.exit(1);
            }
            System.out.print("Enter a number between 1 and 100");
            z = input.next( );
The program uses the first input instead of the new input though.

404notfound
Mar 5, 2006

stop staring at me

Okay, so you'll ask for input for each iteration. But the raw input isn't what you're checking when determining what to do :eng101:

Defenestrategy
Oct 24, 2010

404notfound posted:

Okay, so you'll ask for input for each iteration. But the raw input isn't what you're checking when determining what to do :eng101:

:eng99: derp

code:
System.out.print("Enter a number between 1 and 100");
            z = input.next( );
            x = Double.parseDouble(z);
Thanks for all your collective help.

Zeether
Aug 26, 2011

I have a problem with trying to sort a group of three integers input from a text file from smallest to largest. I know of a function to do exactly that, Arrays.sort(), but it will just print out memory addresses and not the three integers.

For example, my text file would start with a Scanner "sc" that reads in a text file starting with 3 numbers, x, y, and z, and the code is this:

code:
int x = sc.nextInt();
int y = sc.nextInt();
int z = sc.nextInt();
		
int[]sortingArray = new int [3];
x = sortingArray[0];
y = sortingArray[1];
z = sortingArray[2];
		
Arrays.sort(sortingArray);
System.out.print(sortingArray[0] + " " + sortingArray[1] + " " + sortingArray[2]);
But when I run it, it doesn't print the three numbers, just three zeroes. Do I need to add a for loop?

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

= makes the left hand side take the value of the right hand side. which of x or sortingArray[0] gets the value from the scanner?

Posting Principle
Dec 10, 2011

by Ralp
Your assignments are backwards.

x = sortingArray[0] should be sortingArray[0] = x

404notfound
Mar 5, 2006

stop staring at me

KildarX posted:

Thanks for all your collective help.

One more thing you can do to clean up the code. I'm assuming you fixed the code by asking for input both before the while loop and also within the loop at the end. While this works, duplicating code is generally frowned upon. You can get by with using just one copy of the input code by putting it inside the loop at the beginning, and then changing from while to do-while.

Java code:
public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	String z;
	Double x;
	do {
		System.out.print("Enter a number between 1 and 100 to quit type a negative number: ");
		z = input.next();
		x = Double.parseDouble(z);

		if (x > 0 && x < 59)
			System.out.print("you typed a number!\n");

		if (x > 59 && x < 100)
			System.out.print("you typed another number\n");

		if (x < 0)
			System.exit(1);
	} while (x > 0);
}
Do-while is the same thing as while, but the condition is checked at the end of the loop rather than the beginning. If you tried this with a regular while loop, it would complain about x not being initialized yet. For more info: http://en.wikipedia.org/wiki/Do_while_loop

404notfound fucked around with this message at 22:49 on Sep 9, 2013

Adbot
ADBOT LOVES YOU

Zeether
Aug 26, 2011

Posting Principle posted:

Your assignments are backwards.

x = sortingArray[0] should be sortingArray[0] = x
That fixed it, thanks! I was initially using a bunch of crazy if-else logic to sort which confused me, and I guess I should have checked the docs for a sorting function.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply