星期二 四月 14, 2009

Quick Design "Calculator" with GUI Builder in NetBeans 6.5

During NetBeans 6.5,you can do the GUI design very quickly and it's very convenient for you to use.You can work out the project by just drafting the swing components.


Before get started,you should install NetBeans 6.5(6.7 Milestone 1/2/3 is  also okay) and JDK 6(or higher edition) on your computer.


This time I'd like to do a simple calculator with NetBeans 6.5.


First of all,just oepn NetBens 6.5,choose Javase,create a new java desktop application, name for your project and make it the main project.


After that,we can design the calculator by drifting the swing components ,here we use Jbutton for the number 1 to 9 ,and use textfield to display the result.Like below:


 


I put the sourcecode in the attachment,you can download it and run it on your computer.


However,this is just a simple application,contains four arithmetic operations(add,subtract,multiply,divide)and arithmetic point operations.Besides,with it ,you can continue your next calculation .Of course, you can do further developing with the existing one.


 Source code:http://blogs.sun.com/Chinese_Functional_CA/resource/src.rar


 

星期一 五月 05, 2008

Running Sun Ray Server on Windows

When we use Sun Ray clients, we may wanna use the device which doesn't support Solaris. Even we're running the Mac OS, windows which is not supported by Sun Ray Server Software.

What Should We Do? VirtualBox can help us.

At first, we should download a copy of VirtualBox for our OS.

