Is there a way to know if a Java program was started from the command line or from a jar file?

The straight forward answer is that you cannot tell how the JVM was launched. But for the example use-case in your question, you don’t really need to know how the JVM was launched. What you really need to know is whether the user will see a message written to the console. And the way to … Read more

WPF DataGrid: CommandBinding to a double click instead of using Events

No need for attached behaviors or custom DataGrid subclasses here. In your DataGrid, bind ItemsSource to an ICollectionView. The trick here is to set IsSynchronizedWithCurrentItem=”True” which means the selected row will be the current item. The second part of the trick is to bind CommandParameter to the current item with the forward slash syntax. When … Read more

Double click listener on JTable in Java

Try this: mytable.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent mouseEvent) { JTable table =(JTable) mouseEvent.getSource(); Point point = mouseEvent.getPoint(); int row = table.rowAtPoint(point); if (mouseEvent.getClickCount() == 2 && table.getSelectedRow() != -1) { // your valueChanged overridden method } } });

How to stop highlighting of a div element when double-clicking

The CSS below stops users from being able to select text. Live example: http://jsfiddle.net/hGTwu/20/ /* If you want to implement it in very old browser-versions */ -webkit-user-select: none; /* Chrome/Safari */ -moz-user-select: none; /* Firefox */ -ms-user-select: none; /* IE10+ */ /* The rule below is not implemented in browsers yet */ -o-user-select: none; /* … Read more

Need to cancel click/mouseup events when double-click event detected

This is a good question, and I actually don’t think it can be done easily. (Some discussion on this) If it is super duper important for you to have this functionality, you could hack it like so: function singleClick(e) { // do something, “this” will be the DOM element } function doubleClick(e) { // do … Read more

Javafx 2 click and double click

Yes you can detect single, double even multiple clicks: myNode.setOnMouseClicked(new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if(mouseEvent.getButton().equals(MouseButton.PRIMARY)){ if(mouseEvent.getClickCount() == 2){ System.out.println(“Double clicked”); } } } }); MouseButton.PRIMARY is used to determine if the left (commonly) mouse button is triggered the event. Read the api of getClickCount() to conclude that there maybe multiple click … Read more