,
===============================================================================
Package tiger.annotation;
/**
* User-defined label?? MyTag
*/
Public @interface MyTag {}
Once we have defined a tag, we can use this tag in any Java file,
Import Tiger.annotation.MyTag;
public class tagtest{
@MyTag
public void Testtag () {
}
}
====================================
annotation type (annotation type ). Creating a new annotation type looks like defining an interface,Mytag. Java is used to create a custom tag. The Code is as follows,
========================================================== ==========================================================Package tiger. annotation;/*** User-Defined tags ?? Mytag*/Public @ interface mytag
function.After reading the usage of standard labels, let's take a look at the user-defined labels. First, we will introduce @ interface, which is used to define a new annotation type (annotation type ). Creating a new annotation type looks similar to defining an Interface. MyTag. java is used to create a custom tag. the code is as follows,========================================================== ======================================================
equivalent to the entire form as a picture scaling, more beautiful. Double-click the form to enter the load function for edit Form1
private void Form1_Load (object sender, EventArgs e){This. Resize + = new EventHandler (form1_resize);//When the form is resized, events are raisedX = this. width;//get the width of the formY = this. height;//get the height of the formSettag (this);//Calling methodWrite your own method:
float X, Y; The private void Settag (Control cons) {//traverses controls in
?? MyTag/Public @interface MyTag {} Defines a tag, we can use this tag in any Java file, import Tiger.annotation.MyTag; public class tagtest{@MyTag public void Testtag () {}} =============================================================== ================ annotation types can also have member variables, ============================================================
tools provided by MicrosoftProceedProgramDevelopment Span Style = "Font-family: Arial; font-size: 12pt ;" > We use Ruby > U > Visual Studio. NET 2003 U > RT > Span Style = "Font-family: Arial; font-size: 8pt; color: red ;" > Development tools provided by Microsoft Span > Ruby > Program Development Span >
3. Use your own defined elementsStep 1 declare the namespace and use the xmlns tag attribute of the HTML ElementStep 2: Define custom tags in @ media Pa
Java:jsp: A simple custom label TLDPlease note that the URI is: Http://www.tag.com/mytag, keep unified, otherwise error, cannot accessTLD file1"1.0"encoding="UTF-8"?>2"HTTP://JAVA.SUN.COM/XML/NS/J2EE"3Xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"4xsi:schemalocation="HTTP://JAVA.SUN.COM/XML/NS/J2EE5http//java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd "6version="2.0">71.1Print library891.0Ten Short-name>
Public Class FRMDLDim x As Single = 0Dim y As Single = 0Private Sub frmdl_load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Loadx = Me.Widthy = me.heightSettag (Me)End Sub' recursively take control of the original size and position, using tag to recordPrivate Sub Settag (ByVal obj as Object)For each con as Control in obj. ControlsCon. Tag = con. Width ":" con. Height ":" con. Left ":" con. Top ":" con. Font.Size' If it is a container control, the recursion
Public Class FRMDL
Dim x As Single = 0
Dim y As Single = 0
Private Sub frmdl_load (ByVal sender as System.Object, ByVal e as System.EventArgs) Handles MyBase.Load
x = Me.Width
y = me.height
Settag (Me)
End Sub
' recursively takes the original size and position of the control, using tag to record
Private Sub Settag (ByVal obj as Object)
For all con as control in obj. Controls
Con. Tag = con. Width ":" con. Height ":" con. Left ":" con. Top ":" con. Font.Size
' If it is a container contro
, You need to declare it in advance so that IE can recognize it.
Version Information
IE has many problems with non-standard label elements. These problems can be categorized into two categories, each of which has its own solution.
If the tag name starts with "my:", it is treated as an XML namespace and must have a corresponding namespace declaration.
If the tag does not have a symbol but is not a standard HTML tag, you must use document. createElement ('My-tag') to create it in advance.
need for special handling of custom attributes (V. What happens if I fail to do this? (What happens if you don't do the processing?!) )Suppose we have a nonstandard HTML tag (with the same result for My:tag or My-tag). However, after the test, you will find that the namespace method does not have this annoyance.In general, the DOM structure will be converted to a bit:
#document+- HTML+- BODY+- mytag+-#text: some text
What w
document. createElement ('My-tag') to create it in advance.
If you plan to use the CSS selector to change the style of the custom tag, you must use document. createElement ('My-tag') to create a custom tag no matter whether there is a namespace.
Good News
The good news is that these restrictions only apply to element tag names and not to element attribute names. Therefore, no special handling is required in IE:
What will happen if I don't do this?
Assume that you use the unknown HTML tag
this?!) )
Let's say we have a non-standard HTML tag (the same result for My:tag or My-tag). But after the test, it was found that the namespace approach would not have this annoyance.
In general, it will be converted to a DOM structure:
#document
+-HTML
+-body
+-mytag
+-#text: some text
What we expect is that the BODY element has a mytag child element, and
news
The good news is that these restrictions apply only to element tag names and not to element property names. Therefore, there is no need for special processing in IE: What would happen if I didn't?
If you use the HTML unknown tag mytag (My:tag or My-tag results are the same): ?
1 2 3 4 5 6
The DOM should be parsed as follows: ?
1 2 3 4 5
#document +-HTML +-body +-
default, annotation can be used to decorate any element, including classes, interfaces, methods, and so on. The following program uses @testannotation to modify the methodpublic class myclass{ //Use the @testannotation adornment method @Test public void info () {... }}Annotation can be not only this simple annotation,annotation but also with the staff variables, annotation member variables are declared in the annotation definition with no parameters. Its method and return value define
nonstandard HTML tag ( with the same result for My:tag or My-tag). However, after the test, you will find that the namespace method does not have this annoyance. In general, the DOM structure will be converted to a bit:
#document +- HTML +- BODY +- mytag +- #text: some text
What we expect is that the BODY element has a mytag child element,andMyTag has a text sub-elemen
() method, however, you may inadvertently put it on the FOB (), for such a "low-level error", if you do not find in the early days, to the system integration test, you may be a few hours or even one or two days to find such a bug. Well now, the compiler will give you an error when compiling.
Child.java:3: method does not override a method from its superclass @Override ^ 1 error
How about, this function is also good.
Looking at the use of standard tags, let's look at user-defined tags. Introd
Controls change with the window size (from the small lottery system), window Lottery
I. A problem encountered in the lottery system is that the control needs to zoom in with the window, and the position and size also change. I found a lot of information on the Internet, the attribute values of both Anchor and Dock are modified, but they do not match the desired effect. The emperor finally found me (as shown below)Private float X, Y; private void setTag (Control cons) {foreach (Control con in con
WinForm, how to control the position of a control changes with the size of the formThere are 3 ways to do this:Method 1[CSharp]View Plaincopy
Using System;
Using System.Collections.Generic;
Using System.ComponentModel;
Using System.Data;
Using System.Drawing;
Using System.Text;
Using System.Windows.Forms;
Namespace Markprinter
{
Public partial class Resizetest:form
{
public float X;
public float Y;
//public float y;
Public resizetest ()
{
InitializeC
control in a form, reset the value of the control $ foreach(Control coninchcons. Controls) $ { - string[] MyTag = con. Tag.tostring (). Split (New Char[] {':'});//gets the value of the control's Tag property, and then stores the string array after splitting - the floatA = Convert.tosingle (mytag[0]) * NEWX;//determines the value of the control based
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.