Showing posts with label Java Swing. Show all posts
Showing posts with label Java Swing. Show all posts

Saturday, November 30, 2013

Java prog#151. How to use JPopupMenu in Java Netbeans




























---------------------------------------------------------------
JPopupMenu: How to use?
An example of the JPopupMenu in action
 Java: submenu in jpopupmenu with separators
Do more with JPopupMenu
A simple example of JPopupMenu
javax.swing.JPopupMenu
 JTable with JPopupMenu
Searches related to jpopupmenu java example
java swing jpopupmenu example
java popup menu example
java submenu example
java menubar example
java swing popup menu
java jpopup
java swing context menu
java popup menu submenu

Tuesday, November 26, 2013

Java prog#148. Determine if internet connection is available using Java

















-------------------------------------------------------
How to check internet connectivity in Java
How to check if internet connection is present in java?
sockets - check internet connectivity in java
How to programmatically check availibilty of internet connection
How to Check my pc is having internet connection using java
Check if there is internet connection [Java]
Searches related to check internet connection java
java check network connection
how to check who is connected to your internet
c# check internet connectivity
android verify internet connection
How to check whether PC is connected to Internet programmatically
Java code to test whether connection to internet can be established

Tuesday, April 2, 2013

Maximizing a window in Java Swing

Java swing maximize window


public void run() {
MyFrame myFrame = new MyFrame();
myFrame.setVisible(true);
myFrame.setExtendedState(myFrame.getExtendedState() | JFrame.MAXIMIZED_BOTH);
}

The above code will work Provided that you are extending  the JFrame













------------------------------------------------------------------------------------------
Searches related to java swing maximize window java jframe maximize window java maximize frame java close jframe jframe close jframe resize center jframe close a jframe on clicking a button center jframe on screen.How to maximize a JFrame

Java Swing - Java Look and Feel

If you developing a desktop application with Java Swing for personal or commercial use.You are  in need of some beautiful Look and Feel for my application. How can you do it using Java or a third party API?



There is a lot of possibilities for Look and Feels with third party plugins or add-ons. Here is some of the list-


Below are some example How to implement look and feel in Netbeans IDE which I have used in my videos

Java prog#42.Change look & feel of NetBeans IDE run Jframe to Metal,Windows,Windows Classic etc. 






Java prog#43.How to use JTattoo look & feel of Java NetBeans IDE run Jframe 



----------------------------------------------------------------------------------------------

How to change look & feel of NetBeans IDE and application
How to customize NetBeans look and feel
What Is NetBeans Nimbus
How to set Nimbus Look and feel in Netbeans
Java's Windows look and feel netbeans
javax.swing.plaf.metal.MetalLookAndFeel
 com.sun.java.swing.plaf.nimbus
Can I run NetBeans with a custom Look and Feel
netbeans java windows look and feel
netbeans java Metal look and feel
netbeans java windows classic look and feel
netbeans java Nimbus look and feel
netbeans java CDE/Motif look and feel
netbeans java tutorial iit

netbeans - JTattoo look and feel Java
Using JTattoo look-and-feel with NetBeans
how to set java look and feel
How to use jTattoo Look and Feel - Java
java - Why Look and feel is not getting updated properly?
netbeans java JTattoo Help please
New Looks and Feels from JTattoo
How to change the theme of a java GUI Application
Download Free JTattoo
Best Java Swing Look and Feel Themes

Java Swing - how to add an image to a JPanel?

How to add image inside jPanel ?


import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JPanel;

public class ImagePanel extends JPanel{

private BufferedImage image;

public ImagePanel() {
try {
image = ImageIO.read(new File("image name and path"));
} catch (IOException ex) {
// handle exception...
}
}

@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters
}

}



--------------------------------------------------
How to add image inside jPanel ?
Java Swing - how to add image in north of Jpanel
java - how to put Image on JPanel using Netbeans
background image on JPanel Swing
Add an image to JFrame
Adding multiple images to JPanel
Adding picture to Jframe on click‎
Add image to jframe‎
JPanel background picture?‎
How do i add images to java Jframe?
How to set a background image for a JFrame using Jlabel

Sunday, January 13, 2013

Extract file/files from a zip file using Java code


THIS IS A SIMPLE CODE TO EXTRACT FILES FROM A ZIP FILE ........



