Home Answers Viewqa Applet Web programming guidence

 
 


P.Ravichristy
Web programming guidence
4 Answer(s)      4 years and 5 months ago
Posted in : Applet

View Answers

January 5, 2009 at 12:44 AM


Hi friend,

import java.awt.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.net.URL;

import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.metal.MetalButtonUI;

public class LayoutDemo extends JButton {
private static final String uiString = "LinkButtonUI";

public static final int ALWAYS_UNDERLINE = 0;
public static final int HOVER_UNDERLINE = 1;
public static final int NEVER_UNDERLINE = 2;
public static final int SYSTEM_DEFAULT = 3;

private int linkBehavior;

private Color linkColor;

private Color colorPressed;

private Color visitedLinkColor;

private Color disabledLinkColor;

private URL buttonURL;

private Action defaultAction;

private boolean isLinkVisited;

public static void main(String[] a) {
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new GridLayout(0,2));
frame.getContentPane().add(new LayoutDemo("www.roseindia.net"));
frame.getContentPane().add(new LayoutDemo("www.roseindia.net/java/"));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600, 200);
frame.setVisible(true);
}

public LayoutDemo() {
this(null, null, null);
}

public LayoutDemo(Action action) {
this();
setAction(action);
}

public LayoutDemo(Icon icon) {
this(null, icon, null);
}

public LayoutDemo(String s) {
this(s, null, null);
}

public LayoutDemo(URL url) {
this(null, null, url);
}

public LayoutDemo(String s, URL url) {
this(s, null, url);
}

public LayoutDemo(Icon icon, URL url) {
this(null, icon, url);
}

public LayoutDemo(String text, Icon icon, URL url) {
super(text, icon);
linkBehavior = SYSTEM_DEFAULT;
linkColor = Color.blue;
colorPressed = Color.red;
visitedLinkColor = new Color(128, 0, 128);
if (text == null && url != null)
setText(url.toExternalForm());
setLinkURL(url);
setCursor(Cursor.getPredefinedCursor(12));
setBorderPainted(false);
setContentAreaFilled(false);
setRolloverEnabled(true);
addActionListener(defaultAction);
}

public void updateUI() {
setUI(BasicLinkButtonUI.createUI(this));
}

January 5, 2009 at 12:46 AM


private void setDefault() {
UIManager.getDefaults().put("LinkButtonUI", "BasicLinkButtonUI");
}

public String getUIClassID() {
return "LinkButtonUI";
}

protected void setupToolTipText() {
String tip = null;
if (buttonURL != null)
tip = buttonURL.toExternalForm();
setToolTipText(tip);
}

public void setLinkBehavior(int bnew) {
checkLinkBehaviour(bnew);
int old = linkBehavior;
linkBehavior = bnew;
firePropertyChange("linkBehavior", old, bnew);
repaint();
}

private void checkLinkBehaviour(int beha) {
if (beha != ALWAYS_UNDERLINE && beha != HOVER_UNDERLINE
&& beha != NEVER_UNDERLINE && beha != SYSTEM_DEFAULT)
throw new IllegalArgumentException("Not a legal LinkBehavior");
else
return;
}

public int getLinkBehavior() {
return linkBehavior;
}

public void setLinkColor(Color color) {
Color colorOld = linkColor;
linkColor = color;
firePropertyChange("linkColor", colorOld, color);
repaint();
}

public Color getLinkColor() {
return linkColor;
}

public void setActiveLinkColor(Color colorNew) {
Color colorOld = colorPressed;
colorPressed = colorNew;
firePropertyChange("activeLinkColor", colorOld, colorNew);
repaint();
}

public Color getActiveLinkColor() {
return colorPressed;
}

public void setDisabledLinkColor(Color color) {
Color colorOld = disabledLinkColor;
disabledLinkColor = color;
firePropertyChange("disabledLinkColor", colorOld, color);
if (!isEnabled())
repaint();
}

public Color getDisabledLinkColor() {
return disabledLinkColor;
}

public void setVisitedLinkColor(Color colorNew) {
Color colorOld = visitedLinkColor;
visitedLinkColor = colorNew;
firePropertyChange("visitedLinkColor", colorOld, colorNew);
repaint();
}

public Color getVisitedLinkColor() {
return visitedLinkColor;
}

public URL getLinkURL() {
return buttonURL;
}

public void setLinkURL(URL url) {
URL urlOld = buttonURL;
buttonURL = url;
setupToolTipText();
firePropertyChange("linkURL", urlOld, url);
revalidate();
repaint();
}

public void setLinkVisited(boolean flagNew) {
boolean flagOld = isLinkVisited;
isLinkVisited = flagNew;
firePropertyChange("linkVisited", flagOld, flagNew);
repaint();
}

public boolean isLinkVisited() {
return isLinkVisited;
}

public void setDefaultAction(Action actionNew) {
Action actionOld = defaultAction;
defaultAction = actionNew;
firePropertyChange("defaultAction", actionOld, actionNew);
}

public Action getDefaultAction() {
return defaultAction;
}

January 5, 2009 at 12:47 AM


