Saturday, 11 January 2020

Open, Read, Display image File using Java Program | Java Slide Making

Open, Read, Display image File using Java Program | Java Slide Making

Java program to show an image in a JFrame


Here you find the Java Swing source code for a program that does all those things, eventually displaying the image you provide in a JFrame:

import java.awt.*;
import java.awt.image.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;

/**
 * A Java class to demonstrate how to load an image from disk with the
 * ImageIO class. Also shows how to display the image by creating an
 * ImageIcon, placing that icon an a JLabel, and placing that label on
 * a JFrame.
 *
 * @author alvin alexander, alvinalexander.com
 */
public class ImageDemo
{
  public static void main(String[] args) throws Exception
  {
    new ImageDemo(args[0]);
  }

  public ImageDemo(final String filename) throws Exception
  {
    SwingUtilities.invokeLater(new Runnable()
    {
      public void run()
      {
        JFrame editorFrame = new JFrame("Image Demo");
        editorFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
       
        BufferedImage image = null;
        try
        {
          image = ImageIO.read(new File(filename));
        }
        catch (Exception e)
        {
          e.printStackTrace();
          System.exit(1);
        }
        ImageIcon imageIcon = new ImageIcon(image);
        JLabel jLabel = new JLabel();
        jLabel.setIcon(imageIcon);
        editorFrame.getContentPane().add(jLabel, BorderLayout.CENTER);

        editorFrame.pack();
        editorFrame.setLocationRelativeTo(null);
        editorFrame.setVisible(true);
      }
    });
  }
}

compiling this program


 ImageDemo.java

To run the program


java ImageDemo path-to-your-image



Open, Read, Display image File using Java Program | Java Slide MakingOpen, Read, Display image File using Java Program | Java Slide MakingOpen, Read, Display image File using Java Program | Java Slide MakingOpen, Read, Display image File using Java Program | Java Slide Making

Java Image Gallery Download With Code


Java Image Gallery Download With Code Java Image Gallery Download With Code Java Image Gallery Download With Code Java Image Gallery Download With Code Java Image Gallery Download With Code Java Image Gallery Download With Code Java Image Gallery Download With Code Java Image Gallery Download With Code

Copy Paste The Code:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.TimerTask;


public class ImageGallery extends JFrame
{
    private ImageIcon myImage1 = new ImageIcon ("Chrysanthemum.jpg");
    private ImageIcon myImage2 = new ImageIcon ("Desert.jpg");
    private ImageIcon myImage3 = new ImageIcon ("Jellyfish.jpg");
    private ImageIcon myImage4 = new ImageIcon ("Penguins.jpg");
    JPanel ImageGallery = new JPanel();
    private ImageIcon[] myImages = new ImageIcon[4];
    private int curImageIndex=0;

    public ImageGallery ()
        { 
            ImageGallery.add(new JLabel (myImage1));
            myImages[0]=myImage1;
            myImages[1]=myImage2;
            myImages[2]=myImage3;
            myImages[3]=myImage4;

            add(ImageGallery, BorderLayout.NORTH);

            JButton PREVIOUS = new JButton ("Previous");
            JButton PLAY = new JButton ("Play");
            JButton STOP = new JButton ("Stop");
            JButton NEXT = new JButton ("Next");

            JPanel Menu = new JPanel();
            Menu.setLayout(new GridLayout(1,4));
            Menu.add(PREVIOUS);
            Menu.add(PLAY);
            Menu.add(STOP);
            Menu.add(NEXT);

            add(Menu, BorderLayout.SOUTH);

            //register listener
            PreviousButtonListener PreviousButton = new PreviousButtonListener ();
            PlayButtonListener PlayButton = new PlayButtonListener ();
            StopButtonListener StopButton = new StopButtonListener ();
            NextButtonListener NextButton = new NextButtonListener ();

            //add listeners to corresponding componenets
            PREVIOUS.addActionListener(PreviousButton);
            PLAY.addActionListener(PlayButton);
            STOP.addActionListener(StopButton);
            NEXT.addActionListener(NextButton);

        }

    public static void main (String [] args)
        {
            ImageGallery frame = new ImageGallery();

            frame.setSize(490,430);
            frame.setVisible(true);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setLocationRelativeTo(null);
        }



