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
baquerd
Jul 2, 2007

by FactsAreUseless

Jo posted:

This is from HOLDING the 's' key. Why would multiple key events be generated from a single key hold?

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4504217

Edit: To clarify, basically you can't depend on the events reflecting an accurate state of the keyboard. Rather, record the key presses on a timer and set the state of movement accordingly. That way you standardize performance across all platforms.

baquerd fucked around with this message at 09:15 on Nov 12, 2010

Adbot
ADBOT LOVES YOU

Jo
Jan 24, 2005

:allears:
Soiled Meat

Oh. Thanks!

EDIT: Turns out there's a better way to do this. KeyBindings is the Swing equivalent of KeyListener.

Jo fucked around with this message at 01:02 on Nov 14, 2010

mcw
Jul 28, 2005
Hey, can we talk about web services?

Java offers a ludicrous number of options for developing and deploying web services, and I'm curious as to how you guys usually do it, and why. For example, I'm trying to dip my toes into web services by developing some RESTful methods in JAX-RS using Jersey, and I'd hate to spend several days mastering this only to learn that most Java shops use SOAP services instead.

Chairman Steve
Mar 9, 2007
Whiter than sour cream
My work uses RESTful URLs. Our requests are fairly simple, so I would think that, if you have extremely complex requests (which can only be simplified otherwise by maintaining state on the server), you might want to go with SOAP. My general sentiment is that, more times than not, most anything that is currently accomplished in SOAP can be done with RESTful URLs, and those are typically very much easier to consume.

mcw
Jul 28, 2005

Chairman Steve posted:

My work uses RESTful URLs. Our requests are fairly simple, so I would think that, if you have extremely complex requests (which can only be simplified otherwise by maintaining state on the server), you might want to go with SOAP. My general sentiment is that, more times than not, most anything that is currently accomplished in SOAP can be done with RESTful URLs, and those are typically very much easier to consume.

Based on the learning I've done thus far on this subject, I think I'd agree with you. Even for web services where I'll be using XSDs, RESTful services should do the job nicely, and more intuitively to boot. Then again, I haven't yet researched the advantages of SOAP in regards to security, which is where I'd really have an uphill battle at work...

Jo
Jan 24, 2005

:allears:
Soiled Meat
As a start, I'd like to apologize for spamming requests to help to this thread without really contributing. Thank you to all those who have provided feedback to my inane problems.

The most recent issue, a change from the AWT method of input to the Swing method of input, has left me daft. The following code does not work for reasons I can't explain.

code:
		JPanel content = (JPanel)engine.gfxman.getContentPane();
		InputMap map = content.getInputMap( javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW ); // Tried all three JComponent options, when focused, when in focused window, etc...
		ActionMap action = content.getActionMap();

		Action keyDownRight = new AbstractAction() {
			public void actionPerformed(ActionEvent e) {
				System.out.println( "HURF DURF D!" );
			}
		};

		map.put( KeyStroke.getKeyStroke("d"), "keyDownRight" ); // pressed d, d, and d pressed have no effect.
		action.put( "keyDownRight", keyDownRight );

Paolomania
Apr 26, 2006

I may be wrong, but I think that content panes, not being input widgets, never get input focus.

edit: I think that input map is for things like text boxes so you can do things like automatically updating a search as you type, etc.

Jo
Jan 24, 2005

:allears:
Soiled Meat

Paolomania posted:

I may be wrong, but I think that content panes, not being input widgets, never get input focus.

edit: I think that input map is for things like text boxes so you can do things like automatically updating a search as you type, etc.

Ah. Okay. Thanks. :smith:

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa
I need a Web UI framework suggestion:

I need to develop an UI which is built from portlets (nonono, not those Portlets but, you know, similar), basically bunch of boxes showing content streams. What I've found out that I like either strict templating (GSP in Grails) or full-blown component oriented design with clear separation of markup and code (Apache Wicket) but I don't neither of those are applicable here exactly: If I were to build the UI part in Grails, I would have to create a whole layer of integration to code I already have and if I were to use Wicket, the actual dynamic amount of portlets and such would be a relative pain (been there, done that).

So, what would you suggest as an intermediary? Note that I specifically do NOT want a RIA application, which should be read as "no GWT, thank you".

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Parantumaton posted:

I need a Web UI framework suggestion:

I need to develop an UI which is built from portlets (nonono, not those Portlets but, you know, similar), basically bunch of boxes showing content streams. What I've found out that I like either strict templating (GSP in Grails) or full-blown component oriented design with clear separation of markup and code (Apache Wicket) but I don't neither of those are applicable here exactly: If I were to build the UI part in Grails, I would have to create a whole layer of integration to code I already have and if I were to use Wicket, the actual dynamic amount of portlets and such would be a relative pain (been there, done that).

So, what would you suggest as an intermediary? Note that I specifically do NOT want a RIA application, which should be read as "no GWT, thank you".

Can you be more clear about what you mean by "a whole layer of integration" if you went with Grails? What does your current code base do exactly?

Chairman Steve
Mar 9, 2007
Whiter than sour cream

MariusMcG posted:

Based on the learning I've done thus far on this subject, I think I'd agree with you. Even for web services where I'll be using XSDs, RESTful services should do the job nicely, and more intuitively to boot. Then again, I haven't yet researched the advantages of SOAP in regards to security, which is where I'd really have an uphill battle at work...

I'd say keep authentication and authorization separate from the API's language. Use something like OpenID to authenticate (which opens you up to allowing people to log in using things like their GMail account) and OAuth to authorize users. Otherwise, you'll have to deal with things like sharing of keys to encrypt the SOAP request, which would probably contain your username and password, when it's sent from the client to the server.

Stealthgerbil
Dec 16, 2004


