com.main.MainPageView.java Source code

Java tutorial

Introduction

Here is the source code for com.main.MainPageView.java

Source

/*
 * Created by JFormDesigner on Thu Mar 14 01:01:23 IST 2013
 */

package com.main;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingConstants;

import com.jgoodies.forms.factories.CC;
import com.jgoodies.forms.layout.FormLayout;

/**
 * @author Anjali Shinde
 */
public class MainPageView extends JPanel {
    public MainPageView() {
        initComponents();
    }

    // Initialzing all pages to called from button
    KeralaPage kerala = new KeralaPage();
    RajasthanView rajasthan = new RajasthanView();
    MaharashtraView maharashtra = new MaharashtraView();
    GoaView goa = new GoaView();
    JKView jk = new JKView();
    Gurajat gurajat = new Gurajat();

    public static void createAndShowGUI() {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                MainPageView GUI = new MainPageView();
                JFrame frame = new JFrame();
                frame.setContentPane(GUI);
                frame.setVisible(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
            }
        });
    }

    public static void main(String[] args) {
        createAndShowGUI();
    }

    /*public boolean handleEvent(Event e)
      {
       if(e.id==Event.WINDOW_DESTROY)
     System.exit(0);
       return(super.handleEvent(e));
      } */

    private void initComponents() {
        // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
        // Generated using JFormDesigner Evaluation license - Anjali Shinde
        label1 = new JLabel();
        panel2 = new JPanel();
        button6 = new JButton();
        KeralaImage = new JLabel();
        scrollPane6 = new JScrollPane();
        editorPane1 = new JEditorPane();
        button5 = new JButton();
        rajasthanimage = new JLabel();
        scrollPane1 = new JScrollPane();
        editorPane2 = new JEditorPane();
        button4 = new JButton();
        maharashtraimage = new JLabel();
        scrollPane3 = new JScrollPane();
        editorPane3 = new JEditorPane();
        button3 = new JButton();
        goaimage = new JLabel();
        scrollPane4 = new JScrollPane();
        editorPane4 = new JEditorPane();
        button2 = new JButton();
        jkimage = new JLabel();
        scrollPane7 = new JScrollPane();
        editorPane5 = new JEditorPane();
        button1 = new JButton();
        gurajatimage = new JLabel();
        scrollPane8 = new JScrollPane();
        editorPane6 = new JEditorPane();

        //======== this ========
        setPreferredSize(new Dimension(1200, 1200));

        // JFormDesigner evaluation mark
        setBorder(
                new javax.swing.border.CompoundBorder(
                        new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                                "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                                javax.swing.border.TitledBorder.BOTTOM,
                                new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red),
                        getBorder()));
        addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent e) {
                if ("border".equals(e.getPropertyName()))
                    throw new RuntimeException();
            }
        });

        setLayout(new FormLayout("default:grow", "default, $lgap, default"));

        //---- label1 ----
        label1.setText("TRAVELS AND TOURISM");
        label1.setFont(new Font("Tahoma", Font.BOLD, 24));
        label1.setHorizontalAlignment(SwingConstants.CENTER);
        add(label1, CC.xy(1, 1));

        //======== panel2 ========
        {
            panel2.setLayout(new FormLayout("center:default, $lcgap, 181dlu, $lcgap, default:grow",
                    "5*(fill:65dlu:grow, $lgap), fill:64dlu:grow"));

            //---- button6 ----
            button6.setText("Kerala");
            button6.setFont(new Font("Tahoma", Font.PLAIN, 18));
            panel2.add(button6, CC.xy(1, 1, CC.FILL, CC.DEFAULT));

            //---- KeralaImage ----
            KeralaImage.setIcon(new ImageIcon(getClass().getResource("/com/images/formimages/kerala.jpg")));
            KeralaImage.setIconTextGap(0);
            KeralaImage.setHorizontalTextPosition(SwingConstants.LEFT);
            KeralaImage.setHorizontalAlignment(SwingConstants.LEFT);
            panel2.add(KeralaImage, CC.xy(3, 1, CC.LEFT, CC.CENTER));

            //======== scrollPane6 ========
            {

                //---- editorPane1 ----
                editorPane1.setText(
                        "God's own country Kerala: With the Arabian Sea in the west, the Western Ghats towering 500-2700 ms in the east and networked by 44 rivers, Kerala enjoys unique geographical features that have made it one of the most sought after tourist destinations in Asia. An equable climate. Please click on state name to know more.");
                editorPane1.setEditable(false);
                editorPane1.setFont(new Font("Tahoma", Font.PLAIN, 14));
                scrollPane6.setViewportView(editorPane1);
            }
            panel2.add(scrollPane6, CC.xy(5, 1));

            //---- button5 ----
            button5.setText("Rajasthan");
            button5.setFont(new Font("Tahoma", Font.PLAIN, 18));
            panel2.add(button5, CC.xy(1, 3, CC.FILL, CC.DEFAULT));

            //---- rajasthanimage ----
            rajasthanimage.setIcon(new ImageIcon(getClass().getResource("/com/images/formimages/rajasthan.jpg")));
            rajasthanimage.setIconTextGap(0);
            panel2.add(rajasthanimage, CC.xy(3, 3, CC.LEFT, CC.DEFAULT));

            //======== scrollPane1 ========
            {

                //---- editorPane2 ----
                editorPane2.setText(
                        "The magic of vibrant Rajasthan: It's heritage, culture, safaris, sand dunes, lush forests and wildlife-makes it destination nonpareil.  India's oldest mountain range as the backdrop. Please click on state name to know more.");
                editorPane2.setEditable(false);
                editorPane2.setFont(new Font("Tahoma", Font.PLAIN, 14));
                scrollPane1.setViewportView(editorPane2);
            }
            panel2.add(scrollPane1, CC.xy(5, 3));

            //---- button4 ----
            button4.setText("Maharashtra");
            button4.setFont(new Font("Tahoma", Font.PLAIN, 18));
            panel2.add(button4, CC.xy(1, 5, CC.FILL, CC.DEFAULT));

            //---- maharashtraimage ----
            maharashtraimage.setIcon(new ImageIcon(getClass().getResource("/com/images/formimages/mah.jpg")));
            panel2.add(maharashtraimage, CC.xy(3, 5, CC.LEFT, CC.DEFAULT));

            //======== scrollPane3 ========
            {

                //---- editorPane3 ----
                editorPane3.setText(
                        "Welcome to Maharashtra: A land whose sheer size and diversity will stun you. Enjoy her mountains that stretch out into the mists as far as the eye can see. Her scores of temples, sculpted into and out of basalt rock. Please click on state name to know more.");
                editorPane3.setEditable(false);
                editorPane3.setFont(new Font("Tahoma", Font.PLAIN, 14));
                scrollPane3.setViewportView(editorPane3);
            }
            panel2.add(scrollPane3, CC.xy(5, 5));

            //---- button3 ----
            button3.setText("Goa");
            button3.setFont(new Font("Tahoma", Font.PLAIN, 18));
            panel2.add(button3, CC.xy(1, 7, CC.FILL, CC.DEFAULT));

            //---- goaimage ----
            goaimage.setIcon(new ImageIcon(getClass().getResource("/com/images/formimages/goa.jpg")));
            panel2.add(goaimage, CC.xy(3, 7, CC.LEFT, CC.DEFAULT));

            //======== scrollPane4 ========
            {

                //---- editorPane4 ----
                editorPane4.setText(
                        "The Coolest Place in India Goa: Now our road takes us to the magnificent kingdom of Goa. The people of this kingdom are strong, prudent and very hardworking ... The kingdom of Goa is the most important in India. Please click on state name to know more.");
                editorPane4.setEditable(false);
                editorPane4.setFont(new Font("Tahoma", Font.PLAIN, 14));
                scrollPane4.setViewportView(editorPane4);
            }
            panel2.add(scrollPane4, CC.xy(5, 7));

            //---- button2 ----
            button2.setText("Jammu and Kashmir");
            button2.setFont(new Font("Tahoma", Font.PLAIN, 18));
            panel2.add(button2, CC.xy(1, 9, CC.FILL, CC.DEFAULT));

            //---- jkimage ----
            jkimage.setIcon(new ImageIcon(getClass().getResource("/com/images/formimages/shalimar.jpg")));
            panel2.add(jkimage, CC.xy(3, 9, CC.LEFT, CC.DEFAULT));

            //======== scrollPane7 ========
            {

                //---- editorPane5 ----
                editorPane5.setText(
                        "Heaven on Earth Jammu and Kashmir: As they say beauty is the eyes of beholder and that is so true of the Valley. In Kashmir there is as much hidden as revealed. So the Valley has to be seen with the eyes of the soul. Please click on state name to know more.");
                editorPane5.setEditable(false);
                editorPane5.setFont(new Font("Tahoma", Font.PLAIN, 14));
                scrollPane7.setViewportView(editorPane5);
            }
            panel2.add(scrollPane7, CC.xy(5, 9));

            //---- button1 ----
            button1.setText("Gujarat");
            button1.setFont(new Font("Tahoma", Font.PLAIN, 18));
            panel2.add(button1, CC.xy(1, 11, CC.FILL, CC.DEFAULT));

            //---- gurajatimage ----
            gurajatimage.setIcon(new ImageIcon(getClass().getResource("/com/images/formimages/gujarat.jpg")));
            panel2.add(gurajatimage, CC.xy(3, 11, CC.LEFT, CC.DEFAULT));

            //======== scrollPane8 ========
            {

                //---- editorPane6 ----
                editorPane6.setText(
                        "Gandhi's birth place Gujarat: Gujarat is unique in its geological and topographical landscape. From volcanic outpourings through bedrock to fossil fields of indegenous dinosaurs; from the art of the neolithic cave painter. Gujarat has it all. Please click on state name to know more.");
                editorPane6.setEditable(false);
                editorPane6.setFont(new Font("Tahoma", Font.PLAIN, 14));
                scrollPane8.setViewportView(editorPane6);
            }
            panel2.add(scrollPane8, CC.xy(5, 11));
        }
        add(panel2, CC.xy(1, 3));
        // JFormDesigner - End of component initialization  //GEN-END:initComponents

        button6.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                kerala.createAndShowGUI();
            }
        });

        button5.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                rajasthan.createAndShowGUI();
            }
        });

        button4.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                maharashtra.createAndShowGUI();
            }
        });

        button3.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                goa.createAndShowGUI();
            }
        });

        button2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                jk.createAndShowGUI();
            }
        });

        button1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                gurajat.createAndShowGUI();
            }
        });
    }

    // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
    // Generated using JFormDesigner Evaluation license - Anjali Shinde
    private JLabel label1;
    private JPanel panel2;
    private JButton button6;
    private JLabel KeralaImage;
    private JScrollPane scrollPane6;
    private JEditorPane editorPane1;
    private JButton button5;
    private JLabel rajasthanimage;
    private JScrollPane scrollPane1;
    private JEditorPane editorPane2;
    private JButton button4;
    private JLabel maharashtraimage;
    private JScrollPane scrollPane3;
    private JEditorPane editorPane3;
    private JButton button3;
    private JLabel goaimage;
    private JScrollPane scrollPane4;
    private JEditorPane editorPane4;
    private JButton button2;
    private JLabel jkimage;
    private JScrollPane scrollPane7;
    private JEditorPane editorPane5;
    private JButton button1;
    private JLabel gurajatimage;
    private JScrollPane scrollPane8;
    private JEditorPane editorPane6;
    // JFormDesigner - End of variables declaration  //GEN-END:variables

}