protected String paramString() {
String str;
if (linkBehavior == ALWAYS_UNDERLINE)
str = "ALWAYS_UNDERLINE";
else if (linkBehavior == HOVER_UNDERLINE)
str = "HOVER_UNDERLINE";
else if (linkBehavior == NEVER_UNDERLINE)
str = "NEVER_UNDERLINE";
else
str = "SYSTEM_DEFAULT";
String colorStr = linkColor == null ? "" : linkColor.toString();
String colorPressStr = colorPressed == null ? "" : colorPressed
.toString();
String disabledLinkColorStr = disabledLinkColor == null ? ""
: disabledLinkColor.toString();
String visitedLinkColorStr = visitedLinkColor == null ? ""
: visitedLinkColor.toString();
String buttonURLStr = buttonURL == null ? "" : buttonURL.toString();
String isLinkVisitedStr = isLinkVisited ? "true" : "false";
return super.paramString() + ",linkBehavior=" + str + ",linkURL="
+ buttonURLStr + ",linkColor=" + colorStr + ",activeLinkColor="
+ colorPressStr + ",disabledLinkColor=" + disabledLinkColorStr
+ ",visitedLinkColor=" + visitedLinkColorStr
+ ",linkvisitedString=" + isLinkVisitedStr;
}
}

class BasicLinkButtonUI extends MetalButtonUI {
private static final BasicLinkButtonUI ui = new BasicLinkButtonUI();

public BasicLinkButtonUI() {
}

public static ComponentUI createUI(JComponent jcomponent) {
return ui;
}

protected void paintText(Graphics g, JComponent com, Rectangle rect,
String s) {
LayoutDemo bn = (LayoutDemo) com;
ButtonModel bnModel = bn.getModel();
Color color = bn.getForeground();
Object obj = null;
if (bnModel.isEnabled()) {
if (bnModel.isPressed())
bn.setForeground(bn.getActiveLinkColor());
else if (bn.isLinkVisited())
bn.setForeground(bn.getVisitedLinkColor());

else
bn.setForeground(bn.getLinkColor());
} else {
if (bn.getDisabledLinkColor() != null)
bn.setForeground(bn.getDisabledLinkColor());
}
super.paintText(g, com, rect, s);
int behaviour = bn.getLinkBehavior();
boolean drawLine = false;
if (behaviour == LayoutDemo.HOVER_UNDERLINE) {
if (bnModel.isRollover())
drawLine = true;
} else if (behaviour == LayoutDemo.ALWAYS_UNDERLINE || behaviour == LayoutDemo.SYSTEM_DEFAULT)
drawLine = true;
if (!drawLine)
return;
FontMetrics fm = g.getFontMetrics();
int x = rect.x + getTextShiftOffset();
int y = (rect.y + fm.getAscent() + fm.getDescent() + getTextShiftOffset()) - 1;
if (bnModel.isEnabled()) {
g.setColor(bn.getForeground());
g.drawLine(x, y, (x + rect.width) - 1, y);
} else {
g.setColor(bn.getBackground().brighter());
g.drawLine(x, y, (x + rect.width) - 1, y);
}
}
}
----------------------------
Visit for more information:

http://www.roseindia.net/java/example/java/swing/

Thanks.

January 11, 2009 at 2:19 AM


Dear Sir/Madam
Received the programee.
Thank you very much for the programme.
When I run the programme, two out put displayed.
thanks once again for the programme.

Now my main wish, is to design a web site and host with the help of Roseindia.net. Can I please be helped with the free study meterial as and how to design and the proceedure for hosting.

I am very much thankfull to you for the favor received.

Yours,
P.Ravichristy