    class PreviousButtonListener implements ActionListener
    {

        public void actionPerformed(ActionEvent e)
            {
                if(curImageIndex>0 && curImageIndex <= 3)
                    {   ImageGallery.remove(0);
                        curImageIndex=curImageIndex-1;
                        ImageIcon TheImage= myImages[curImageIndex];
                        ImageGallery.add(new JLabel (TheImage));
                        ImageGallery.validate();
                        ImageGallery.repaint();
                    }
                else
                    { 
                        ImageGallery.remove(0);
                        ImageGallery.add(new JLabel (myImage1));
                        curImageIndex=0;
                        ImageGallery.validate();
                        ImageGallery.repaint();
                    }
            }
    }

    class PlayButtonListener implements ActionListener
    {
        public void actionPerformed(ActionEvent e)
            {
                        // *need help here*//

            }
    }

    class StopButtonListener implements ActionListener
    {
        public void actionPerformed(ActionEvent e)
            {
                        // *need help here*//
            }
    }

    class NextButtonListener implements ActionListener
    {


        public void actionPerformed(ActionEvent e)
        {

            if(curImageIndex>=0 && curImageIndex < 3)
                {   ImageGallery.remove(0);
                    curImageIndex = curImageIndex + 1;
                    ImageIcon TheImage= myImages[curImageIndex];
                    ImageGallery.add(new JLabel (TheImage));
                    ImageGallery.validate();
                    ImageGallery.repaint();
                }
            else
                { 
                    ImageGallery.remove(0);
                    ImageGallery.add(new JLabel (myImage4));
                    curImageIndex=3;
                    ImageGallery.validate();
                    ImageGallery.repaint();
                }

        }
    }
}

Monday, 18 June 2012

Nokia CEO Wants Employees To Use iPhones | Android

Now that the flounder handset giant Nokia has been taken over by the ex-Microsoft tycoon  Stephen Elop, you’d presume that he’d want his employees to start using Windows Phone 7 handsets preferably Nokia ones. But it happens to be not the case; he wants them to use iPhones.

Nokia iphone Nokia CEO Wants Employees To Use iPhones
According to a report, the hard task ahead of Elop is to change the entrenched way of thinking of his new employees that led to the once supreme handset giant’s fall. The report further narrates a meeting in which Elop questioned 11,600 Nokia engineers that how many people used an iPhone or an Android device.
When only few hands were raised, Elop sharply reprimanded his engineers.

“That upsets me,” Elop said. “Not because some of you are using iPhones, but because only a small number of you are using iPhones.”

“I’d rather want people to have the intellectual curiosity to try to understand what we’re up against,” said Elop.

This indeed is the sort of incident that makes me think that Nokia has got a fighting chance.

Gadget in 2011 | Android Apps Development

BlackBerry PlayBook

playbook keyboard.png blackberry 550x369 Gadget in 2011
Research In Motion’s BackBerry Playbook is set to escort the company into the tablet market in or around the first quarter of 2011. The tablet supports Flash 10.1 and HTML 5, has a 7-inch screen, HDMI support, dual (front and back-facing) HD cameras, 1 GB of RAM and a 1 GHz dual-core processor.

Kindle 3

Kindle 2 front6 550x550 Gadget in 2011
As great as the iPad is, it still doesn’t improve upon the book-reading experience of Kindle’s e-ink. This year’s model is improved in just about every way: faster, lighter, longer battery life, better contrast and bigger storage.

IPad

ipad 550x409 Gadget in 2011
The iPad rumour mill is now completely full, and from what we’ve heard, the new specs sound great. Based on the rumours, the newest iteration of the iPad will sport both a front & back facing camera, a lighter & smaller body, USB ports, a newer display technology and a new 3-axis gyroscope.

7.Ultrasonic Touchless Input technology

ultrasonic Gadget in 2011
Elliptic Labs is demo-ing their ultrasonic touchless input technology this year at CES and it looks super cool. It’s similar to the technology built-in to Microsoft Kinect that allows users to execute actions without physically touching the device or a controller.

Surf the web with a proxy on Android | Android Apps Development

