NetBeans: use a radio button group

It’s possible to unite several radio buttons into the group. For example, if the buttons “On” and “Off” are in the same button group, only one of them will be active (which is logical).

To create the radio button group in NetBeans do the following:

  1. Use “Button group” from the components palette and put it into Your form. It will be added as “non-visual”
  2. Button group component

  3. Add the radio buttons to the group, changing their ButtonGroup property (combobox in the Properties)
  4. RadioButton properties

To remove the radio button group, go to the inspector window and remove radio button group there.

  • Remove radio button group

  • Bookmark and Share

PDF file: set the bookmark

Strange enough, Adobe Acrobar Reader does not allow to put the user-defined bookmarks into the PDF file (and this is so simple and necessary thing!)

However, with the help of some “hack” the bookmarks still could be used.

Here is the trick:

  1. Go to PDF Hacks site and download the zip file with the javascript.
  2. Extract the file bookmark_page.js from the archive
  3. Copy the file bookmark_page.js to one of the following folders:
    • %ProgramFiles%\Adobe\Reader\Javascripts
    • %AppData%\Adobe\Reader\Javascripts

    Please, check the real installation path of the Acrobat software, it could be different on Your system.

  4. Restart the Acrobat Reader

Now You have 4 new menu items in the menu “View”. The first two could be called using shortcut “Alt-V-5″ and “Alt-V-6″ (for English version of Acrobat)
Bookmarks in PDF

The bookmarks are not saved in the PDF itself, so they could be lost, if the PDF file is moved to some other location.

To uninstall the bookmark script, just remove bookmark_page.js from the Javascripts folder and restart the Acrobat Reader.

Some other PDF tricks could be found in this book:


Bookmark and Share

Linux: get the version of the system

Get the version of the distro:

cat /etc/issue

cat /etc/*-release

Get the kernel version:

uname -r
Bookmark and Share

Perl: get file checksum

use Digest::MD5;
use IO::File;

my $chk = Digest::MD5->new();

foreach my $file (@ARGV)
{
    $chk->addfile(IO::File->new($file));

    print "$file -> ",$chk->hexdigest,"\n";
}

The additional details could be found on IBM site

Bookmark and Share

Install javadoc for NetBeans

Java documentation is not included neither in NetBeans installation, nor in “standard” Java SDK installation.

However, it’s possible to download it manually and add to the NetBeans IDE.

  1. Get the Java Documentation (currently “Java SE 6 Documentation”) from Sun site.
  2. Start NetBeans
  3. Select menu item “Tools->Java platforms”, then click “Javadoc” tab
  4. Click “Add Zip/Folder” button and select the path to the downloaded Zip-file

NetBeans Javadoc window

Bookmark and Share

Deactivate social services in Google Reader

There is a small piece of code (“bookmarklet”), which deactivates social services in Google Reader.

Just go to Google Reader and put into the browser command line the following:

javascript:antisocial('true')

If it’s necessary to reactivate it, use the following:

javascript:antisocial('false')
Bookmark and Share

Java: minimize Application window

The following method could be used to minimize application window, if java.awt.Frame or its subclass is used:

public void setState(int state)
Parameters:
state – Frame.ICONIFIED if this frame is in iconic state;
Frame.NORMAL if this frame is in normal state.

Example:

// Close window on ESC
// use it in the constructor of the window, extending JFrame
//
KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
rootPane.registerKeyboardAction(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setState(Frame.ICONIFIED);
        }          
    } , stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
Bookmark and Share

Oracle: eval function

The function takes some expression as the argument and executes it, returning output in the varchar string

CREATE OR REPLACE FUNCTION eval (expr VARCHAR2) RETURN VARCHAR2
AS
  ret VARCHAR2(4000);
BEGIN
  EXECUTE IMMEDIATE 'begin :result := ' || expr || '; end;' USING OUT ret;
  RETURN ret;
END;
/

The discussion and examples could be found there

Bookmark and Share

Oracle: list of the system events

This piece of code show the list of events, set in the Oracle database

SET serveroutput ON
 DECLARE
  event_level NUMBER;
 BEGIN
  dbms_output.enable(20000) ;
  FOR i IN 10000..33999 LOOP
     sys.dbms_system.read_ev(i,event_level);
     IF (event_level > 0) THEN
        dbms_output.put_line('Event '||to_char(i)||' set at level '||
                             TO_CHAR(event_level));
     END IF;
  END LOOP;
END;
Bookmark and Share

Oracle: list of the running transactions

This query shows SID, username and start time of the running transaction.
In addition, number of the used blocks is shown.

SELECT a.sid, a.status, a.username, b.xidusn, b.used_urec, b.used_ublk, b.START_TIME
FROM v$session a, v$transaction b
WHERE a.saddr = b.ses_addr
ORDER BY START_TIME DESC;
Bookmark and Share