Is there a good way to add a lot of buttons and link them with an actionlistener? I need to make a calculator for my class and I find that my code is just painful to look at. Since I have like 16 buttons and I have to create them and then add them to the panel and then link all of the actionlisteners, my code is looking kind of ugly. I tried setting up an array of buttons which would use a for loop to go through the array and create the buttons but I kept getting a null pointer error :(

chippy
Aug 16, 2006

OK I DON'T GET IT

Stealthgerbil posted:

Is there a good way to add a lot of buttons and link them with an actionlistener? I need to make a calculator for my class and I find that my code is just painful to look at. Since I have like 16 buttons and I have to create them and then add them to the panel and then link all of the actionlisteners, my code is looking kind of ugly. I tried setting up an array of buttons which would use a for loop to go through the array and create the buttons but I kept getting a null pointer error :(

If I've got to create a lot of buttons or something for a UI I sometimes use a helper class to actually build them and then pass them to the main UI class, keeps things a little cleaner.

If you've got them in an array you should be able to add your actionlister to all of like this:

code:
for (Button button : buttons) {
    button.setOnClickListener(whateverYourListenerIs)
    }
With Android though you can also use an XML layout and assign methods to a be called when a button is clicked like this:

code:
 <Button
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:text="@string/self_destruct"
     android:onClick="selfDestruct" />
If that makes life any easier.

chippy fucked around with this message at 01:52 on Nov 17, 2010

chippy
Aug 16, 2006

OK I DON'T GET IT
p.s.

code:
for (Button button : buttons) {
is equivalent to

code:
for (int i = 0; i < buttons.length; i++) { 
    Button button = buttons[i];
You probably know that but it threw me the first time I saw it so I just thought I'd mention it.

Outlaw Programmer
Jan 1, 2008
Will Code For Food
I suspect you got the NullPointerException because you created an array of Button objects, but didn't actually create the buttons themselves:

code:
JButton[] buttons = new JButton[10];

if(buttons[0] == null)
    System.out.println("I'm null right now!");  // this will print out
In your case, you might want:

code:
JButton[] buttons = new JButton[10]; // create array only
for(int i = 0; i < buttons.length; i++)
{
    JButton button = new JButton(String.valueOf(num)); // create actual button
    button.addActionListener(new ActionListener()
    {
        public void actionPerformed(ActionEvent evt)
        {
            calculatorState.push(num); // not sure what your logic is
        }
    }
    
    buttons[i] = button;
}
Note that the 'new' keyword appears twice, once to create the array, and once to instantiate the button objects themselves. You can think of arrays as objects that contain other objects.

chippy
Aug 16, 2006

OK I DON'T GET IT

Outlaw Programmer posted:


code:
JButton[] buttons = new JButton[10]; // create array only
for(int i = 0; i < buttons.length; i++)
{
    JButton button = new JButton(String.valueOf(num)); // create actual button
    button.addActionListener(new ActionListener()
    {
        public void actionPerformed(ActionEvent evt)
        {
            calculatorState.push(num); // not sure what your logic is
        }
    }
    
    buttons[i] = button;
}

Is it good form to create actionPerformed(ActionEvent evt) like this? i.e. within the same code that creates the button. I know there are multiple ways of doing it like creating a seperate class to be your actionListener or defining the methods in your UI class, and this always seems like the messiest way of doing it to me.

Although I guess this way you can define a different actionPerformed method for each button. I usually have them all call the same method and then have that method examine ActionEvent to work out where it came from and what to do.

ShardPhoenix
Jun 15, 2001

Pickle: Inspected.

chippy posted:

Is it good form to create actionPerformed(ActionEvent evt) like this? i.e. within the same code that creates the button. I know there are multiple ways of doing it like creating a seperate class to be your actionListener or defining the methods in your UI class, and this always seems like the messiest way of doing it to me.
Using an anonymous inner class like this is best way if you're just want a simple listener. Unfortunately Java makes this uglier than it needs to be.

Parantumaton
Jan 29, 2009


The OnLy ThInG
i LoVe MoRe
ThAn ChUgGiNg SeMeN
iS gEtTiNg PaId To Be A
sOcIaL MeDiA sHiLl
FoR mIcRoSoFt
AnD nOkIa

TRex EaterofCars posted:

Can you be more clear about what you mean by "a whole layer of integration" if you went with Grails? What does your current code base do exactly?

First: Sorry for phasing out for a couple of days, I was kinda busy.

Anyway, the app I have has just about everything home grown; there's a certain point for everything such as saving stuff and querying data in general and everything's wonderfully intertwined which makes it really hard to express the whole thing as a logical bunch of for example Grails Services (or Spring Beans or whatever). Even if it could be expressed as such, I still need to be able to do all kinds of on-demand data updates which are not tied to, say, user session which rules Wicket out quite quickly due to its Ajax implementation.

Anyway, what I need the UI framework to do is to provide me with a good way to integrate 100% custom Ajax with the JS library of my choice (that'd be jQuery) while still managing the tedious stuff such as repeaters and initial states for me. I have been thinking that I may need to go "full Ajax" here but that would mean that all those without JS enabled would be left out of the UI goodness.

Hopefully this at least somewhat helps you.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Parantumaton posted:

First: Sorry for phasing out for a couple of days, I was kinda busy.

Anyway, the app I have has just about everything home grown; there's a certain point for everything such as saving stuff and querying data in general and everything's wonderfully intertwined which makes it really hard to express the whole thing as a logical bunch of for example Grails Services (or Spring Beans or whatever). Even if it could be expressed as such, I still need to be able to do all kinds of on-demand data updates which are not tied to, say, user session which rules Wicket out quite quickly due to its Ajax implementation.

Anyway, what I need the UI framework to do is to provide me with a good way to integrate 100% custom Ajax with the JS library of my choice (that'd be jQuery) while still managing the tedious stuff such as repeaters and initial states for me. I have been thinking that I may need to go "full Ajax" here but that would mean that all those without JS enabled would be left out of the UI goodness.

Hopefully this at least somewhat helps you.

I honestly don't know of anything for the UI that would be able to just do all that work for you, while being all AJAX cool and everything. Grails has scaffolding that would set up a lot of the minutiae for you, but you'd still have to customize it. If you find something that will just "take" your classes and make easily extendable poo poo for you please let me know cause I would certainly use it.

But for the back end, would you be able to expose your home-grown application as a set of webservices (whether REST or SOAP or whatever) and then write a smaller, front-end-oriented application? I've done this before and it worked really well, you basically treat the legacy application as a black box database and query it via the webservices on-demand. In fact, in grails I would probably just write a plugin to autoinject the webservice CRUD garbage into a set of classes like the domain classes get with hibernate.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
Is Java the right choice for a cross platform desktop application these days?

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
fletcher: Who is your target audience? What kind of UI experience are you working with?

Minecraft is a pretty good example of a popular desktop application written in Java and released for OSX, Windows and Linux. At the same time, it does not attempt to match the look and feel of any of these operating systems.

Will your users already have the Java runtime installed? I know that OSX comes bundled with Java, but I don't think Windows does. On Linux I've noticed most distributions seem to run IcedTea by default, which is pretty flaky in my experience. If you plan to offer a Linux release, I'd recommend testing against this configuration.

Finally, if you're using the Java 2D graphics infrastructure for anything, be aware that the performance of implementations varies.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Internet Janitor posted:

fletcher: Who is your target audience? What kind of UI experience are you working with?

Minecraft is a pretty good example of a popular desktop application written in Java and released for OSX, Windows and Linux. At the same time, it does not attempt to match the look and feel of any of these operating systems.

Will your users already have the Java runtime installed? I know that OSX comes bundled with Java, but I don't think Windows does. On Linux I've noticed most distributions seem to run IcedTea by default, which is pretty flaky in my experience. If you plan to offer a Linux release, I'd recommend testing against this configuration.

Finally, if you're using the Java 2D graphics infrastructure for anything, be aware that the performance of implementations varies.

I want to write a simple database schema browser/query utility. The only one that currently exists for the database I'm using is an old Windows Forms application and it is absolutely terrible in terms of UI and functionality.

I'd like for it to match the look and feel of whatever OS the user is in, but it's not an absolute necessity. I'm not really interested in making it look fancy, I just want it to be as simple as possible. I won't be using any of the Java 2D stuff.

I'm guessing that if people don't already have the Java runtime installed their hatred of the existing application will make that an easy decision.

fletcher fucked around with this message at 00:25 on Nov 18, 2010

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

fletcher posted:

I want to write a simple database schema browser/query utility. The only one that currently exists for the database I'm using is an old Windows Forms application and it is absolutely terrible in terms of UI and functionality.

I'd like for it to match the look and feel of whatever OS the user is in, but it's not an absolute necessity. I'm not really interested in making it look fancy, I just want it to be as simple as possible. I won't be using any of the Java 2D stuff.

I'm guessing that if people don't already have the Java runtime installed their hatred of the existing application will make that an easy decision.

http://www.dbvis.com/

maskenfreiheit
Dec 30, 2004
Edit: Double Post

maskenfreiheit fucked around with this message at 21:32 on Mar 13, 2017

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

TRex EaterofCars posted:

http://www.dbvis.com/

Haven't seen that before, thanks for the link. Seems to be overkill of what I want though, and it doesn't support the database I'm using. I don't even want it to be able to edit the schema. I just need to be able to view what tables and fields exist, run queries, and export the output as a csv.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

fletcher posted:

Haven't seen that before, thanks for the link. Seems to be overkill of what I want though, and it doesn't support the database I'm using. I don't even want it to be able to edit the schema. I just need to be able to view what tables and fields exist, run queries, and export the output as a csv.

It'll support any database with a JDBC driver... If you were even considering targeting Java you should make sure there's a JDBC driver available for your database before you get much further.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

TRex EaterofCars posted:

It'll support any database with a JDBC driver... If you were even considering targeting Java you should make sure there's a JDBC driver available for your database before you get much further.

Interaction with the database is all done through SOAP, the underlying database is not exposed directly. They provide a Java library that I'm pretty comfortable using, which is one of the main reasons I was considering Java in the first place. I've already got a little prototype app that displays the schema and lets me execute queries, I'm just wondering if there's any other platforms I should consider doing this in before I invest more time in the Java route.

Shavnir
Apr 5, 2005

A MAN'S DREAM CAN NEVER DIE

GregNorc posted:

what's a good IDE that will let me drag and drop JButtons etc to rapid prototype UIs?

Eclipse + VisualSwing4Eclipse or NetBeans.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
fletcher: Based on your description, sounds like Java will do just about exactly what you want. More power to ya.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Internet Janitor posted:

fletcher: Based on your description, sounds like Java will do just about exactly what you want. More power to ya.

Should I be concerned that Swing is no longer actively developed? Should I not be using it? How about the SwingLabs stuff? Or Better Swing Application Framework?

fletcher fucked around with this message at 21:48 on Nov 18, 2010

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
Spring is a web framework, and Swing will be supported for a long time to come. The SwingLabs has some cool stuff that you can use, but I don't see too many people using it in the future for any serious desktop applications.

Java FX was supposed to be this awesome thing that would save desktop Java applications but that didn't pan out. My opinion is that Java desktop applications are dead, and if not that at least a second class citizen on the platform.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

MEAT TREAT posted:

Spring is a web framework, and Swing will be supported for a long time to come. The SwingLabs has some cool stuff that you can use, but I don't see too many people using it in the future for any serious desktop applications.

Java FX was supposed to be this awesome thing that would save desktop Java applications but that didn't pan out. My opinion is that Java desktop applications are dead, and if not that at least a second class citizen on the platform.

Whoops, I meant to say Better Swing Application Framework.

Googling around and reading message boards about it I get the same feeling that it is dead/dying.

Walked
Apr 14, 2003

Can someone help me out with Java versioning?

I'm on a DoD network; both 5.0 update 22 and 6.0 update 20 are deployed enterprise-wide.

Unofortuantely; Java 5.0 is no longer listed as secure, and as such requires either:
- Update 26
- Removal across all hosts

We dont have a Java for business contract; however administrative removal is simple.

Its 6.0 backwards compatable with 5.0 Java applications? This page:
http://www.oracle.com/technetwork/java/javase/compatibility-137541.html
Is a bit unclear to me.

Can anyone tell me whether removing 5.0 and ensuring 6.0 is installed would be viable? I'm sure it at least partially depends on the applications - but before I dig, and audit all our hosts and determine what applications are running it, I want to be sure I'm not wasting shitloads of time, when I'm just going to need my higher-ups to purchase the support contract..

rjmccall
Sep 7, 2007

no worries friend
Fun Shoe
Well, you should never upgrade JVMs without rigorous testing, but in general it should work.

Walked
Apr 14, 2003

rjmccall posted:

Well, you should never upgrade JVMs without rigorous testing, but in general it should work.

Tight deadline; security requirement for DoD compliance. Very tight schedule. Otherwise I 100% completely agree.

trex eaterofcadrs
Jun 17, 2005
My lack of understanding is only exceeded by my lack of concern.

Walked posted:

Tight deadline; security requirement for DoD compliance. Very tight schedule. Otherwise I 100% completely agree.

Are you going to compile new code or just run stuff on a new JVM? That'll determine how much bullshit you will have to go through.

Jewbert Jewstein
Dec 4, 2007

Bring me a hard copy of the Internet so I can do some serious surfing
I had finally finished this program that I was writing for work, but my boss wanted me to upload it under a different name than what I had called it originally (ie- adding an "_2"). Ever since doing that this red exclamation mark won't go away and any changes that I make to the code don't get made whenever I compile and test it. I'm working in Eclipse on a Vaadin project titled "AddressSearch_2".

Can any goons tell me how to fix this?

ninja edit: Black bars are covering my company's name. Ignore them.

Kilson
Jan 16, 2003

I EAT LITTLE CHILDREN FOR BREAKFAST !!11!!1!!!!111!

Jewbert Jewstein posted:

I had finally finished this program that I was writing for work, but my boss wanted me to upload it under a different name than what I had called it originally (ie- adding an "_2"). Ever since doing that this red exclamation mark won't go away and any changes that I make to the code don't get made whenever I compile and test it. I'm working in Eclipse on a Vaadin project titled "AddressSearch_2".

Can any goons tell me how to fix this?

ninja edit: Black bars are covering my company's name. Ignore them.

I have the same problem occasionally in Netbeans. The way to fix it there is to delete the cache folder where it stores all the information about source files and restart. When it restarts, it will have to rebuild the cache, and the issue should go away. I would guess there's a similar procedure you can follow for Eclipse.

Malloc Voidstar
May 7, 2007

Fuck the cowboys. Unf. Fuck em hard.

Jewbert Jewstein posted:

Can any goons tell me how to fix this?
Is there anything listed in the Problems tab?

Adbot
ADBOT LOVES YOU

D0nk3y_
Jan 27, 2004
Eee-Ore

Jewbert Jewstein posted:

Can any goons tell me how to fix this?

Try cleaning the project and rebuild it. Eclipse's autobuild can do funny things.

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