Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,259 members, 7,815,405 topics. Date: Thursday, 02 May 2024 at 11:53 AM

Orobogenius's Posts

Nairaland Forum / Orobogenius's Profile / Orobogenius's Posts

(1) (of 1 pages)

Programming / Re: Can't Find Java Console. by orobogenius: 6:45pm On Oct 15, 2016
For those of us that would like the company of other Java Programmers sharing ideas and moving each other forward, here is a link to the Java Whatsapp Group.



https:///67YS6IJnPwBLontRn1XlxV
Programming / Re: Official Thread For Experts And Begineers In Python by orobogenius: 9:11am On Oct 31, 2015
.
Programming / Re: Where Are The Java Programmers? by orobogenius: 5:38pm On Oct 29, 2015
Droidguy:
Please I have a problem of re-sizing a JLabel icon image, i.e. the IconImage is too big for the Panel created to contain it. Any help? undecided

[b]

First the easy way.....

ImageIcon icon = new ImageIcon("imageName" );
Image img = icon.getImage();
Image newImg = img.getScaledInstance(400, 200, java.awt.Image.SCALE_SMOOTH);
newIcon = new ImageIcon(newImg);


However there are some issues with the getScaledInstace method one of which is

Image.getScaledInstance() does not return a finished, scaled image. It leaves much of the scaling work for a later time when the image pixels are used.


To overcome such problem you can override
getPreferredSize()
of JLabel and return the dimensions you want from the function however a JLabel will size itself to its content and you will just need to resize the picture (imageicon) you add to the JLabel.

To autosize the image in the JLabel you have to resize your image according to your desired width and height and then add it to the JLabel.

To resize the image, you will need to create a BufferedImage with the picture and the desired dimensions. Here are two examples of what you want:

1. Using a function to create and return the BufferedImage.



//the method takes an image, and its corresponding dimension as argument and returns a BufferedImage
public BufferedImage resizeImage(BufferedImage image, int width, int height) {
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TRANSLUCENT);
Graphics2D g2d = (Graphics2D) bi.createGraphics();
g2d.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
g2d.drawImage(image, 0, 0, width, height, null);
g2d.dispose();
return bi;
}


and then calling the function like so

BufferedImage image=ImageIO.read("imageName" );
BufferedImage resizedImage=resize(image,400,200);//resize the image to 400x200


2. Create a buffered image without a function

ImageIcon icon = new ImageIcon("imageName" );
//Make sure the reference you create is an ImageIcon reference. Then use getImage() to grab the image from the ImageIcon:
Image img = icon.getImage();
//Now create a buffered image the same size as the image:
BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);
Graphics g = bi.createGraphics();
g.drawImage(img, 0, 0, WIDTH, HEIGHT, null);
//create an image icon from the bufferedimage
IconImage newIcon = new IconImage(bi);


then go ahead to add the imageicon to the JLabel
[/b]
Programming / Re: Bash/shell Scripting In A Unix/linux Environment by orobogenius: 8:35am On Oct 29, 2015
This is good sir. Quick question: what does the -n option in echo and -d option in the if condition do?

1 Like

Programming / Re: Check Out My Android App (exam Prep) by orobogenius: 6:38pm On Oct 28, 2015
Nice app, uses Google Material Design. Thumbs UP
Programming / Re: I Need Help In Java Programming. by orobogenius: 9:30am On Oct 28, 2015
danjumakolo:


Does this take care of minute milliseconds?
Why not use java.util.concurrent.TimeUnit

The
TimeUnit
in
javax.swing.Timer
class is in milliseconds sir.

1 Like

Programming / Re: Bash/shell Scripting In A Unix/linux Environment by orobogenius: 9:25am On Oct 28, 2015
danjumakolo:
@op

"Most of you are probably unaware that you use a version of Linux in your pocket (Android OS)"

lol

True talk sir, most of the core *nix Utilities are available
Programming / Re: I Need Help In Java Programming. by orobogenius: 6:49am On Oct 28, 2015
...
Programming / Re: A Good Php Developer, What Next? Java Vs .NET Vs Ruby by orobogenius: 6:24pm On Oct 14, 2015
yungcheda:
Which nonsense 24hours to learn which basics?? Except if u are cming from a very solid programming background and I mean "very solid" otherwise, a newbie can never learn php is 24hrs

I agree but it doesn't have to be "very solid" and a newbie is a newbie, they have to start learning programming concepts from scratch.
Programming / Re: Bash/shell Scripting In A Unix/linux Environment by orobogenius: 11:16am On Oct 11, 2015
Linux is by far the best OS for those of us that do not have a phobia for the command line, you feel at home, you are in control. I don't care for the so-called romantic interface windows seems to project. OP please continue, it's a nice feeling to know you're not alone.

1 Like

Phones / Re: HTC G2 (Android Phone) Owners Thread by orobogenius: 12:00pm On Sep 04, 2013
hyuga:
that cm9 chop battery o. my phone dey smoke anyhow. slimbean still d champ.

yap am definitely with u on this......slim bean is great......cm9 na battery killer.
Phones / Re: HTC G2 (Android Phone) Owners Thread by orobogenius: 7:13pm On Sep 01, 2013
Vijon: plz i didnt i understand wht u mean by computer button + R

click on start then click on run and type cmd....
Phones / Re: HTC G2 (Android Phone) Owners Thread by orobogenius: 2:59pm On Aug 29, 2013
Uche ernest: [color=#000099][/color]

i jst bought this fone today ,andi want to root diz phone, how do i do it?

download srsroot from srsroot.com anf install on ur system then goto settings an enable usb debugging and connet ur phone to ur system then open srsroot icon on ur desktop and click root my device (all method)
Phones / Re: HTC G2 (Android Phone) Owners Thread by orobogenius: 2:53pm On Aug 29, 2013
Vijon: yes i have.it says ADB device nt found

u should enable android debugging......goto setting => applications => development then enable usb debugging. connect ur phone to ur computer den on ur computer press windows button + R then type CMD......now type adb devices, this should show u ur phone serial number and if it does....ur good to root. but if the problem still persist download adb driver installer.
Phones / Re: HTC G2 (Android Phone) Owners Thread by orobogenius: 7:52am On Aug 28, 2013
Vijon: @all,plz wht other way can one root htc G2 coz i ve tried srsroot to no avail.am running gingerbread 2.3.4

are you sure u have a working internet connection? cause srsroot method requires a working internet connection to connect to thier server and dectect the appropriate rootkit method.
Phones / Re: HTC G2 (Android Phone) Owners Thread by orobogenius: 8:16pm On Aug 27, 2013
donsunny22:
Hello, pls can u past d link which u use in downloading gapps.zip and pls after downloading d zip file will i put it in my sdcard and locate on my recovery mod them click to install or flash.
Thanks

Goto goo.im/gapps then select the appropriate gapps for ur current OS.......downlad the zip file then place in ur /sdcard/. now reboot ur phone into recovery then while in recovery navigate to "install zip from sd"......locate d gapps zip file and select to open, select yes if asked and you're done. reboot ur phone after install complete.

(1) (of 1 pages)

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 24
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.