Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Jerry Stuckle Newsgroups: comp.lang.java.programmer Subject: Re: Returning to Java - have questions Date: Thu, 22 Jan 2015 21:47:29 -0500 Organization: A noiseless patient Spider Lines: 139 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Fri, 23 Jan 2015 02:46:59 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="3088393e34bc61b3e6a923d0c81ae1e3"; logging-data="4450"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199kzL6piatOZ0gwt7+6q50ScAohQSM0w8=" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 In-Reply-To: Cancel-Lock: sha1:KsIPLAREIoN9zWU1lbiubw62A24= Xref: csiph.com comp.lang.java.programmer:30810 On 1/22/2015 9:18 PM, Jeff Higgins wrote: > On 01/22/2015 08:59 PM, Jerry Stuckle wrote: >> On 1/22/2015 8:06 PM, Jeff Higgins wrote: >>> On 01/22/2015 11:11 AM, Jerry Stuckle wrote: >>>> On 1/22/2015 9:41 AM, Jeff Higgins wrote: >>>>> On 01/22/2015 09:07 AM, Jerry Stuckle wrote: >>>>>> On 1/22/2015 6:48 AM, Jeff Higgins wrote: >>>>>>> On 01/21/2015 11:06 PM, Jerry Stuckle wrote: >>>>>>>> Hi, all >>>>>>>> >>>>>>>> Well, I'm just getting back into java after about a 15 year >>>>>>>> hiatus. I >>>>>>>> did a bunch of it back then, both SE and EE, but then got off on >>>>>>>> other >>>>>>>> projects. >>>>>>>> >>>>>>>> Now I want to get my fingers back into it and see massive changes. >>>>>>>> It's >>>>>>>> going to take a log of getting used to. >>>>>>>> >>>>>>>> For instance, I was looking at a game I wrote back then (nothing >>>>>>>> fancy - >>>>>>>> just something to play with). With Swing it's very easy to change >>>>>>>> the >>>>>>>> look of buttons by loading a new image, i.d. when the player >>>>>>>> presses >>>>>>>> the >>>>>>>> button. It seems with fx the only way you can change the button >>>>>>>> when >>>>>>>> it's pressed/not pressed is via css. While I guess there are >>>>>>>> advantages >>>>>>>> to doing it this way, I haven't seen them yet. And I'd rather be >>>>>>>> able >>>>>>>> to control the button looks myself. >>>>>>> >>>>>>> extend SkinBase >>>>>>> and use Control.setSkin(Skin value) >>>>>>> >>>>>> >>>>>> Actually, I don't need to extend anything to set a static image - >>>>>> I can >>>>>> just use setImage() and not have any text. >>>>>> >>>>>> But that doesn't tell me if the button is pressed or not, so I don't >>>>>> know when to change the image to the pressed one. >>>>>> >>>>> I'm afraid your question is not clear to me. >>>>> Are BaseButtons's armedProperty, and onActionProperty, somehow >>>>> insufficient? >>>>> Maybe one of Node's many properties. >>>>> onKey..., onMouse..., onSwipe..., onTouch..., etc. >>>>> >>>> >>>> Armed is not the same as pressed. >>> That's right. >>> And the button being pressed does not >>>> necessarily indicate an action. >>> ?? >>> Do you want a ToggleButton? >> >> No, I want a button. >> >> For a button, the action occurs on the RELEASE of the button, not the >> push. For instance, if you place the mouse pointer over a button and >> hold down the LMB, the button will look pushed. If you then move the >> mouse pointer off the button before releasing the LMB, the button will >> return to normal state but an action will not occur. >> >> This action has been consistent since the first versions of Java (it is >> also consistent with every GUI I know of for at least 25 years). >> >>>> >>>> As for the properties - that would require polling all of the >>>> buttons in >>>> a loop to constantly follow their statuses. Not good. >>> ?? >>> >>> Is the standard event handling mechanism somehow insufficient? >>> >>> myBeautyousBtn.setOnAction(new EventHandler() { >>> @Override >>> public void handle(ActionEvent event) { >>> controlTheButtonLooksMyself(); >>> } >>> }); >>> >> >> That only gets triggered when an action occurs - which, as indicated >> above, is way too late. >> >>> or >>> >>> myBeautyousBtn.addEventHandler(MouseEvent.MOUSE_PRESSED, >>> new EventHandler() { >>> @Override >>> public void handle(MouseEvent e) { >>> controlTheButtonLooksMyself(); >>> } >>> }); >>> >> >> And a mouse is not the only way the button can be pressed. It can be >> via the space bar on the keyboard if the button has the focus, for >> instance. >> > public class Button > extends ButtonBase > > A simple button control. The button control can contain text and/or a > graphic. A button control has three different modes > > Normal: A normal push button. > Default: A default Button is the button that receives a keyboard > VK_ENTER press, if no other node in the scene consumes it. > Cancel: A Cancel Button is the button that receives a keyboard > VK_ESC press, if no other node in the scene consumes it. > > When a button is pressed and released a ActionEvent is sent. Your > application can perform some action based on this event by implementing > an EventHandler to process the ActionEvent. Buttons can also respond to > mouse events by implementing an EventHandler to process the MouseEvent > > MnemonicParsing is enabled by default for Button. > > Either I'm missing something or you are. > Good luck. > > > > Which has nothing to do with the look of a button when it is pushed. -- ================== Remove the "x" from my email address Jerry Stuckle jstucklex@attglobal.net ==================