Related Pages:
Web programming guidence - Applet
Web programming guidence  Dear Sir/Madam, I have studied (little) Java but not having good knowledge. I wish to host a simple web site... in each button. And also please give me the guidence for developing web
Web programming
Web programming  Write a program in servlet by using JDBC to display the records of employees from a table called employee
web
web  what do you mean by stacking elements? explain with example(in web programming
web
web  what do you mean by stacking elements? explain with example(in web programming
web programming - JSP-Servlet
web programming   Write a JSP page to display the number of hits to this page. (Hint: use application scope of java bean).  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/simple-jsp
web programming - JSP-Servlet
web programming  9)Create an HTML page containing the following features a.Create a login JSP page with username , password and submit button. b.On submit, display message ?Thank you for logging in ? Also create cookies
web programming - JSP-Servlet
web programming  6) Create an HTML page containing the following features a.A combo box containing the list of 7 colors: Violet, Indigo, Blue, Green, Yellow, Orange, Red b.An empty 1X1 table with default background color
web programming - JSP-Servlet
web programming  Write a JSP program to display current date and time and suitable welcome message. 1.If time is between 5AM and 12 PM display welcome message as ?Good Morning? 2.If time is between 12 PM and 5 PM display
web programming - Java Beginners
web programming  4) Create two HTML pages a. First page with the following features i. An image(logo) with a company name as the heading in the top center ii. This page containing an HTML form, two text boxes to get First Name
Black Berry Programming - MobileApplications
with the GPRS will any one give guidence for me i am learner now i know some programming knowledge in j2me please provide some help thanks in advance
Ajax programming
concept. What should be my starting point for Ajax programming? Thanks   Hi, If you have prior programming experience in any web development...Ajax programming  Hi, How I can start ajax programming easily? I
programming questions
programming questions  this is my assignment questions please help me... the programs in c# language Describe the following with respect to creating Web Forms in .Net environment: a. Web Form Life Cycle b. Creating a Web Form
socket programming
socket programming  how to create server socket in web service...it will read parameter from file
ajax programming
Ajax Programming What is Ajax Programming? Asynchronous JavaScript and XML... the section of the web page without reloading the whole page. This is the technique to creating faster web pages which is also more integrative. This technique
could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project.
could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project.  could you suggest me that in which area i have to do a project?i want a complete guidence to complete my project
Java Programming Language
Java Programming Language  Hi, For beginner which programming concepts is important? Discuss the importance of Java programming language. In the discussion please let's know how to use Java in developing web applications
Web Page
Web Page    Use any programming language or package to create a Project 2 .The Main menu should only be displayed, if the user is valid and uses..., 2012   Here is my first project Use any programming language
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 10.5 THIS PAGE DISCUSSES ONE... the server. The actual programming of the client is fairly straightforward... to understanding how the World Wide Web works. A Web server program is just
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 3.5 THIS PAGE DISCUSSES ONE... of the checkerboard: (To run an applet, you need a Web page to display...; Call this file Checkerboard.html. This is the source code for a simple Web page
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 3.6 THIS PAGE DISCUSSES ONE..., must be in the same directory as your Web-page source file and the compiled class..., then the source file for the Web page should contain the lines
Java Programming: Solution to Programming Exercise
Solution for Programming Exercise 8.4 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook...; tag on the web page. The tag for the applet at the top of this page
Java Programming, Solution to Programming Exercise
Solution for Programming Exercise 11.4 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the following exercise from this on-line Java textbook... by copying the class from a Web browser window and pasting it into my source code file
programming - Java Beginners
programming  how to implement web client in java
Web Services
Web Services       A web... applications from different sources to communicate with each other over the web. Web services enable applications written with different programming languages
Web Services - Web Services Tutorials
Web Services - Web Services Tutorials In this section of the Web Services tutorial you will be familiarized with the Web Services. Introduction The next generation of distributed computing has arrived. A Web service
Unix Web Hosting
Unix Web Hosting Unix Web Hosting is the type hosting provided on the Unix Servers. Unix Web Hosting is very reliable hosting option. Unix Hosting provides Perl programming, PHP programming and MySQL & PostgreSQL databases
Java programming
side web programming and runs in a secured manner over Internet that runs... Java programming       Java programming language is useful for development of enterprise grade
Web Portal - Development process
Web Portal  Could somebody tell us what common tools (and the cheaper ones) are in the market to develop a web portal? Say, if I want to develop a web portal, where people would post their comments and reviews; and others
Programming Books
Programming Books A Collection of Large number of Free books is presented here. You can browse these high quality programming... are for programming who wants to become expert programmer in their field
Java Programming: Contents
and World-Wide Web Quiz on this Chapter Chapter 2: Programming in the Small I... Introduction to Programming Using Java, Fourth Edition Table of Contents... introductory programming textbook. For more information about the text, please see
Java Programming Language
Introduction to Java programming Language Java is one of the Object-Oriented programming language used to create various types of applications.  James A. Gosling developed the Java programming language in the year 1995 at Sun
Web Services Growth
Web Services Growth The growth of open standards creates new opportunities... application programming interfaces (APIs) rather than to operating system-specific... of their perspective customers. By making its legacy data available via XML-based Web services
Programming
Programming  Given a number n, write a programming to determine its square root if it is possible, in the contraly case print an appropriate massege on the screen
Why Professional Web Hosting?,Professional Web Hosting
emails using web browsers.   FTP and other programming tools... on the web server. For the programming needs it provides PHP, PERL, CGI, JSP... Why Professional Web Hosting? You can take Internet connection
Programming Style Guideline
Java Notes: Programming Style Guideline Contents I. Motivation for programming guidelines II. Comments, indentation, spacing, braces, ... III. Naming... for programming guidelines Maintainability. If there's one idea that could serve
programming
Java Constructor programming for single and double constructor  write a program which have no argument constructor ,single parameter constructor constructor,double parameter constor,and the now when we create a object
Custom Website Programming Services
and web portal applications. Our custom website programming team uses latest...Custom Website Programming Services We offer custom website programming... programming? There are many free and open source software developed
Java Programming Keywords
Java  Programming Keywords Java is rich programming language for developing any type of applications. You can use java to develop desktop, web... programming language. There are 48 Keywords in Java abstract boolean
Help in Semantic web using SweDe
Help in Semantic web using SweDe  Hey I am very new to we programming and wondering if I can find the tutorial for learning Semantic development using SweDe
Web development - Introduction
Web development - Introduction       Web development in general term is process of developing a web site for the World Wide Web or an internet that includes web design, web

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.