Program Logic & Java Graphics

can anyone provide the source code how to create a ticket system. The system should have 2 category, adults and children with a pulldown menu for how many adults or children and calculate the total price of the ticket.
example: Adult/$2.00 (the pulldown menu, 1 to 10) total
Children/$1.00(the pulldown menu, 1 to 10) total
(sum total)

Assuming this is an application, your main class is going to extend a JFrame, which is what makes a window.
We add a JPanel to that so that we have something to add our JLabels and JComboBoxes too.
I'm not doing any formatting in this example
class TicketCalculator extends JFrame
    JPanel panel = new JPanel();
    JComboBox childBox = new JComboBox();
    JComboBox adultBox = new JComboBox();
    JLabel total = new JLabel();
    //add all the JLabels
    public TicketCalculator()
        panel.add(childBox);
        panel.add(adultBox);
        panel.add(total);
        childBox.addItemListener(new ItemListener()
            public void itemStateChanged(ItemEvent e)
                 total.setText("" + calculate());
        add(panel);
        pack();
        show();
    public double calculate()
        //do calculating
        //use new Double(childBox.getSelectedItem()).doubleValue();
}

Similar Messages

  • Java graphics app prob regarding painting........ app does NOT use applets

    Hi ,
    I basically want to write a java graphics game application ......At this point in time all I want to do is add a green rectangle to the content pane.......I can do this but I want to stick with OO concepts so I have various classes......the thing is ....when a user resizes the window the graphic I have painted dissapeared
    I will show the classes I have used and the code below......I want to do the program conforming to the way I was tought java which is to have a main controlling class that orchestrates communication between unrelated classes and their methods. In addition to my question if anyone sees stuff fundementally wrong with my code and has a better solution please feel free to enlighten me :-)
    main controlling class:
    import java.awt.Graphics;
    * <p>Title: </p>
    * <p>Description: </p>
    * <p>Copyright: Copyright (c) 2005</p>
    * <p>Company: </p>
    * @author not attributable
    * @version 1.0
    public class PoolApp {
    public PoolApp() {
    //creates new gamescreen object
    GameScreen aScreen = new GameScreen(this);
    public static void main(String[] args) {
    PoolApp poolApp1 = new PoolApp();
    public Graphics getPaintedTable(GameScreen aGameScreen) {
    Paint aPaint = new Paint(this);
    Graphics tblObj = aPaint.getTbleGraphic(aGameScreen);
    return tblObj;
    ------end main controlling class
    ------TLayer Class start
    import javax.swing.*;
    /* The purpose of this class was to create a generic frame that would
    be inherited from all screen classes ...I initially had this creating a black background that would be inherited from child classes but that created
    more problems when the screen was resized by one of the child classes*/
    public class TLayer extends JFrame {
    public TLayer() {
    -----TLayer Class end
    -----GameScreen class start--------
    public class GameScreen extends TLayer{
    private PoolApp thePoolApp;
    public GameScreen(PoolApp aPoolApp) {
    thePoolApp = aPoolApp; //set a reference from here to the controlling PoolApp initGameScreen(); //initialise and show GameScreen .....screen
    public void initGameScreen() {
    this.setSize(800,600);
    this.show();
    //now make a request to the poolapp controlling class to ask for a painted green table and get the paint class to paint it to screen
    thePoolApp.getPaintedTable(this);
    ----GameScreen class end------------
    ----PaintScreen class start-------------
    PoolApp thePoolApp;
    public Paint() {
    public Paint(PoolApp apoolApp) {
    thePoolApp = apoolApp;
    public Graphics getTbleGraphic(GameScreen aGameScreen) {
    Container theCont = aGameScreen.getContentPane(); //assign the gamescreen content pane to a container
    theCont.setSize(200,200); //set a viewable size to the container
    Graphics thetbl = theCont.getGraphics(); //get container graphics context and assign it to a graphics object
    thetbl.setColor(Color.green); //color the object
    thetbl.fillRect(30,30,20,60); //fill the rectangle
    return thetbl; //return the object
    ---PaintScreen class end---------------
    This code actually draws the green rectangle to the gamescreen from the paint class .......so it works to a degree! ......whenever I resize the window the painted image dissapears, could anyone suggest a way around this also ...am I going about this the correct way? Im open to making mass changes to better the program ......the only thing I do not want is to use applets! .....as I want to learn the fundementals of custom painting my stuff
    Any help is much needed and appreciated
    David

    Hi .....I managed to fix my problem .....but I have really had to get my head around method overiding! ......Your advice is taken onboard ...also Im going to try and find a straight forward diagram of the java graphics heirrachy ......well the parts that are reasnable to what Im doing ......Also from what I know and what you have said yes threads would definately be the way to go as far as animation and paintings concerned...I plan to do some serious research on that as I progress.
    I am going to post my basic working program ........I was wandering if you think this is an effiecent way I have done this? or if you could make any recommendations? its just I dont want to adopt this approach and find its no good when I get further into the programs development :-)) anyway heres the code :
    ------Class PoolApp start--------------
    public class PoolApp {
      public PoolApp() {
        GameScreen aGScreen = new GameScreen(this);
      public static void main(String[] args) {
        PoolApp poolApp1 = new PoolApp();
    }------Class PoolApp end--------------
    ------Class TLayer start--------------
    import javax.swing.*;
    import java.awt.Graphics;
    public class TLayer extends JFrame {
      public TLayer() {
         System.out.println("In TLayer default constructor");
         this.setSize(800,600);
    }------Class TLayer end--------------
    ------Class GameScreen start--------------
    import java.awt.Graphics;
    public class GameScreen extends TLayer {
      PoolApp thepoolApp;
      Table theTable;
      Graphics g;
      public GameScreen() {
       System.out.println("In gamescreen default constructor table");
      public GameScreen(PoolApp apoolApp) {
      thepoolApp = apoolApp;
      System.out.println("In gamescreen  constructor 2");
      addTable();
    public void addTable() {
    System.out.println("in addTable");
    this.show();
    //theTable = new Draw(this);
    //theTable.setTable();
    //theTable.paint(g);
    public void paint(Graphics g) {
         System.out.println("In Gamescreen paint ");
         theTable = new Table(this);
         theTable.paint(g);
    public void update(Graphics g) {
        System.out.println("In Gamescreen update ");
        theTable = new Table(this);
        theTable.paint(g);
    }------Class GameScreen end--------------
    ------Class Table start--------------
    import java.awt.Graphics;
    import java.awt.Container;
    import java.awt.Color;
    public class Table extends TLayer{
      GameScreen thegameScreen;
      public Table() {
          System.out.println("In Table default constructor");
      public Table(GameScreen agameScreen) {
        thegameScreen = agameScreen;
        System.out.println("In Table 2nd constructor");
      public void paint(Graphics theGraphic) {
        System.out.println("In Table paint ");
        Container tablecont = thegameScreen.getContentPane();
        theGraphic = tablecont.getGraphics();
        theGraphic.setColor(Color.green);
        theGraphic.fillRect(310,220,180,80);
      public void update(Graphics theGraphic) {
           System.out.println("In Table update");
       paint(theGraphic);
    }------Class Table end--------------
    To be honest I would rather have created a table object then added it to the content pane ....but when i did it that way ......and I resized the screen the green table graphic dissapeared .....I would also have prefered all painting of the table to be done in the table class but I had the same problem of the graphic dissapearing when the window was resized and this is the best solution I have come up with as yet ....:-) .....any recommendations are greatly appreciated
    Thanks
    David

  • Specify program logic at runtime

    Hi,
    I have this requirement where the program logic is specified at runtime. My class is fairly complete except that few variables are to be created and set at runtime. Also I need to evaluate an expression made up from these created variables.
    Any suggestions ?
    In case anyone is thinking whats the need for this - I am writing a translator that is going to translate a program written in some language say 'L' to Java. One way is I can output Java code and compile and run it. But this leaves me with the situation that the users of my application have Java compiler (I can't assume that). Other way is do runtime programming - create required variables, expressions on the fly and evaluate them at runtime.
    Thanks,
    Taran

    tasingh wrote:
    I was looking for some framework or at least a design pattern hmmm,.. Strategy ?

  • Can any one please send me sample programs using java mapping..

    <b>Can any one please send me sample programs using java mapping with input and output?</b>
    please let me know how to get started with java mapping?
    Prerequisites for java mapping ?
    What are the jars need to be deployed for SAX,DOM.  And how to do it in NWDS?
    Use of Execute() and setparameter() ... StreamTransformation?
    Some sample program using java mapping with simple logic(input and output)?

    Hi,
    Did you go thro these blogs?
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-i
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-ii
    /people/prasad.ulagappan2/blog/2005/06/29/java-mapping-part-iii
    Nice blogs to start Java Mapping.
    Go thro this one too.
    /people/stefan.grube/blog/2006/10/23/testing-and-debugging-java-mapping-in-developer-studio
    Regards,
    P.Venkat
    Message was edited by:
            Venkataramanan

  • �� I have a java applet program (yanhua.java) need help!!!

    �� I have a java applet program (yanhua.java) that use mouse click a area show a fireworks, the applet program that a java fan mail me. Now i find some bug in the program, can you help me? thank in advance!
    The backdrop of the question: The yanhua.java applet program works well. But one day, i install j2re 1.4.1 plugin for my microsfot Internet Explorer, i run the yanhua.java applet program again, it show difficult(i move my mouse in the area, slowness), the fireworks is not fluent. Then i try my best to find the cause , i get some information, the following: yanhua.java run in j2re 1.4.1 plugin,it will deplete 100% cpu; else yanhua.java does not run in j2re 1.4.1 plugin, it will deplete 90%--95% cpu too; but my computer c3 1G cpu and 256MB memory, without running other program at that time. So i can have the assurance to say that the yanhua.java have some bug or error. can you help me to find all bug in yanhua.java? thank you very much!!!
    i want to solve the question: finding all bug in yanhua.java
    NOTE:
    1��fireworks show specially good effect(a yanhua.java applet) you can look at:
    http://www.3ren.net/down/java/yanhua.html
    2��all program you can get from http://www.3ren.net/down/java/yanhua.rar
    /*************************yanhua.java******************************
    import java.applet.Applet;
    import java.applet.AudioClip;
    import java.awt.*;
    import java.awt.image.MemoryImageSource;
    import java.util.Random;
    public class yanhua extends Applet
    implements Runnable
    private int m_nAppX;
    private int m_nAppY;
    private int m_centerX;
    private int m_centerY;
    private int m_mouseX;
    private int m_mouseY;
    private int m_sleepTime;
    private boolean isError;
    private boolean m_isPaintFinished;
    boolean isRunning;
    boolean isInitialized;
    Thread runner;
    int pix0[];
    MemoryImageSource offImage;
    Image dbImg;
    int pixls;
    int pixls2;
    Random rand;
    int bits;
    double bit_px[];
    double bit_py[];
    double bit_vx[];
    double bit_vy[];
    int bit_sx[];
    int bit_sy[];
    int bit_l[];
    int bit_f[];
    int bit_p[];
    int bit_c[];
    int bit_max;
    int bit_sound;
    int ru;
    int rv;
    AudioClip sound1;
    AudioClip sound2;
    public yanhua()
    m_mouseX = 0;
    m_mouseY = 0;
    m_sleepTime = 5;
    isError = false;
    isInitialized = false;
    rand = new Random();
    bits = 10000;
    bit_px = new double[bits];
    bit_py = new double[bits];
    bit_vx = new double[bits];
    bit_vy = new double[bits];
    bit_sx = new int[bits];
    bit_sy = new int[bits];
    bit_l = new int[bits];
    bit_f = new int[bits];
    bit_p = new int[bits];
    bit_c = new int[bits];
    ru = 50;
    rv = 50;
    public void init()
    String s = getParameter("para_bits");
    if(s != null)
    bits = Integer.parseInt(s);
    s = getParameter("para_max");
    if(s != null)
    bit_max = Integer.parseInt(s);
    s = getParameter("para_blendx");
    if(s != null)
    ru = Integer.parseInt(s);
    s = getParameter("para_blendy");
    if(s != null)
    rv = Integer.parseInt(s);
    s = getParameter("para_sound");
    if(s != null)
    bit_sound = Integer.parseInt(s);
    m_nAppX = this.getSize().width;
    m_nAppY = this.getSize().height;
    m_centerX = m_nAppX / 2;
    m_centerY = m_nAppY / 2;
    m_mouseX = m_centerX;
    m_mouseY = m_centerY;
    resize(m_nAppX, m_nAppY);
    pixls = m_nAppX * m_nAppY;
    pixls2 = pixls - m_nAppX * 2;
    pix0 = new int[pixls];
    offImage = new MemoryImageSource(m_nAppX, m_nAppY, pix0, 0, m_nAppX);
    offImage.setAnimated(true);
    dbImg = createImage(offImage);
    for(int i = 0; i < pixls; i++)
    pix0[i] = 0xff000000;
    sound1 = getAudioClip(getDocumentBase(), "firework.au");
    sound2 = getAudioClip(getDocumentBase(), "syu.au");
    for(int j = 0; j < bits; j++)
    bit_f[j] = 0;
    isInitialized = true;
    start();
    public void run()
    while(!isInitialized)
    try
    Thread.sleep(200L);
    catch(InterruptedException interruptedexception) { }
    do
    for(int j = 0; j < pixls2; j++)
    int k = pix0[j];
    int l = pix0[j + 1];
    int i1 = pix0[j + m_nAppX];
    int j1 = pix0[j + m_nAppX + 1];
    int i = (k & 0xff0000) >> 16;
    int k1 = ((((l & 0xff0000) >> 16) - i) * ru >> 8) + i;
    i = (k & 0xff00) >> 8;
    int l1 = ((((l & 0xff00) >> 8) - i) * ru >> 8) + i;
    i = k & 0xff;
    int i2 = (((l & 0xff) - i) * ru >> 8) + i;
    i = (i1 & 0xff0000) >> 16;
    int j2 = ((((j1 & 0xff0000) >> 16) - i) * ru >> 8) + i;
    i = (i1 & 0xff00) >> 8;
    int k2 = ((((j1 & 0xff00) >> 8) - i) * ru >> 8) + i;
    i = i1 & 0xff;
    int l2 = (((j1 & 0xff) - i) * ru >> 8) + i;
    int i3 = ((j2 - k1) * rv >> 8) + k1;
    int j3 = ((k2 - l1) * rv >> 8) + l1;
    int k3 = ((l2 - i2) * rv >> 8) + i2;
    pix0[j] = i3 << 16 | j3 << 8 | k3 | 0xff000000;
    rend();
    offImage.newPixels(0, 0, m_nAppX, m_nAppY);
    try
    Thread.sleep(m_sleepTime);
    catch(InterruptedException interruptedexception1) { }
    } while(true);
    public void update(Graphics g)
    paint(g);
    public void paint(Graphics g)
    g.drawImage(dbImg, 0, 0, this);
    public void start()
    if(isError)
    return;
    isRunning = true;
    if(runner == null)
    runner = new Thread(this);
    runner.start();
    public void stop()
    if(runner != null)
    runner.stop();
    runner = null;
    public boolean mouseMove(Event event, int i, int j)
    m_mouseX = i;
    m_mouseY = j;
    return true;
    public boolean mouseDown(Event event, int i, int j)
    m_mouseX = i;
    m_mouseY = j;
    int k = (int)(rand.nextDouble() * 256D);
    int l = (int)(rand.nextDouble() * 256D);
    int i1 = (int)(rand.nextDouble() * 256D);
    int j1 = k << 16 | l << 8 | i1 | 0xff000000;
    int k1 = 0;
    for(int l1 = 0; l1 < bits; l1++)
    if(bit_f[l1] != 0)
    continue;
    bit_px[l1] = m_mouseX;
    bit_py[l1] = m_mouseY;
    double d = rand.nextDouble() * 6.2800000000000002D;
    double d1 = rand.nextDouble();
    bit_vx[l1] = Math.sin(d) * d1;
    bit_vy[l1] = Math.cos(d) * d1;
    bit_l[l1] = (int)(rand.nextDouble() * 100D) + 100;
    bit_p[l1] = (int)(rand.nextDouble() * 3D);
    bit_c[l1] = j1;
    bit_sx[l1] = m_mouseX;
    bit_sy[l1] = m_nAppY - 5;
    bit_f[l1] = 2;
    if(++k1 == bit_max)
    break;
    if(bit_sound > 1)
    sound2.play();
    return true;
    public boolean mouseExit(Event event, int i, int j)
    m_mouseX = i;
    m_mouseY = j;
    return true;
    void rend()
    boolean flag = false;
    boolean flag1 = false;
    boolean flag2 = false;
    for(int k = 0; k < bits; k++)
    switch(bit_f[k])
    default:
    break;
    case 1: // '\001'
    bit_vy[k] += rand.nextDouble() / 50D;
    bit_px[k] += bit_vx[k];
    bit_py[k] += bit_vy[k];
    bit_l[k]--;
    if(bit_l[k] == 0 || bit_px[k] < 0.0D || bit_py[k] < 0.0D || bit_px[k] > (double)m_nAppX || bit_py[k] > (double)(m_nAppY - 3))
    bit_c[k] = 0xff000000;
    bit_f[k] = 0;
    } else
    if(bit_p[k] == 0)
    if((int)(rand.nextDouble() * 2D) == 0)
    bit_set((int)bit_px[k], (int)bit_py[k], -1);
    } else
    bit_set((int)bit_px[k], (int)bit_py[k], bit_c[k]);
    break;
    case 2: // '\002'
    bit_sy[k] -= 5;
    if((double)bit_sy[k] <= bit_py[k])
    bit_f[k] = 1;
    flag2 = true;
    if((int)(rand.nextDouble() * 20D) == 0)
    int i = (int)(rand.nextDouble() * 2D);
    int j = (int)(rand.nextDouble() * 5D);
    bit_set(bit_sx[k] + i, bit_sy[k] + j, -1);
    break;
    if(flag2 && bit_sound > 0)
    sound1.play();
    void bit_set(int i, int j, int k)
    int l = i + j * m_nAppX;
    pix0[l] = k;
    /*********************************end*******************************

    no one help me???????????

  • Problem with programming logic in code

    I have hit a programming logic problem. What I wanted is for my main program to create a jDialog according to user's choice selection from a jOptionPane and the code in the main body to stop running and rather wait for the user to select the option in the jDialog and then go back to running the main code body but somehow my program doesn't work that way. Anyone have any ideas how to fix it ?
    Object[] obj = {"Specific Date","Month/Year"};
                String input = (String) JOptionPane.showInputDialog(this,"Choose the following ways to select a date.","Select Date",JOptionPane.INFORMATION_MESSAGE,null,obj,obj[0]);
                if(input.equals("Specific Date")){
                    jDialog1.setSize(400,250);
                    jDialog1.setVisible(true);
                    //while(option!=1){
                    //System.out.println("waiting");
                    if(option==1){
                        System.out.println("Year: "+chosenYear);
                        //break;
                        data.append("<H1>Other Day / Month / Year Record</H1>");
                        data.append("<p>Date: "+todayDay+"/"+todayMonth+"/"+todayYear+"</p><br>");
                        System.out.println("breaking out soon...");
                } else if(input.equals("Month/Year")){
                    jDialog2.setSize(300,200);
                    jDialog2.setVisible(true);
                    //while(option!=1){
                    //System.out.println("waiting");
                    if(option==1){
                        System.out.println("Year: "+chosenYear);
                        //break;
                        data.append("<H1>Other Day / Month / Year Record</H1>");
                        data.append("<p>Date: "+todayDay+"/"+todayMonth+"/"+todayYear+"</p><br>");
                        System.out.println("breaking out soon...");
    //            data.append("<H1>Other Day / Month / Year Record</H1>");
    //            data.append("<p>Date: "+todayDay+"/"+todayMonth+"/"+todayYear+"</p><br>");
                System.out.println("break executed...");As you can see...I was originally thinking to use a while loop but it failed so I commented it out. I have been stuck in this programming logic of waiting for the user to choose an option form the jDialog before continuning in the main body. The jDialogs are already initiatized and both jDialogs would set the 'option' variable which has been init earlier on (the code is really too long to be placed here to '1' when it is ready for the program to resume to run the main body of the codes as you can see.
    So anyone have any ideas how to get it solved ?
    I do need a solution fast because these codes have a deadline in 2 weeks time.
    null

    Here's the entire code for this java class.
    * ExportRecord.java
    * Created on September 7, 2007, 2:03 PM
    package lkgaccount;
    import java.util.ArrayList;
    import java.util.Calendar;
    import javax.swing.*;
    import java.awt.*;
    import java.io.*;
    * @author  Owner
    public class ExportRecord extends javax.swing.JInternalFrame {
        export exp = new export();
        String filepath = "";
        File toFile;
        StringBuffer data;
        HTMLBrowser htmlbrowser;
        int subOption = 0;
        int chosenDay;
        int chosenMonth;
        String chosenMth;
        int chosenYear;
        CodeManager cm = new CodeManager();
        /** Creates new form ExportRecord */
        public ExportRecord() {
            initComponents();
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
        private void initComponents() {
            jDialog1 = new javax.swing.JDialog();
            jPanel2 = new javax.swing.JPanel();
            jButton6 = new javax.swing.JButton();
            jLabel6 = new javax.swing.JLabel();
            jCalendar1 = new com.toedter.calendar.JCalendar();
            jDialog2 = new javax.swing.JDialog();
            jPanel4 = new javax.swing.JPanel();
            jButton10 = new javax.swing.JButton();
            jLabel7 = new javax.swing.JLabel();
            jComboBox2 = new javax.swing.JComboBox();
            jSpinner1 = new javax.swing.JSpinner();
            jLabel8 = new javax.swing.JLabel();
            jLabel1 = new javax.swing.JLabel();
            jComboBox1 = new javax.swing.JComboBox();
            jButton1 = new javax.swing.JButton();
            jLabel2 = new javax.swing.JLabel();
            jTextField1 = new javax.swing.JTextField();
            jLabel3 = new javax.swing.JLabel();
            jTextField2 = new javax.swing.JTextField();
            jButton2 = new javax.swing.JButton();
            jLabel4 = new javax.swing.JLabel();
            jTextField3 = new javax.swing.JTextField();
            jLabel5 = new javax.swing.JLabel();
            jPanel1 = new javax.swing.JPanel();
            jButton5 = new javax.swing.JButton();
            jButton4 = new javax.swing.JButton();
            jButton3 = new javax.swing.JButton();
            jDialog1.setTitle("Search By Date");
            jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Search By: Date ", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
            jButton6.setText("Submit");
            jButton6.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton6ActionPerformed(evt);
            jLabel6.setText("Date Parameter:");
            javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
            jPanel2.setLayout(jPanel2Layout);
            jPanel2Layout.setHorizontalGroup(
                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel6)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jCalendar1, javax.swing.GroupLayout.PREFERRED_SIZE, 228, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                    .addContainerGap(255, Short.MAX_VALUE)
                    .addComponent(jButton6)
                    .addContainerGap())
            jPanel2Layout.setVerticalGroup(
                jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel6)
                        .addComponent(jCalendar1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                    .addComponent(jButton6)
                    .addContainerGap())
            jDialog1.getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);
            jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true), "Search By: Month/Year", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 11)));
            jButton10.setText("Submit");
            jButton10.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton10ActionPerformed(evt);
            jLabel7.setText("Month: ");
            jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "*" }));
            jLabel8.setText(" Year:    ");
            javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
            jPanel4.setLayout(jPanel4Layout);
            jPanel4Layout.setHorizontalGroup(
                jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel4Layout.createSequentialGroup()
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel7)
                                .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, 51, Short.MAX_VALUE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jSpinner1)
                                .addComponent(jComboBox2, 0, 167, Short.MAX_VALUE)))
                        .addComponent(jButton10, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addContainerGap())
            jPanel4Layout.setVerticalGroup(
                jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel4Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel7)
                        .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel8))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton10)
                    .addContainerGap())
            jDialog2.getContentPane().add(jPanel4, java.awt.BorderLayout.CENTER);
            setTitle("Export Record");
            jLabel1.setText("Export by: ");
            jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Daily Record", "Current Month's Record", "Current Year's Record", "Other Day / Month / Year Record", "Supplier Names", "All Account Records" }));
            jButton1.setText("Close");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jLabel2.setText("Export as: ");
            jTextField1.setEditable(false);
            jTextField1.setText(".html");
            jLabel3.setText("Save to: ");
            jButton2.setText("...");
            jButton2.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton2ActionPerformed(evt);
            jLabel4.setText("File Name: ");
            jLabel5.setText("( do not add a file extension behind )");
            jButton5.setText("Clear");
            jButton5.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton5ActionPerformed(evt);
            jPanel1.add(jButton5);
            jButton4.setText("Preview");
            jButton4.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton4ActionPerformed(evt);
            jPanel1.add(jButton4);
            jButton3.setText("Export");
            jButton3.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton3ActionPerformed(evt);
            jPanel1.add(jButton3);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(jLabel1)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jLabel3)
                                        .addComponent(jLabel2)
                                        .addComponent(jLabel4))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                                        .addComponent(jTextField1)
                                        .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                                        .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE))))))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(12, 12, 12)
                            .addComponent(jButton1))
                        .addGroup(layout.createSequentialGroup()
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel1)
                        .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jButton2)
                        .addComponent(jLabel3))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel5)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addContainerGap())
            pack();
        }// </editor-fold>//GEN-END:initComponents
        private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
    // TODO add your handling code here:
            String mth = (String)jComboBox2.getSelectedItem();
            Integer yr = (Integer)jSpinner1.getValue();
            subOption = 2;
            chosenMth = mth;
            chosenYear = (int)yr;
        }//GEN-LAST:event_jButton10ActionPerformed
        private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
    // TODO add your handling code here:
            Calendar calendar = jCalendar1.getCalendar();
            int day = calendar.get(Calendar.DATE);
            int month = calendar.get(Calendar.MONTH);
            int year = calendar.get(Calendar.YEAR);
            month ++;
            System.out.println("calendar: "+day+"/"+month+"/"+year);
            subOption = 1;
            chosenDay = day;
            chosenMonth = month;
            chosenYear = year;
        }//GEN-LAST:event_jButton6ActionPerformed
        private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    // TODO add your handling code here:
            int index = jComboBox1.getSelectedIndex();
            String folderExt = jTextField2.getText();
            String fileName = jTextField3.getText();
            String urlpath = folderExt+"\\"+fileName+".html";
            System.out.println(urlpath);
            if(folderExt.equals("")||fileName.equals("")){
                JOptionPane.showMessageDialog(this,"Please specific which folder and the name of the file you want to save your exported documents.","Folder and file not specified",JOptionPane.INFORMATION_MESSAGE);
            } else{
                toFile = new File(urlpath);
                if(toFile.exists()){
                    JOptionPane.showMessageDialog(this,urlpath+" has already existed. Please enter a new file name. ","File Exist",JOptionPane.WARNING_MESSAGE);
                data = new StringBuffer();
                data = getData(data,index,fileName);
                exp.writeHTML(data,toFile);
                if(htmlbrowser!=null){
                    htmlbrowser.dispose();
                    htmlbrowser = new HTMLBrowser("file:/"+urlpath);
                    htmlbrowser.setVisible(true);
                } else{
                    htmlbrowser = new HTMLBrowser("file:/"+urlpath);
                    htmlbrowser.setVisible(true);
        }//GEN-LAST:event_jButton3ActionPerformed
        private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    // TODO add your handling code here:
            int index = jComboBox1.getSelectedIndex();
            toFile = new File("C:\\Documents and Settings\\Owner\\LKGAccount\\dist\\preview.html");
            if(toFile.exists()){
            data = new StringBuffer();
            data = getData(data,index,"Preview");
            exp.writeHTML(data,toFile);
            if(htmlbrowser!=null){
                htmlbrowser.dispose();
                htmlbrowser = new HTMLBrowser("file:/C:\\Documents and Settings\\Owner\\LKGAccount\\dist\\preview.html");
                htmlbrowser.setVisible(true);
            } else{
                htmlbrowser = new HTMLBrowser("file:/C:\\Documents and Settings\\Owner\\LKGAccount\\dist\\preview.html");
                htmlbrowser.setVisible(true);
        }//GEN-LAST:event_jButton4ActionPerformed
        private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    // TODO add your handling code here:
            jComboBox1.setSelectedIndex(0);
            jTextField2.setText("");
            jTextField3.setText("");
        }//GEN-LAST:event_jButton5ActionPerformed
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    // TODO add your handling code here:
            this.dispose();
        }//GEN-LAST:event_jButton1ActionPerformed
        private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:
            JFileChooser chooser = new JFileChooser();
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            int returnVal = chooser.showOpenDialog(this);
            if(returnVal == JFileChooser.APPROVE_OPTION) {
                filepath = chooser.getSelectedFile().getAbsolutePath();
            jTextField2.setText(filepath);
        }//GEN-LAST:event_jButton2ActionPerformed
        public StringBuffer getData(StringBuffer data, int option, String filename){
            ArrayList aList = new ArrayList();
            Date date = new Date();
            int todayDay = date.getDay();
            int todayMonth = date.getMonth();
            int todayYear = date.getYear();
            data.append("<html>");
            data.append("<head>");
            data.append("<title>Lim Kim Guan Accounting Record: "+filename+"</title>");
            data.append("</head>");
            data.append("<body>");
            if(option==0){
                data.append("<H1>Daily Record</H1>");
                data.append("<p>Date: "+todayDay+"/"+todayMonth+"/"+todayYear+"</p><br>");
                aList = cm.searchByDate(todayDay,todayMonth,todayYear);
                if(aList==null||aList.isEmpty()){
                    data.append("<p><center><b>There is no data transaction for today.</b></center></p>");
                } else{
                    data.append("<center><table border=\"1\">");
                    data.append("<tr>");
                    data.append("<td colspan=\"7\"><center><b>Accounting Records</b></center></td>");
                    data.append("</tr>");
                    data.append("<tr>");
                    data.append("<td><center><B>Acct ID</B></center></td>");
                    data.append("<td><center><B>Supplier Name</B></center></td>");
                    data.append("<td><center><B>Invoice #</B></center></td>");
                    data.append("<td><center><B>Original $ before GST</B></center></td>");
                    data.append("<td><center><B>GST(%)</B></center></td>");
                    data.append("<td><center><B>$ after GST</B></center></td>");
                    data.append("<td><center><B>Date</B></center></td>");
                    data.append("</tr>");
                    for(int i=0;i<aList.size();i++){
                        account acct = (account)aList.get(i);
                        if(acct != null) {
                            data.append("<tr>");
                            data.append("<td>"+Integer.toString(acct.getId())+"</td>");
                            data.append("<td>"+acct.getSupplierName()+"</td>");
                            data.append("<td>"+acct.getInvoiceid()+"</td>");
                            data.append("<td>"+Double.toString(acct.getBeforeGST$())+"</td>");
                            data.append("<td>"+Integer.toString(acct.getGst())+"</td>");
                            data.append("<td>"+Double.toString(acct.getAfterGST$())+"</td>");
                            data.append("<td>"+acct.getDay()+" / "+acct.getMonth()+" / "+acct.getYear()+"</td>");
                            data.append("</tr>");
                    data.append("</table></center>");
            } else if(option==1){
                data.append("<H1>Current Month's Record</H1>");
                data.append("<p>Date: "+todayDay+"/"+todayMonth+"/"+todayYear+"</p><br>");
                aList = cm.searchByIntMonthYear(todayMonth,todayYear);
                if(aList==null||aList.isEmpty()){
                    data.append("<p><center><b>There is no data transaction for current month.</b></center></p>");
                } else{
                    data.append("<center><table border=\"1\">");
                    data.append("<tr>");
                    data.append("<td colspan=\"7\"><center><b>Accounting Records</b></center></td>");
                    data.append("</tr>");
                    data.append("<tr>");
                    data.append("<td><center><B>Acct ID</B></center></td>");
                    data.append("<td><center><B>Supplier Name</B></center></td>");
                    data.append("<td><center><B>Invoice #</B></center></td>");
                    data.append("<td><center><B>Original $ before GST</B></center></td>");
                    data.append("<td><center><B>GST(%)</B></center></td>");
                    data.append("<td><center><B>$ after GST</B></center></td>");
                    data.append("<td><center><B>Date</B></center></td>");
                    data.append("</tr>");
                    for(int i=0;i<aList.size();i++){
                        account acct = (account)aList.get(i);
                        if(acct != null) {
                            data.append("<tr>");
                            data.append("<td>"+Integer.toString(acct.getId())+"</td>");
                            data.append("<td>"+acct.getSupplierName()+"</td>");
                            data.append("<td>"+acct.getInvoiceid()+"</td>");
                            data.append("<td>"+Double.toString(acct.getBeforeGST$())+"</td>");
                            data.append("<td>"+Integer.toString(acct.getGst())+"</td>");
                            data.append("<td>"+Double.toString(acct.getAfterGST$())+"</td>");
                            data.append("<td>"+acct.getDay()+" / "+acct.getMonth()+" / "+acct.getYear()+"</td>");
                            data.append("</tr>");
                    data.append("</table></center>");
            } else if(option==2){
                data.append("<H1>Current Year's Record</H1>");
                data.append("<p>Date: "+todayDay+"/"+todayMonth+"/"+todayYear+"</p><br>");
                aList = cm.searchByMonthYear("*",todayYear);
                if(aList==null||aList.isEmpty()){
                    data.append("<p><center><b>There is no data transaction for today.</b></center></p>");
                } else{
                    data.append("<center><table border=\"1\">");
                    data.append("<tr>");
                    data.append("<td colspan=\"7\"><center><b>Accounting Records</b></center></td>");
                    data.append("</tr>");
                    data.append("<tr>");
                    data.append("<td><center><B>Acct ID</B></center></td>");
                    data.append("<td><center><B>Supplier Name</B></center></td>");
                    data.append("<td><center><B>Invoice #</B></center></td>");
                    data.append("<td><center><B>Original $ before GST</B></center></td>");
                    data.append("<td><center><B>GST(%)</B></center></td>");
                    data.append("<td><center><B>$ after GST</B></center></td>");
                    data.append("<td><center><B>Date</B></center></td>");
                    data.append("</tr>");
                    for(int i=0;i<aList.size();i++){
                        account acct = (account)aList.get(i);
                        if(acct != null) {
                            data.append("<tr>");
                            data.append("<td>"+Integer.toString(acct.getId())+"</td>");
                            data.append("<td>"+acct.getSupplierName()+"</td>");
                            data.append("<td>"+acct.getInvoiceid()+"</td>");
                            data.append("<td>"+Double.toString(acct.getBeforeGST$())+"</td>");
                            data.append("<td>"+Integer.toString(acct.getGst())+"</td>");
                            data.append("<td>"+Double.toString(acct.getAfterGST$())+"</td>");
                            data.append("<td>"+acct.getDay()+" / "+acct.getMonth()+" / "+acct.getYear()+"</td>");
                            data.append("</tr>");
                    data.append("</table></center>");
            } else if(option==3){
                data.append("<H1>Other Day / Month / Year Record</H1>");
                data.append("<p>Date: "+todayDay+"/"+todayMonth+"/"+todayYear+"</p><br>");
                Object[] obj = {"Specific Date","Month/Year"};
                String input = (String) JOptionPane.showInputDialog(this,"Choose the following ways to select a date.","Select Date",JOptionPane.INFORMATION_MESSAGE,null,obj,obj[0]);
                if(input.equals("Specific Date")){
                    jDialog1.setSize(400,250);
                    jDialog1.setVisible(true);
                    while(true){
                        System.out.println("waiting");
                        if(subOption==1){
                            System.out.println("Year: "+chosenYear);
                            break;
                } else if(input.equals("Month/Year")){
                    jDialog2.setSize(300,200);
                    jDialog2.setVisible(true);
                    while(true){
                        System.out.println("waiting");
                        if(subOption==2){
                            System.out.println("Year: "+chosenYear);
                            break;
                System.out.println("break executed...");      
            } else if(option==4){
                data.append("<H1>Supplier Names</H1>");
                data.append("<p>Date: "+todayDay+"/"+todayMonth+"/"+todayYear+"</p><br>");
                aList = cm.getCompanyList();
                if(aList==null||aList.isEmpty()){
                    data.append("<p><center><b>There is no data transaction for today.</b></center></p>");
                } else{
                    data.append("<center><table border=\"1\">");
                    data.append("<tr>");
                    data.append("<td colspan=\"1\"><center><b>Supplier Names</b></center></td>");
                    data.append("</tr>");
                    for(int i=0;i<aList.size();i++){
                        String result = (String)aList.get(i);
                        if(result != null||result.isEmpty()) {
                            data.append("<tr>");
                            data.append("<td>"+result+"</td>");
                            data.append("</tr>");
                    data.append("</table></center>");
            } else if(option==5){
                data.append("<H1>All Account Records</H1>");
                data.append("<p>Date: "+todayDay+"/"+todayMonth+"/"+todayYear+"</p><br>");
                aList = cm.getAccountRecords();
                if(aList==null||aList.isEmpty()){
                    data.append("<p><b>There is no data transaction for today.</b></p>");
                } else{
                    data.append("<center><table border=\"1\">");
                    data.append("<tr>");
                    data.append("<td colspan=\"7\"><center><b>Accounting Records</b></center></td>");
                    data.append("</tr>");
                    data.append("<tr>");
                    data.append("<td                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

  • N-tiered programming in Java

    I'm new to Java/JSP and am looking for tutorials and examples of how to do web n-tiered programming in Java. In .NET, I've often separated the web presentation layer from the business logic and data access layers. How do you accomplish this in Java? Thank you.

    What do you mean "accomplish"? You write java classes. N-tiered architecture is not limited to specific programming languages. It is a paradigm.
    Additionally, check this out: http://java.sun.com/blueprints/corej2eepatterns/Patterns/

  • Compression program in java

    hello all,
    any idea how to write a file compression program in java.
    any help would be appreciated.
    thanx

    The same way you would write a compression program in any other language.
    Open a stream for the file to be compressed
    Open a stream for the compressed file, add a filter-stream (according to your choice of algorithm) to the stream for the compressed file.
    Read from one stream, write to the other.
    For uncompressing, reverse the above. :)
    With java you have some small addenums that are useful, like the java.util.zip classes if it is basic zip-functionality that you want.
    Once all this is done, as sugar on the top, fix a nice gui involving JTable, JTree and other eminent swing-components of your choice.
    A fair bit of warning, if you want to use the JFileChooser for your logical file-view inside a compressed file, you are in for a ride. You will have to make your own FileView and File object. The java.io.File object is badly designed and it will be a long hassle to make it work, but it can be done.
    Yours sincerely
    Peter Norell

  • When i click on the Firefox icon I get an error message, C:\Program Files\Java\jre6\lib\deploy\jqs\ff\..\..\..\..\bin\jqsnotify\.exe cannot be found. What is it? and how do i fix it? in English

    When i click on the icon to open Firefox an error message box appears with the following message, C:\Program Files\Java\jre6\lib\deploy\jqs\ff\..\..\..\..\bin\jqsnotify\.exe cannot be found. It then advises me to use the Search function, but the search function says it is unavailable.
    What is it? and how do I fix it? in English

    See:
    http://www.java.com/en/download/help/quickstarter.xml - What is Java Quick Starter (JQS)? What is the benefit of running JQS? - 6.0

  • How to execute external program in java?

    My question is how to execute an external program in java.
    I need to call a unix command in java.
    Thanks.

    it depends on what you are trying to do. Following are the two methods
    1. Runtime.exec() : this method allows you just to call an external program as a seperate process
    2. JNI (Native Interface) :- As of right now only C and C++ are supported by this method. This method allows you to directly call the C/C++ methods from JAVA

  • How Can I execute a java program using java code?

    {color:#000000}Hello,
    i am in great trouble someone please help me. i want to execute java program through java code i have compiled the java class using Compiler API now i want to execute this Class file through java code please help me, thanks in advance
    {color}

    Thanks Manko.
    i think my question was not clear enough.. actually i want to run this class using some java code . like any IDE would do i am making a text editor for java, as my term project i have been able to complie the code usign compiler api and it genertaes the class file but now i want to run this class file "THROUGH JAVA CODE" instead of using Java command. I want to achive it programatically. do you have any idea about it.. thanks in advance

  • How to create a  schedule program in java

    Hello Friends ,
    Can any one provide me with an example how to create a schedule program using java.util.timer etc . I am in need of a program which should run as a schedule job that searches for a file in a directory and read the latest files from that directory in every minute of time as a schedule job .
    Thanks
    mahesh

    I don't feel like writing my own example, but google will be happy to provide you with an example.

  • New "Windows Programming Using Java" Website

    Our newly created "Windows Programming Using Java" website (http://fivedots.coe.psu.ac.th/~ad/winJava/) is for programmers who want to extend Java's capabilities on Windows XP and/or Vista, but aren't sure where to start. One of the drawbacks of Java's portability is that many Java programmers have a rather sketchy knowledge of Windows-specific programming.
    We plan to explain how Java applications can utilize Windows application software, OS features, and hardware beyond the reach of Java's standard libraries. A variety of Java/Windows programming techniques will be explained, including:
    * Java's employment of the Win32 API via C, JNI, and J/Invoke.
    * Java's utilization of Window's Command Line Interface (CLI) and batch files, accessed through Java's Runtime, ProcessBuilder, and Process classes.
    * Java and Windows object-based scripting, centered around the use of VBScript, Windows Script Host (WSH), and Windows Management Instrumentation (WMI).
    * Java interoperability with COM, including hosting of ActiveX controls in Swing containers using jacoZoom.
    This website is a work in progress, with four chapters available for download at the moment. We'll be adding more regularly, and would love feedback on what we're doing.
    Thanks,
    Gayathri Singh and Andrew Davison
    [email protected] and [email protected]
    Edited by: AndrewDavison on Jun 20, 2008 1:36 AM

    Hi, I am looking the similar kind of requirement that you had done.. Do you have any more details on the code that is working for you . All i need is if the user logs in successfully in windows, the the app should be accessible. Please let me know if you have the code with you on this problem.
    Thanks in advance
    "what i meant is the we b applications running in my system, when i access the application iam able to to login automatically with windows authentication and now in case of other users following process happened:"

  • Asynchronous socket programming in Java?

    I am a C++ programmer, I just wonder how do I do asynchronous programming in Java?
    In VC++, you can hook an event handler to the socket and the system will fire an event whenever there is data coming in to the socket. The event handler can then spawn a thread and handle the network message.
    In Unix, you can use the select() function. This function will return whenever the indicated socket fires events. If nothing happens within the timeout period, the function simply returns.
    What about in Java? I don't see any methods that allows you to hook an event handler to it. Is there anything like select() function in Unix?
    Thanks so much.

    There is something very much like C's select: selectors. I don't immediately know where to read more about them but google for things like "java selector example", "java nio tutorial", etc (NIO = new I/O, the library where selectors live.)
    Another way to do async sockets in Java is by threading. That is the traditional way before New I/O. It's still a perfectly good and easy way, thanks to Java's easy threading. Downside is that it scales to only maybe 100-200 simultaneous connections per server (will depend on your operating system). For thread-based sockets check Sun's Java socket tutorial (first item when you google "java socket tutorial").

  • How Hard is it to program in Java.Swing

    Hi
    I wanted to program using java.swing component but i don't have any idea where i should start.
    I have been programming in java using java.Awt
    and i can do simple array programing.
    So how hard is it, and Where should i start learning java.swing. Ps I don't know anything about Swing, I don't even know what it is.
    Thanks you

    Hi
    As the previous guy said it is quite easy, and that link should teach you the basics. What I want to remind you of is that Swing uses up more memory when run. But it also have a few nicer extra goodies that make coding a little bit easier. Have fun with it.
    Here are a few more sites
    <http://manning.spindoczine.com/sbe/>
    <http://java.sun.com/docs/books/tutorial/uiswing/>
    Ciao

Maybe you are looking for

  • How to create On Account Credit Memo in R12.1.3

    Hello Experts / Dina, Oracle claims that there is new feature of creating credit memo On Account can be done by using Oracle Projects billing with R12.1.3 only. For the same they say that:- The Interface Invoices to Receivables process creates credit

  • BB Curve - Power Suplly

    In 3 months time, it's the second time that my BB Curve won't receive powe. The first time Vodafone Portugal (where I bought th BB) said that the warranty had ended and that de BB could not be repaired. So, i bought a new one... Today, only 3 months

  • Chinese characters dont show up on the PDF file

    Hi guys, Chinese characters dont show up on the PDF file. Its #. Please let know how to fix it. Thanks!

  • How do i add Linux systems to be monitored using Virtual agent/SNMP in OLT?

    Dear All, I need to know the process to add Linux systems to be monitored using Virtual agent and SNMP in OLT ? I have added my details to Virtual agent and chosen ssh and all i get is cannot connect Appreciate if someone can give me the detailed scr

  • QM tables relationship

    Can anyone provide me QM tables relationship diagram.