Second, download a copy of Solaris 10 which is supported by SRSS.
(Attention: the opensolaris doesn't support SRSS very well)

Let's begin, launch the VirtualBox and create one virtual machine. You should add one network card and set the networking Attached to: Host Interface and select the interface name at first.

Now, we can boot this virtual machine by Solaris DVD and install it.

After a long wait, we can login to the new Solairs in our virtual machine. We should check the network before install the SRSS.

At last, copy SRSS into virtual machine and unpack the Sun Ray software

  Run "utinstall"

  Then, configure the sun ray server:

    \* /opt/SUNWut/sbin/utadm -c
    \* /opt/SUNWut/sbin/utadm -A 192.168.128.0 # {allows you to server Sun Ray over this network }
    \* /opt/SUNWut/sbin/utadm -L on # {enable LAN connection from Sun Ray}
    \* /opt/SUNWut/sbin/utadm -n # {bring server online}
    \* /opt/SUNWut/sbin/utrestart

  Now connect your Sun Ray client to the network.

If you're already connected to another Sun Ray server, do this:

  /opt/SUNWut/sbin/utswitch -h "your VirtualHost's IP address"
 
Finally, we have running sun ray server on Windows XP successfully.

星期一 四月 21, 2008

Google Maps on Rails with NetBeans (Part Two)

Author: Gao Ang

Once we get the Google
Maps in our browser, we could see two point markers that we added in the final
page. Now we take a glace at the JavaScript code which generate by our Rails
application:

<html>

<head>

  <title>Map demo</title>

 

<script src='http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAj5cpJ2swzFT77RVZXuP73BTX2XchcwgyHzp4Xo0DHRAzt2aLjhSg2ymVlJvVjBa7kWNgtqU8xxwIAQ'
type='text/javascript'></script>

</head>

<body id="map">

    <div id="main">

      <h1>Add New Location</h1>

<hr />

 

<script type="text/javascript">

var gmaps;

 

var location_3;

function location_3_infowindow_function(){

  location_3.openInfoWindowHtml("")

}

var location_4;

function location_4_infowindow_function(){

  location_4.openInfoWindowHtml("")

}

function initialize_gmap_gmaps() {

if (!GBrowserIsCompatible()) return
false;

gmaps = new GMap2(document.getElementById("gmaps"));

// initialization the center point of our map

gmaps.setCenter(new GLatLng(37.79, -122.4), 14);

  // set the default
type of the map

  gmaps.setMapType(G_NORMAL_MAP);

  // add control bar
for the map

  gmaps.addControl(new GLargeMapControl());

  gmaps.addControl(new GScaleControl());

  // create every
markers from the array @markers

  location_3 = new GMarker(new GLatLng(37.792528, -122.393981));

// add listener on our map

  GEvent.addListener(location_3, "click", function() {location_3_infowindow_function()});

    // add user
marker to the map

    gmaps.addOverlay(location_3);
 
  location_4 = new GMarker(new GLatLng(37.794391, -122.394831));

  GEvent.addListener(location_4, "click", function() {location_4_infowindow_function()});

    gmaps.addOverlay(location_4);

}

 

if (typeof window.onload != 'function')

  window.onload = initialize_gmap_gmaps;

else {

  old_before_cartographer_gmaps
= window.onload;

  window.onload = function() {

    old_before_cartographer_gmaps();

    initialize_gmap_gmaps();

  }

}

</script>

<div id="gmaps" style="width: 600px; height: 400px;"></div>

</div>

</body>

</html>

 

In the final page, Rails plugin
Cartographer help
us to generate most of our Google Maps API code. And then mark our location in
the final map.

After the above work, let’s
make some supplement for our gmaps application. We will create a form and let
user add the address in the page with the auto-geocoding provided by the GeoKit.

First, we should add a new method in the controller location, we define create method to accept
the user input. After that we will
redirect our page to the index method. Our code in the create method looks like:

  def create

    @location = Location.create(params[:location])

    redirect_to :action => "index"

  end

Then we will add the corresponding code in the index
view. When user post the form to location controller,
the
create method will deal with the new location. The supplement code in
the index view looks like:

<h2>Add New Place</h2>

<% form_for :location, :url => { :action => :create } do |f| %>

  <p>Address:

  <%= f.text_field :address %></p>

  <p>Description:

  <%= f.text_field :description %></p>

  <p><%= submit_tag "Add Location" %></p>

<% end %>
 

After the modification, let’s refresh the page, we could
see a new form with input field. Now we add a new location in the field:
333 Post St, San Francisco,
CA
and the description of the
field. Then click Add Location button to post our information. When the page
reloads, we could see a new place marker has been added in our map.

Now click the new marker that we added just
now. We could see a popup window with the description will show up in the map. The
final map looks like the following graph.


 

More information

 You can find additional information about Ruby
support in NetBeans on its wiki page: http://wiki.netbeans.info/wiki/view/Ruby.

Various demos
and tutorials are available from the main Ruby documentation page:
http://www.netbeans.org/kb/60/ruby/index.html.

Finally you can
download the NetBeans IDE for free from the following URL: http://www.netbeans.org/community/releases/60/index.html.
You can either choose to install a small version of the Ruby-only IDE (a
special bundle is provided) or full-blown Java IDE with Ruby support. It is
also possible to add Ruby support to the Java-only IDE using Tools | Plugins.

In the next part
of the series, we will discuss how to add locations in the rails project. As
well as how to show up popup window in our map.

In the meantime,
make sure to try out Ruby support in NetBeans. If you develop in Ruby a lot,
you may find that NetBeans is the IDE you have been looking for!

星期五 四月 11, 2008

Introduce File Backups


Introduce File Backups


 


The fundamental mission of system administrator is protecting the data in system. Unfortunately ,data always missed for some reasons.,such as hardware trouble, system failure and so on.Therefore,system administrator need to make a plan for backups termly.


There are three kinds of backups,as follows:


1.Full backups


Backup all data every time。


2.Incremental backups


An incremental backup copies only files in the file system that have been added or modified since a previous lower-level backup


3.Differential backups


Copie all of files updated in the file system since a full backup last time.


A example:


(1)   Rewind the tapes


 #mt rewind



(2)   Create /export/home backup


 #ufsdump 0S /export/home


#umount /export/home


#ufsdump 0uf /dev/rmt/0 /export/home


#cat /etc/dumpdates



       (3)add files and directories into /export/home file system


 #monut /dev/dsk/c0t0d0s7 /export/home


#cp –r /root/ /export/home


#umonut /export/home



(4)incremental backups


 #mt –f /dev/rmt/0 fsf 1


#ufsdump 1uf/dev/rmt/0 /export/home



(5)remove the tape


 #mt offline



       (6)display backup log files


# cat /etc/dumpdates

星期三 四月 09, 2008

Why,How,What

When we learn some new things,we always have the same process:Why we should learn them,How we shold learn them,and What make them so excellent?Of cource,when we learn Solaris ,we also start our travel in these aspects.
Why we should learn Solaris?That's our Sun Campus Ambassadors and Sun technology Evangelists' duty to let more students and developers know and like Solaris.Solars has many new features and it can make enterprise run that operation system in the stabile way.In fact, Lots of meeting ,tech day,tech party also give us the chance to know the advanced technologies ,including solaris which has been the  open os in the world.
How we should learn Solaris?Firstly,we could ask any questions when we use the solaris on the line,there are some communities and websites we can find resources,such as opensolaris.org,opentech.org.cn and so on.Secondly,we can use basic operation on solaris,you can learn on websites.If you have demand,you also can prepare some certifications,such SCSA.It can make us learn solaris in the system way.Of cource,if you have some experiences on solaris,we can teach and talk with other people.
What make solaris so excellent?Sometimes we would like to know the internal theory and want to make some our own features.Therefore,you should learn some solaris kernel knowledge and create something.If you like,you can take part in some solaris training,such teache training in china(my mentor Fiona hold these activities)or you can join some community to develop some projects of open solaris.You can know what make solaris excellent,and you have contributed on the new solaris features maybe.
So why,how,what,that is a process to learn Solaris,Right?

About

This is Chinese Functional CA Team Blog. Any suggestion is appreciated.

Search

Categories
Archives
« 四月 2014
星期日星期一星期二星期三星期四星期五星期六
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
今天