Rice University logo
 
Top blue bar image
Computer Scientist at the Department of BioSciences, Rice University
 

Archive for October, 2012


Java dialog for yes-no question

October 12th, 2012 by Boanerges Aleman-Meza

Java Dialog for giving user option of YES/NO in a GUI, the default is the second option in this case (i.e., the NO). I’d like to quickly find this code when needed, but also important is how the question needs to be made, and the text of each button needs to be worded so that user can better know what each button is going to do.

String[] options = { "Yes, discard changes", "No, go back to where I was" };
int n = JOptionPane.showOptionDialog( dialog, "Changes have not been saved!\nDiscard Changes?",
        "Unsaved changes", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[ 1 ] );
if( n == 0 ) {
dialog.setVisible( false );
}

Maybe I could have proposed in this way, but setting the default to ‘YES’. Fun, but my wife likely wont think it is fun, heheh.

Note: the question has a mistake, it should say “Changes have not been saved”

Extra note: simple html can be used, such as

"<html>Yes,<br>discard changes</html>"

Learning Web Design 4th Edition (Book Review)

October 6th, 2012 by Boanerges Aleman-Meza

Summary: Learning Web Design (4th edition) The book tells you not only how to do stuff, it tells you why and when it is right to do so. Proportionally speaking, if the book were 11 pages, you get 1 page for introduction, 3 for HTML, 5 for CSS and 2 for javascript. The book focuses on the important stuff, and says what is good on each. You can always learn the material online via web search, copying examples, etc, but it will take a while to grasp the ‘why’ of its intended usage.

If you already know some of the material and want a refresher on the latest (such as HTML5), simply go to the ‘test yourself’ section at the end of each chapter. The core of the book is the HTML and CSS content. It nicely explains what it’s new in HTML5.

HTML5: the book tells you what to do for browsers that do not support HTML5. It is to the point in just what you need to know. It includes enough for the video tag but not too much. If you need to go deep into canvas tag, get another book.

CSS: the book gives you strategies for page layout, and covers nice stuff such as round corners, transitions, transformations, animations. Finally I was able to fully understand a number of CSS techniques that I have used in my sites.

JavaScript: the book covers enough to practically know what it is and why you may have to learn it in the future. If you need to go deep in JavaScript, get another book. Lastly, a small chapter on web graphics is what I consider ‘filler’ content for people that know nothing about image formats.

The book is big and pretty, in the same way that you can learn genetics online, we all know that the best is to get a genetics book and read through it. Similarly here, you wont regret getting the hard-copy, it is similar to a traditional college book (definitely less pricey than a genetics book). The reader can be a newbie or skilled person in web page design. Newbie will learn in a ‘clean’ way, the skilled person will refresh/learn how to correctly use HTML5 tags and CSS.

Disclaimer: I was provided with a copy of the book from O’Reilly for review. This review was first posted in Boanerges Aleman-Meza’s blog