Posts

Showing posts from November, 2010

How to display a control in JPanel during runtime

I had a problem in a Java project about not able to display a JTree into a JPanel. The JPanel is created during design time. The problem is JTree is created during runtime and adding the JTree into the JPanel will not display the control when executing the application. The code below won't work: JTree treeObject = new JTree(); panelObject.add(treeObject); There is one more thing to do to make it work by adding a group layout. //---------- START JTree treeObject = new JTree(); panelObject.add(treeObject); javax.swing.GroupLayout myLayout = new javax.swing.GroupLayout(panelObject); panelObject.setLayout(myLayout); myLayout.setHorizontalLayout(       myLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)      .addComponent(treeObject, panelObject.getWidth(), panelObject.getWidth(), panelObject.getWidth()) ); myLayout.setVerticalGroup(       myLayout.createParallelGroup(javax....

How to add and delete contents in menu.lst in Linux

I was creating a RPM for Linux in one of my projects. I needed to add contents to the menu.lst which is found in /boot/grub/. The operating system that I'm using is Suse. There are two problems that needs to be done. 1. Need to add content to the file 2. Remove the content from the file. I use the bash script to do both. To add content to the file:  cat /boot/grub/menu.tmp >> /boot/grub/menu.lst  wc -l /boot/grub/menu.lst > /boot/grub/menu.lstcount The first line is to append the content in menu.tmp to  menu.lst. The second is count the number of lines in the menu.lst and save the result to menu.lstcount. To delete the content of the file: num=`grep -o ".*[0-9]" /boot/grub/menu.lstcount` let begin=$num-3 mv /boot/grub/menu.lst /boot/grub/menu.orig sed "$begin,$num"d /boot/grub/menu.orig > /boot/grub/menu.lst The first line is retrieve the line number stored in menu.lstcount Second line is to assign the difference of the line numb...