import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Main {
  public static void main(String[] argsthrows Exception{
    String destinationname = "d:\\";
    byte[] buf = new byte[1024];
    ZipInputStream zipinputstream = null;
    ZipEntry zipentry;
    zipinputstream = new ZipInputStream(new FileInputStream("fileName"));
    zipentry = zipinputstream.getNextEntry();
    while (zipentry != null) {
      String entryName = zipentry.getName();
      FileOutputStream fileoutputstream;
      File newFile = new File(entryName);
      String directory = newFile.getParent();

      if (directory == null) {
        if (newFile.isDirectory())
          break;
      }
      fileoutputstream = new FileOutputStream(destinationname + entryName);
      int n;
      while ((n = zipinputstream.read(buf, 01024)) > -1){
        fileoutputstream.write(buf, 0, n);
      }
      fileoutputstream.close();
      zipinputstream.closeEntry();
      zipentry = zipinputstream.getNextEntry();
    }
    zipinputstream.close();
  }
}

Write Zip file using Java code


THIS IS A SIMPLE CODE TO WRITE A ZIP FILE ........


import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class Main {
  public static void main(String[] argsthrows Exception {
    FileOutputStream fos = new FileOutputStream("C:/MyZip.zip");
    ZipOutputStream zos = new ZipOutputStream(fos);
    ZipEntry ze = new ZipEntry("C:/file1.txt");
    zos.putNextEntry(ze);
    zos.closeEntry();
    ze = new ZipEntry("C:/file2.txt");
    zos.putNextEntry(ze);
    zos.closeEntry();
    zos.close();
  }
}

Create a zip file using Java


THIS IS A SIMPLE CODE TO cREATE A ZIP FILE ........


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class Main {
  public static void main(String[] argsthrows Exception {
    FileInputStream inStream = new FileInputStream("test.txt");
    ZipOutputStream outStream = new ZipOutputStream(new 
      FileOutputStream("compressed.zip"));

    outStream.putNextEntry(new ZipEntry("test.txt"));

    byte[] buffer = new byte[1024];
    int bytesRead;

    while ((bytesRead = inStream.read(buffer)) 0) {
      outStream.write(buffer, 0, bytesRead);
    }

    outStream.closeEntry();
    outStream.close();
    inStream.close();
  }

}

Read zip file using Java

This is a simple code to Read a zip file ........





import 
java.io.FileInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

public class Main {

  public static void main(String[] argsthrows Exception {
    FileInputStream fis = new FileInputStream("C:/MyZip.zip");
    ZipInputStream zis = new ZipInputStream(fis);
    ZipEntry ze;
    while ((ze = zis.getNextEntry()) != null) {
      System.out.println(ze.getName());
      zis.closeEntry();
    }

    zis.close();

  }
}

Thursday, October 25, 2012

Code used in video "Java prog#8. How to close previous jframe on the opening of new jframe in netbeans"

HERE I AM PROVIDING THE downloadable CODE LINK OF  THE JAVA CODE I HAVE USED IN THE VIDEO  "JJava prog#8. How to close previous jframe on the opening of new jframe in netbeans"  OF MY YOUTUBE CHANNEL PROGRAMMINGKNOWLEDGE

Click Link to watch the video LINK

This code below is for the close() function





   public void close(){

WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);

}

after that you have to call the function using below code


rs.close();
pst.close();
close();
//Employee_info is the frame name you want to open
Employee_info s =new Employee_info();
s.setVisible(true);

Other way of doing that is also

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


Java prog#8. How to close previous jframe on the opening of new jframe in netbeans





it's simple just follow the below code:
First import these two files below
import java.awt.event.*;
import java.awt.*;


then write the method for close

 public void close(){

 WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
 Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);

 }



Java prog#25.Exit Command Button jFrame in Java netbeans 




--------------------------------------------------------------------------------------------------------

Java: How do I close a JFrame while opening another one?
How to close a jframe without closing the main program
Close one JFrame without closing another?
passing data from one jframe to another
How to disable main JFrame when open new JFrame
Opening new JFrame replaces current window
NetBeans Forums - Opening new Jframe in existing window
iit Learn     java netbeans
java tutorial netbeans


How to close a Java Swing application from the code
swing - How do I close a java application from the code
java swing close window
How to close Java program or Swing Application with Example
Closing A Swing Application?
How to close this window? Swing

 

© 2013 Klick Dev. All rights resevered.

Back To Top