If you want to surf the web with a proxy on Android and can’t/don’t want to root your device then Opera Mobile is the solution.

If Opera Mobile is not installed on your phone then go get a copy from the Android Market. Or if you don’t have Internet access on your phone, then download a copy from Opera’s website and transfer it to your phone:

http://ftp.opera.com/pub/opera/android/mobile/10.1/

Once you have connected to the Wi-Fi network with the proxy and have Opera Mobile running:

1. Type opera:config into the address bar then enter
1 Surf the web with a proxy on Android
2. Scroll down the page until you get to Proxy and click it to display the settings
2 Surf the web with a proxy on Android
3. Now Scroll down again until you get to HTTP server and HTTPS server and in these two fields type your proxy information in the format address:port (e.g. my.proxy.com:3128)
3 Surf the web with a proxy on Android
4. Scroll down more until you get to Use HTTP and Use HTTPS and tick both boxes then click on save lower down
4 Surf the web with a proxy on Android
5. Now close the window and go to any site and the proxy should be working on Opera Mobile, and if your proxy server needs a username and password a popup will tell you to enter them in after you try going to any site
5 Surf the web with a proxy on Android
Alternatively, we have another solution to this but this surely requires some expertise.
As there is no UI for proxy settings for android web browser. But the android web browser will read the proxy settings in its settings database.
Here is the instructions to enable the proxy in the android web browser.
  1. > adb shell
  2. # sqlite3 /data/data/com.google.android.providers.settings/databases/settings.db
  3. sqlite> INSERT INTO system VALUES(99,’http_proxy’, ‘proxy:port’);
  4. sqlite>.exit
You can talk to settings.db for more information.
  1. sqlite> SELECT * FROM system;
  2. sqlite> .tables
  3. sqlite> .databases
  4. sqlite> .schema table_name
  5. sqlite> more SQL expression to talk to the tables
Don’t forget the ‘;’ at the end of the SQL expression.

Google seeks to unlock Android 3.0 hardware power | Android Apps Development

A new interface coming with the forthcoming Honeycomb version of Android will open up a new ability for programmers who want to tap into hardware power unlocked by low-level programming.
quinn anya Google seeks to unlock Android 3.0 hardware power
The new interface, is called Renderscript, an Android performance and graphics programmer at Google.The goal for the feature has to be better games on Android. It’s a broader feature, though: it’s used in Honeycomb’s YouTube and Books apps.
The target audience is the set of developers looking to maximize the performance of their applications and is comfortable working closer to the metal to achieve this. The target use is for performance-critical code segments where the needs exceed the abilities of the existing APIs.
To that end, Renderscript exposes two hardware-accelerated interfaces, one for rendering 3D graphics and one for for power-efficient computing operations. To use it, Renderscript relies on a variant of the C99 programming language that itself is related to C. And the Renderscript plumbing that comes along with Honeycomb, aka Android 3.0, makes the decisions about whether to run the computing jobs on regular or graphics processors.
DSC09136 Google seeks to unlock Android 3.0 hardware power
The Native Developer Kit Google offers for Android already lets programmers directly access low-level hardware features. Renderscript has an important difference, though: it’s cross-platform. Instead of coming with software coded just for a specific chip, it comes with scripts that are compiled into an intermediate format that is then translated for a specific device only when it runs.

Apple iPhone Growth Suppressed By Rise Of Android Devices | Android Application Development

iPhone 4’s arrival on Verizon Wireless effectively sustained the iOS’s share of the US smartphone market by nine percentage points successively in the first quarter of 2011. However, Verizon’s actual iPhone 4 sales for the quarter reached only 2.2 million units, far below industry watchers’ earlier estimates of 3-4 million units.


iphone vs android Apple iPhone Growth Suppressed By Rise Of Android Devices

Verizon’s lower-than-expected iPhone 4 sales indicate that it was only a temporary problem for Android. It is believed that Android will resume its growth path in the US starting the second quarter.

Reports predict that around 13.5 million iPhones will be shipped in the current second quarter of 2011, still below Apple’s planned sales of 18 million units. In addition, with more Android-based devices hitting store shelves in the second half of 2011, the Google smartphone OS will widen its gap with iOS even more, thanks to its more complete ecosystem.