Showing posts with label Java Desktop Application. Show all posts
Showing posts with label Java Desktop Application. Show all posts

Monday, February 16, 2015

Making an application Launcher for a Java(Jar) Application

After installing the Java runtime environment you can create a launch icon like other applications in the sistem by making a *.desktop file.
It makes things easier and prettier!
  • Create a folder in a directory of your choice with the *.jar (the application) and *.png (the application icon) files. In this case the directory I will use is /usr/share/folder. For the ~/folderis a good idea to name it with the application name, for example, if the application is VUE name the folder ~/VUE or ~/vue.
    Open the terminal and run the following code line:
    sudo mkdir /usr/share/folder
    Or open your file manager (Nautilus in this case) with super admin privileges by runing the following code line in the terminal:
    gksu nautilus
    After that, go to /usr/share and create the folder folder with the GUI.
  • Also in the terminal and run the following code line:
    sudo gedit /usr/share/applications/*.desktop
(You could use your editor of choice. In this case was used Gedit.)
  • Paste the following code lines in the file you are editing:
    #!/usr/bin/env xdg-open
    [Desktop Entry]
    Version=1.0
    Type=Application
    Terminal=false
    Icon[en_US]=/usr/share/HomeAccountant/HomeAccountant.png
    Name[en_US]=HomeAccountant
    Exec=java -jar /usr/share/HomeAccountant/HomeAccountant.jar
    Comment[en_US]=Home Accountant
    Name=HomeAccountant
    Comment=Home Accountant
    Icon=gnome-panel-launcher
  • Save the file.

Thursday, August 21, 2014

Layout in Java Desktop Application

In general, layout managers are objects used in widget toolkits that have the ability to arrange widgets by their relative positions. Java uses layout managers to arrange components in a consistent manner across all windowing platforms.
In this section, we will introduce the following Swing layout managers:
Layout ManagerDescription
FlowLayoutObjects that arrange components in a directional flow, much like lines of text in a paragraph.
GridLayoutObjects that divide the container into equal-sized rectangles and arrange each component into one of these cells.
BorderLayoutObjects that arrange components to the top, bottom, left, right, and center of a container.
To demonstrate these layout managers, we will create an Applet that allows the user to select a layout manager from a list and see the effects it has on some Swing components. In this implementation, we use a BorderLayout manager to place a drop-down list above a panel that contains serveral Swing components (buttons). When an item in the drop-down list is selected, the layout manager for the panel is changed, and without explicitly setting the bounds of any components, the layout manager rearranges the buttons.

Monday, February 3, 2014

jasperviewer closes main application

at the time of closing jasperviewer report that is opened up, main application window is closed at the same time.To get rid form this problem:

in the constructor of JasperViewer there is boolean indicating whehter it should perform an exit on close.

jasperReport = JasperCompileManager.compileReport( "reportloh.jrxml");
jasperPrint = JasperFillManager.fillReport( jasperReport, parameters, conn);
JasperViewer jv = new JasperViewer( jasperPrint, false );
jv.viewReport( jasperPrint, false );
 

Thursday, January 2, 2014

Java Desktop Applicaiotn in Netbeans: To open a JFrame by clicking a button of another

Double click the specific button in the add the Event Listener on Click Event (ActionListener) 
 
 
public void actionPerformed(ActionEvent e) {
        //  this.setVisible(false);
        this.dispose();
        new FrmMain().setVisible(true); // Main Form to show after the Login Form..
    }

Java Desktop Application using Netebans: How to position the form in the center screen?

In design mode:
select your JFrame(on Design mode), and then go to  Properties, Bindings,Events, Code. 
We need "Code" and set properties Generate Center (true) that's all. 


--
Another way through code:
 
JFrame frame = new JFrame("FooRendererTest");
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.getContentPane().add(mainPanel); // or whatever...
  frame.pack();
  frame.setLocationRelativeTo(null);  // *** this will center your app ***
  frame.setVisible(true);