Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
/*
 The GUFF - The GNU Ultimate Framework Facility
 Copyright (C) Simeosoft di Carlo Simeone
    
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
 License as published by the Free Software Foundation; either
 version 2.1 of the License, or (at your option) any later version.
    
 This library is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 Lesser General Public License for more details.
    
 You should have received a copy of the GNU Lesser General Public
 License along with this library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   
 */

import javax.swing.*;
import java.awt.*;

import javax.swing.border.*;

public class Main {
    public final static int STYLE_EDIT = 0;
    public final static int STYLE_OK = 1;
    public final static int STYLE_CANCEL = 2;
    public final static int STYLE_INSBEFOREROW = 16;
    public final static int STYLE_INSAFTERROW = 17;
    public final static int STYLE_DELETEROW = 18;
    public final static int STYLE_CLONEBEFOREROW = 19;
    public final static int STYLE_CLONEAFTERROW = 20;
    public final static int STYLE_DEFAULTROWS = 21;
    public static Icon ICON_INSBEFOREROW = null;
    public static Icon ICON_INSAFTERROW = null;
    public static Icon ICON_DELETEROW = null;
    public static Icon ICON_CLONEBEFOREROW = null;
    public static Icon ICON_CLONEAFTERROW = null;
    public static Icon ICON_DEFAULTROWS = null;

    /**
     * Returns a styled JButton.
     *
     * @param style button type
     * @return a styled button
     */
    public static JButton creaStyledButton(int style) {
        JButton jb = new JButton();
        jb.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
        jb.setMargin(new Insets(0, 5, 1, 5));
        switch (style) {
        case STYLE_EDIT: {
            jb.setText("edit");
            jb.setToolTipText("edit");
            jb.setPreferredSize(new Dimension(60, 30));
            return jb;
        }
        case STYLE_OK: {
            jb.setText("ok");
            jb.setToolTipText("confirm changes");
            jb.setPreferredSize(new Dimension(60, 30));
            return jb;
        }
        case STYLE_CANCEL: {
            jb.setText("cancel");
            jb.setToolTipText("discard changes");
            jb.setPreferredSize(new Dimension(60, 30));
            return jb;
        }
        case STYLE_INSBEFOREROW: {
            jb.setIcon(ICON_INSBEFOREROW);
            jb.setToolTipText("insert row before");
            jb.setName("INSBEFOREROW");
            return jb;
        }
        case STYLE_INSAFTERROW: {
            jb.setIcon(ICON_INSAFTERROW);
            jb.setToolTipText("insert row after");
            jb.setName("INSAFTERROW");
            return jb;
        }
        case STYLE_DELETEROW: {
            jb.setIcon(ICON_DELETEROW);
            jb.setToolTipText("delete row");
            jb.setName("DELETEROW");
            return jb;
        }
        case STYLE_CLONEBEFOREROW: {
            jb.setIcon(ICON_CLONEBEFOREROW);
            jb.setToolTipText("clone row before");
            jb.setName("CLONEBEFOREROW");
            return jb;
        }
        case STYLE_CLONEAFTERROW: {
            jb.setIcon(ICON_CLONEAFTERROW);
            jb.setToolTipText("clone row after");
            jb.setName("CLONEAFTERROW");
            return jb;
        }
        case STYLE_DEFAULTROWS: {
            jb.setIcon(ICON_DEFAULTROWS);
            jb.setToolTipText("set default values");
            jb.setName("DEFAULTROWS");
            return jb;
        }
        default: {
            return null;
        }
        }
    }
}