Nate Lockwood

Ranch Hand
+ Follow
since Feb 22, 2010
Merit badge: grant badges
Learned Fortran in 1975 followed by Basic, Pascal, C and C++.  Have been programing part of the time in C/C++ mostly for Windows developing aps and tools to extract, modify, display scientific data mostly images from specialized IR airborne cameras.  Manage an aircraft and do a LOT of paperwork. Need to learn and use Java on a new project but using Ubuntu Linux.
For More
Riverside, CA
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Nate Lockwood

Put each component in a cell. It appears that you have two rows of 10 or so cells. Here's what I did to line up some buttons.

The above example creates three rows each with two buttons and is grouped by the row. You can specify the width with "width 50:50:50" etc.
(Now if I could figure out why, in a different app, a row of buttons does not center vertically in the container...)
9 years ago
I'm sorry to say it does nothing, even after I tried a few variations.

Thanks for your reply, though!

9 years ago
I have a JPanel that goes across my application something like a status bar. In the panel I have 3 pairs of components a JLabel and a JTextField. I also have a JButton which I want to position near the far right or east in the jPanel.
I've tried several criteria for the Mig layout when adding the btnStartPause to the JPanel but it always is close to the component on its left. I use Java7 EE, with Eclipse Keppler and Builder on Ubuntu 12.04 but the Mig layout is done by hand.

Any suggestions would be most welcome ....
9 years ago
Thanks both. Using a caret listener was not appropriate for what I wanted but I did learn from reading the tutorial.

I replaced the JTextArea with a JList and have it working just as I wanted.

This little app will be used by only one person for a short while but other parts of it will be honed and used in the main app I am developing. In this case I don't need keyboard input, but thanks for the reminder.
9 years ago
I have a JPanel with a small JTextArea that displays text bounded by newlines, ie, it looks to the use like a list of short, non-wrapping, Strings. When a line is double clicked the text in the line is selected and highlighted. What action listener can I use to detect this double click? In this context the line would be detected and copied to a JTextField for possible editting,

9 years ago
Thanks, the wrong Point was imported. Should have been the AWT Point.

9 years ago
Over a year ago I wrote a small application to be able to view data we collect from a specialized camera and display it as a discrete image. Last week I attempted to reuse some of the code in a new demonstratin application to collect image data from the camera and display the images sequentially as collected; kind of like a very, very, slow video at a rate of about 1 Hz (and to integrate camera controls in the GUI).

The original code works using Eclipse Juno as the IDE and Oracle Jav 7 SE. I copied a method to another computer which has Eclipse Kepler and Oracle Java 7 EE. Eclipse reports an error and I've not been able to figure out how to fix it using Google etc.

Eclipse gives the error as:
"The method createWritableRaster(SampleModel, DataBuffer, Point) in the type Raster is not applicable for the arguments (ComponentSampleModel, DataBufferUShort, Point)"

The data in shortData are a single band of raw 16 bit monochrome image data (just as received from the camera).

9 years ago
I just completed the GWT tutorial StockWatcher on my Ubuntu 12.04 machine using the IDE Eclipse.

The second part of the tutorial implements an asynchronous call back but what I want to do is move the timer to the server side to make it completely asynchronous. But I don't quite see the way to do this.

Will I need to start a thread on the server side for the timer?. I'm pretty much a novice at web pages, css, and servers.



9 years ago
I don't understand this layout but an certain that if I have several rows each with two JComponents that the code should be regular, too. But it was not. If I try to align the left edges of the left components in the first row it won't work for many of them. Same for aligning the top edges. This causes some problems although it displays correctly on the development machine (LINUX) but it fails to display correctly on OSX and it affects sizing of the enclosing container.

I especially don't understand the lines 2 though 5. It appears to me to be too many groups. And this is code that I've edited that was far worse.


I come from a long experience with Borland C/C++ and Delphi where the WYSIWYG editor works well so it was a shock to find that Java had layout managers which I needed to learn as well as Java to get a Frame to display correctly. I've hand edited the layout created by WindowBuilder for some of my containters and have more to go. It's tedious and the kind of work a computer should be doing IMHO. It's also strange that when I display the form, then look at the Design and then back to the code I find that it may have been changed for reasons that I don't understand.

I'll see if the GUI displays correctly on OSX when I'm finished.

10 years ago
I've been trying to design a more or less working model of a GUI so that I can discuss what's needed, not needed, and other changes to be made with the primary user. I've been using WindowBuilder and am frustrated as the code it generated is often muddled. I've been able to clean up much of it without a complete understanding of it and hope that someone who understands the "cleaned up" code will comment on it. It appears to display correctly now on this LINUX Ubuntu development machine but before I worked to attempt to clean it up I ran it on OSX where it failed.

This is used to layout a panel with a single JLabel, "alt-Commands" near the top, followed by pairs of JLabels all more or less centered in the panel. This is a kind of menu to show key combinations that do things. It looks something like this (I see by the preview that Java Ranch abhors consecutive spaces):

10 years ago
I have the code below that I want to be triggered when the popup menu disappears but it is not triggered.

What is the correct action listener to detect the menu disappearing or not being shown or being hidden or ...?
10 years ago
Thanks, Rob and Paul, my use of runtime() is up to mediocre!

I have code that works - except - I'd like to get a string back from the process to display difference it time that was found if the sync works and the error message if it doesn't I couldn't follow all from the Oracle reference. Here's what I'm using now. (edit: a couple of typos)

10 years ago
When the user clicks on a particular component on my GUI a listener dispatches the code below which, in turn, executes a method that creates a system process to update the computer clock with network time servers.

LinxSUSO.syncClockDebug() contains this code (and more of course) and the command it runs is "sudo /usr/sbin/ntpdate":

My problem that the first comment written to the log (JTextArea) is not written until LinuxSUDO.syncClockDebug(); returns and it doesn't return until the the Process p completes. In the development environment this takes about 10 seconds but the user has no feedback that the mouse click worked - and that violates one of my top principles of user interactions; always provide feedback.

How can I get the JTextArea to update immediately after the comment is wrtten to it?

10 years ago

Paul Clapham wrote:Were you under the impression that the name of a variable which contains a reference to an object is automatically the name of that object?

No. Objects don't have names. Variables do have names, but you can't get those names by looking at objects to which the variables happen to refer at the current time.

I guess I did. I can retrive other characteristics of the object pointed to by jtf so I thought "why not the name", especially as there is a getName() method (and so many others). Now I see that it is not possible but for my immediate purpose it's just fine. I would have had to parse the name since I have several JTextFields with similar names but all I want is the sub strings "SensorA", "SensorB", etc.. I'll just name them.

10 years ago