Skip to main content

Posts

WMI - Windows Management Instrumentaion

WMI is a windows Library used to get the information like no of processes running currently in the computer and their event notifications like process creation modification and deletion notifications, cumputer's name, version, Win32 processes list etc The information above mentioned can be fetched not only from local PC but also the remote machine too.. WMI can be accessed through a query langauge in two ways they are: 1. WBEMTEST.exe [GUI Tool] 2  WMIC- stands for WMI Commandline tool 3. Programatically [using Powershell and VBScript] 1. wbemtest.exe:       How to start          1. go to start                2.  go to Run                  3. Type wbemtest.exe                  4.  the following window opens up. Queries that can be run with this tool 1. Usual queries 2. Not...

Apache Commons Exec API for executing exe files from java program

In my previous post http://java-gui.blogspot.in/2016/12/api-for-executing-exe-files-from-java.html     you have seen using traditional java API to execute exe files from java program. but it is proved that it is not an ideal solution for  programs which handles IO operations and for async executables. you can find more advantages of Apache Commons Exec library over traditional API in the below link.               http://commons.apache.org/proper/commons-exec/index.html Simple example that uses the Exec library: // class to pass the command ex: cmd.exe and its arguments... CommandLine command = new CommandLine("ping"); // arguments to the command object can be passed in 2 ways... command.addArguments("localhost") ; command.addArguments("-t") ; command.addArguments("-count");    or command.addArguments(new String[]{"-t", "-count"}); //handling the IO operations gracefully using LogOutputStream abstract c...

API for executing exe files from java program.

The traditional API for calling the executable in java program is using the Runtime, Process and their methods like exec(command), waitFor() methods respectively. a simple example to execute a notepad.exe from java program using the above API is given below. Process process = Runtime.getRuntime().exec("notepad.exe"); the above code is used to launch the notepad.exe executable from java program. if there are multiple commands needs to be passed then the code would be.... String[] command = {"cmd.exe", "/C", "echo ", "%TEMP%"};  Process process = Runtime.getRuntime().exec(command); the above snippet is used to execute multiple commands in a java program. this code prints the environment variable TEMP on to the console. Handling standard output produced by the above code: BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); String output = ""; String line = ...

JavaFX: arranging components on GridPane

JavaFX provides different layout panes for arranging components on them. for example GridPane, BorderPane etc. This article describes about arranging components on GridPane. GridPane layout manager allows arranging components/controls using overloaded method. ie add.                         1. add(controlinstance, colindex, rowindex)                       EX:  GridPane pane = new GridPane();                                pane.add(new Separator(), 0, 0); the above example code puts the separator on 0th row and 0th column of a gridPane.                       2. add(Node controlinstance,int colIndex,int rowIndex,int colSpan,int rowSpan)                          ...

Send SMSs with Java

Through this article I want to share some knowledge that I have on sending bulk SMSs through java and .NET applications. SMSLIB is an open source API which allows the programmers to write java or .NET code to send multiple smss to different phone numbers. It requires Mobile phone or GSM MODEM along with any SIM. Please go through this link to get the SMSLIB API.                                                    http://smslib.org/download/  

JForm: Fill the form with style

After understanding and using swing toolkit, I understood that there is a allot of scope to develop Custom components easily. I have developed a component called JForm which basically a button and its selection pops up a window if it is not visible. Technically the JForm component is a combination of 2 components they are: 1. JButton 2. Window JButton is a API of swing toolkit where as Window is a API of AWT. Behaviour of JForm: JForm is a usual button like JButton. but it is glued to a Window component. this Window takes a JPanel class as an arguments. In the given example has 2 components they are 1. JTextArea  2. JButton [Submit] which are appended to a JPanel.. The below image shows the effect before selecting the JForm: This image shown is the effect after selecting the JForm:                                       the below code is an example which i...

JColorComboBox: JComboBox as Color Chooser

  Swing toolkit provides a component called JColorChooser to choose colors. It allows users to select color from multiple color combinations. Some times our application may need simple component with an option to select only basic colors/ less number of color options unlike sepearate dialog with too may color options[JColorChooser]. This JColorComboBox may serve the need. I wanted my color chooser to behave like JComboBox. The popup shows all 12 colors and their names, among all of them one color can be choosen. see the below image. I created two classes          1. JColorComboBox          2. ColorRenderer JColorComboBox extends the JComboBox and ColorRenderer extends JLabel and implements ListCellRenderer. import java.awt.Color; import java.awt.Component; import java.awt.Font; import java.util.Enumeration; import java.util.Hashtable; import javax.swing.*; /** * * @author sharath */ public class JCol...