Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Saturday, July 24, 2010

turning the J into an A

So... this is what I've been working on today. Making the J from some of the javax.swing classes turn into an A... but that's not all ;)). I've been trying to extend JButton and JPanel. The results are: AButton and APanel.
These A things inherit form the J things and here's the spice: the AButton, instead of having some text displayed on, it will display an image/picture. The button takes the size of the picture that it's displaying +4 on both X and Y axis. The APanel instead of having a background made entirely out of one single boring color it displays a background picture.
One more thing that I added was an ACanvas. All these three classes work both with JFrames and JApplets.
Here's a screenshot of an example with a simple application:
The YouTube My Channel is actually a button. I'm too tired now but I'll add source code and maybe the application later. I'm going to bed. Good night!
P.S. ...and Ace Of Base launched a new single: All For You. Linn and Jenny are not in the band anymore but there still are two main female voices: Clara Hagman and Julia Williamson. Good news: the new song has that good, old and awesome ace of base feeling :D. Here's a link to a preview and here's a radio rip because it hasn't yet been released all over the world.

Friday, May 21, 2010

Java RXTX close port solution




class CloseThread extends Thread
{
   public void run()
   {
      serialPort.removeEventListener();
      serialPort.close();
   }
}


public void closePort()
{

   try
   {
      if (serialPort != null)
      {
         serialPort.getInputStream().close();
         serialPort.getOutputStream().close();

         new CloseThread().start();

      }

   } catch (Exception e) {}
}
/*
Late Note(11.17.2011): I see that there are plenty of views on this article and after more than one year I realize that the context might look ambiguous. What I didn't mention before is that this is an inner class to the class in which you have the methods for communicating over the serial port, and in here serialPort is an object of the SerialPort class.
*/

Thursday, April 30, 2009

Capra cu trei iezi

//secventa de poveste in Java


private ArrayList caprasIed;
caprasIed=new ArrayList();
caprasIed.add("Iedul mic");
caprasIed.add("iedul mediu");
caprasIed.add("iedu care o supt mai mult");
private Carnivor lupul;
lupul= new carnivor("Lupul cel rau");
Ied iedTemporarSiProst;
iedTemporarSiProst=new Ied();
if(lupul.knockKnok()) {
iedTemporarSiProst= caprasIed.get(2);
if (iedTemporarSiProst.open(door)) {
lupul.NumberOfKillsCount();
iedTemporarSiProst.died();
}
}