The first ever JavaScript was created by Brendan Eich at Netscape, and has since been updated to conform to ECMA-262 Edition 5 and later versions. This engine, code named SpiderMonkey, is implemented in C/C++.
The programs in this language are called scripts. They can be written right in a web page’s HTML and run automatically as the page loads.
Scripts are provided and executed as plain text. They don’t need special preparation or compilation to run.
In this aspect, JavaScript is very different from another language calledjava.
| Why is it called JavaScript? |
|---|
| When JavaScript was created, it initially had another name: “LiveScript”. But Java was very popular at that time, so it was decided that positioning a new language as a “younger brother” of Java would help. But as it evolved, JavaScript became a fully independent language with its own specification called ECMAScript, and now it has no relation to Java at all. |
Modern JavaScript is a “safe” programming language. It does not provide low-level access to memory or CPU, because it was initially created for browsers which do not require it.
JavaScript’s capabilities greatly depend on the environment it’s running in. For instance, Node.js supports functions that allow JavaScript to read/write arbitrary files, perform network requests, etc.
In-browser JavaScript can do everything related to webpage manipulation, interaction with the user, and the webserver.


Pochettino's hefty compensation after being sacked by Spurs
by BeSoccerMauricio Pochettino has now become part of Tottenham's past, not future. The club fired the Argentine coach this Tuesday, with José Mourinho taking over, and the move will cost them almost 15 million euros
Tottenham's poor performance has forced the entity to unilaterally terminate Pochettino's contract, but the Argentine will not leave empty-handed.
The manager, who consistently delivered good results and even took Spurs to a Champions League final, should receive a compensation of around 14.6 million euros, as reported by 'The Independent'.
Featured links
- BREAKING NEWS: Mourinho replaces Pochettino at Tottenham
- The latest football transfers news and rumours
- Wales, golf, Madrid... in that order
- Luis Enrique returns to Spain national team
But that's not all there is to it, because the coaching staff will also be receiving part of that compensation. Therefore, the total amount of the operation will reach 23.3 million.
In this way, Levy had no qualms about demonstrating Spurs' economic powers. Meanwhile, José Mourinho, the new coach, will receive 17 million a year, more than double what Pochettino was receiving.


When you purchase something from our store, as part of the buying and selling process, we collect the personal information you give us such as your name, address and email address.
When you browse our store, we also automatically receive your computer’s internet protocol (IP) address in order to provide us with information that helps us learn about your browser and operating system.
Email marketing (if applicable): With your permission, we may send you emails about our store, new products and other updates.
How do you get my consent?
When you provide us with personal information to complete a transaction, verify your credit card, place an order, arrange for a delivery or return a purchase, we imply that you consent to our collecting it and using it for that specific reason only.
If we ask for your personal information for a secondary reason, like marketing, we will either ask you directly for your expressed consent, or provide you with an opportunity to say no.
How do I withdraw my consent?
If after you opt-in, you change your mind, you may withdrawing your consent for us to contact you, for the continued collection, use or disclosure of your information, at anytime, by contacting us at<EMAIL_ADDRESS>or mailing us at:
Mosaink
Dalagatan 34, c/o Stockman, SE 113 24 Stockholm, Sweden.
We may disclose your personal information if we are required by law to do so or if you violate our Terms of Service.
Payment:
If you choose a direct payment gateway to complete your purchase, then Stripe stores your credit card data. It is encrypted through the Payment Card Industry Data Security Standard (PCI-DSS). Your purchase transaction data is stored only as long as is necessary to complete your purchase transaction. After that is complete, your purchase transaction information is deleted.
All direct payment gateways adhere to the standards set by PCI-DSS as managed by the PCI Security Standards Council, which is a joint effort of brands like Visa, MasterCard, American Express and Discover.
PCI-DSS requirements help ensure the secure handling of credit card information by our store and its service providers.
For more insight, you may also want to read Stripe’s Terms of Service here or Privacy Statement here.
In general, the third-party providers used by us will only collect, use and disclose your information to the extent necessary to allow them to perform the services they provide to us.
However, certain third-party service providers, such as payment gateways and other payment transaction processors, have their own privacy policies in respect to the information we are required to provide to them for your purchase-related transactions.
For these providers, we recommend that you read their privacy policies so you can understand the manner in which your personal information will be handled by these providers.
In particular, remember that certain providers may be located in or have facilities that are located a different jurisdiction than either you or us. So if you elect to proceed with a transaction that involves the services of a third-party service provider, then your information may become subject to the laws of the jurisdiction(s) in which that service provider or its facilities are located.
As an example, if you are located in Canada and your transaction is processed by a payment gateway located in the United States, then your personal information used in completing that transaction may be subject to disclosure under United States legislation, including the Patriot Act.
Once you leave our store’s website or are redirected to a third-party website or application, you are no longer governed by this Privacy Policy or our website’s Terms of Service.
Links
When you click on links on our store, they may direct you away from our site. We are not responsible for the privacy practices of other sites and encourage you to read their privacy statements.
Google analytics:
Our store may use Google Analytics to help us learn about who visits our site and what pages are being looked at.
To protect your personal information, we take reasonable precautions and follow industry best practices to make sure it is not inappropriately lost, misused, accessed, disclosed, altered or destroyed.
If you provide us with your credit card information, the information is encrypted using secure socket layer technology (SSL) and stored with a AES-256 encryption. Although no method of transmission over the Internet or electronic storage is 100% secure, we follow all PCI-DSS requirements and implement additional generally accepted industry standards.
Here is a list of cookies that we use. We’ve listed them here so you that you can choose if you want to opt-out of cookies or not.
_secure_session_id, unique token, sessional
storefront_digest, unique token, indefinite If the shop has a password, this is used to determine if the current visitor has access.
Google analytics:
PREF, persistent for a very short period, Set by Google and tracks who visits the store and from where
By using this site, you represent that you are at least the age of majority in your state or province of residence, or that you are the age of majority in your state or province of residence and you have given us your consent to allow any of your minor dependents to use this site.
We reserve the right to modify this privacy policy at any time, so please review it frequently. Changes and clarifications will take effect immediately upon their posting on the website. If we make material changes to this policy, we will notify you here that it has been updated, so that you are aware of what information we collect, how we use it, and under what circumstances, if any, we use and/or disclose it.
If our store is acquired or merged with another company, your information may be transferred to the new owners so that we may continue to sell products to you.
If you would like to: access, correct, amend or delete any personal information we have about you, register a complaint, or simply want more information contact our Privacy Compliance Officer at info@mosaink.com


A Showcase page to Demostrate the Fluentstrap UI Components
Aww yeah, you successfully read this important alert message. This example text is going to run a bit longer so that you can see how spacing within an alert works with this kind of content.
Whenever you need to, be sure to use margin utilities to keep things nice and tidy.
Some quick example text to build on the card title and make up the bulk of the card's content.
Go somewhereSome quick example text to build on the card title and make up the bulk of the card's content.
Go somewhereSome quick example text to build on the card title and make up the bulk of the card's content.
Go somewhere


Compatible with Tableau 10.0 and later
Please open this URL from within Tableau
To add more rows of data you will need to:


Lionel Messi spotted playing with his kid in adorable video
Lionel Messi has over the decade proved his amazing superhuman on the pitch to the joy of football fans but nothing warms hearts than the Barcelona star's fatherhood experience.
The Argentine football captain was recently spotted playing with his child Ciro and that experience shows how lenient Messi can be with kids.
In a short clip shared by his wife Antonella Roccuzzo, the 32-year-old was seen playing with Ciro in what appears to be a soft duel between a loving father and son.

Ciro made futile attempts to get the bottle from his father, but the moment he managed to beat his Messi to the tool, they lightened the atmosphere up with bright soft laughter.
The video, which has amassed over three hundred and eighty-five thousand views on Twitter, has warmed hearts of football-loving social media users who hailed the Barcelona talisman's fatherhood style.
"Ciro's laugh is everything. So cute," a user said accompanied by a two beautiful emojis.
"Ciro is Leo's carbon copy. Might be the one to show interest in the round leather game later," another fan said.
And of course, some Ronaldo's fans see nothing spectacular about the video.
PAY ATTENTION: Install Pitch Football App for FREE to get the latest football News & Scores
Meanwhile, Legit.ng had reported that Sadio Mane, against all odds, is becoming a bigger revelation in football despite coming from a local Senegalese community - all thanks to his stellar rise and humility.
Outside the pitch, if anything would be said about the Liverpool forward, apparently it would about his gladsome humbleness which has marked him out as a special breed.
Jose Mourinho makes stunning statement about Lampard after win against Wolves
Recently, the 27-year-old star was spotted in a video that has now gone viral helping the bus assistants offload packs of bottled water from the national team bus.
Abu Azeez: Meet the only Nigerian rated among top 50 beach soccer players worldwide | Legit TV


AirWalker
Activity
Steps/Cycles
0
Threshold
%
Interval
ms
Calorie [cal]
0
calorie/step
Distance [km]
0
km/step
Workout
Date
Steps
Calories
Distance
Time
1
0
0
0
0
History
Date
Steps
Calories
Distance
Time


grep -v -v, --invert-match: select non-matching lines (ie find stuff with "not" text)
grep '[a-zA-Z0-9]' read a file
I can list directories if you don't have access to ls (narrow use case)


| <!--..-->
|
Used for comments in the source code. These comments are not visible on the page. |
N/A |
Container |
| <!DOCTYPE> |
Declaration; tells browser what type of page it should be. Must be the very first thing in your HTML document, before the <html> tag |
N/A |
Empty |
| <a> |
Defines a Hyperlink, used for linking one page to another. Includes the href attribute, which indicates the link's destination. |
Inline |
Container |
| <article> |
Used to semantically specify independent, self-contained content. Used for forum posts, blog posts, news stories, or comments. |
Block |
Container |
| <aside> |
Used to semantically specify content that is separate from the primary content, but related. |
Block |
Container |
| <body> |
Tag used to contain all the visual HTML contents |
Block |
Container |
| <br> |
Line break. Used to insert a single line break. |
Inline |
Empty |
| <dd> |
Definition in a description list. Used to describe a term or name. |
Block |
Container |
|
<div> |
Tag used to define a division or section in an HTML document, in order to selectively apply css styling elements. |
Block |
Container |
| <dl> |
The dl tag defines a Description list. |
Block |
Container |
| <dt> |
Used to define a term or name in a description list. |
Block |
Container |
| <em> |
Visual and semantic emphasis, appearing as italicized. Compatible with screen readers. |
Inline |
Container |
| <fieldset> |
Tag used to group related elements in a form. |
Block |
Container |
| <figcaption> |
Creates a caption for a figure/image element. |
Block |
Container |
| <figure> |
Semantic way of indicating illustrations, diagrams, photos, code listings, related to the main flow but separate. |
Block |
Container |
| <footer> |
Defines a footer section of a document. Typically placed at the end of an HTML document to group together information: authorship, copyright, contact, etc. There can be more than one. |
Block |
Container |
| <form> |
Tag used to create an HTML form for user input. |
Block |
Container |
| <h1> to <h6> |
Header tags, used to define headings. h1 is the most important, descending in importance to h6. |
Block |
Container |
| <head> |
Container for all head elements, including title of the document, various styles and scripts, and metatags. |
Invisble |
Container |
| <header> |
Semantic tag to signify header section. containing elements like heading elements such as logos, icons, and authorship information. |
Block |
Container |
| <html> |
Container encompassing all other HTML elements. |
N/A |
Container |
| <iframe> |
A way to embed another HTML document within the current HTML document. |
Block |
Empty |
| <img> |
Defines an image by referencing a file in the HTML document using the "src" and "alt" attributes. |
Inline |
Empty |
| <input> |
Form field. Specifies an imput field where a user inputs data into a field. |
Inline |
Empty |
| <label> |
Form field. Defines a label for an input element in a form. |
Inline |
Container |
| <li> |
Defines a list item for ordered, unordered, and menu lists. |
Block |
Container |
| <link> |
Defines a link to external resources such as style sheets or fonts. Only used in the head section. |
N/A |
Empty |
| <meta> |
Invisble element included in the head section to include data that can be used by browsers such as author, date last modified, etc. |
N/A |
Empty |
| <nav> |
Tag used to define a section for a major block of navigation elements. |
Block |
Container |
| <ol> |
Tag used to define an ordered list, which has numerical or alphabetical list identifiers. |
Block |
Container |
| <p> |
Tag used to define a paragraph; for grouping text. |
Block |
Container |
| <script> |
Tag that either contains or points to external JavaScript elements. |
N/A |
Container |
| <section> |
Tag used for defining sections within a document such as headers, footers, etc. |
Block |
Container |
| <strong> |
Visual and semantic emphasis, appearing as bolded text. Compatible with screen readers. |
Inline |
Container |
| <style> |
Tag used to define style information for HTML. This should be used to point to CSS stylesheets instead of styling within HTML directly. |
Inline |
Container |
| <table> |
Tag containing and defining a table, holds all elements related to the table like header, rows, caption, etc. |
Block |
Container |
| <td> |
Use to define info for a standard cell in a table. |
Inline |
Container |
| <th> |
Tag used to define a Header cell in a table. |
Block |
Container |
| <title> |
Used within the head section, the title tag is used to set the title of the page that is seen by browsers. |
Inline |
Container |
| <tr> |
Tag used to define a Table Row in a table. |
Block |
Container |
| <ul> |
Tag used for each item in a bulleted list (as opposed to a list that is numerical/alphabetically labelled; this would use the "<ol>" tag). |
Block |
Container |


The dashboard is Ambrosus’ web interface for creating, viewing and managing assets and events within AMB network.
It is made to be utilized by business and developers in order to configure the strategy for uploading bundles to AMB-NET, visualize and manage Assets, Events, and various accounts, and, most importantly, organize data movement between the blockchain and a private database.
Visit ambrosus.io for more information.


{% extends "base.html" %} {% load staticfiles %} {% block js %} {% endblock js %} {% block content %}
| Account Request | Search: |
|---|
| Name | School | Accept | Deny | |
| {{ user.first_name }} {{ user.last_name }} | {{ user.email }} | {{ user.school }} |
| Schools | Search: |
|---|
| Name | School Address | Copy/Modify | Delete |
| {{ school.name }} | {{ school.address }} |
| Manage Students | Search: |
|---|
| Name | School | Delete | |
| {{ active_user.first_name }} {{ active_user.last_name }} | {{ active_user.email }} | {{ active_user.school }} |


@maynoothuniversity/mu-qunit-util
A universal module which provides utilities for use within QUnit test suites for Maynooth University (MU) JavaScript projects.
This module is public purely so it can be used within MU's open source projects. While it's free for anyone to use, it's not designed to be universally useful.
API Documentation is available at bbusschots-mu.github.io/mu-qunit-util.
Incorporation into Test Suite
This module can be used both from the CLI and in-browser.
QUnit CLI (via NodeJS)
Install the module:
npm install --save-dev @maynoothuniversity/mu-qunit-util
To make this module available as u
within the test suite add
u:./node_modules/@maynoothuniversity/mu-qunit-util
to the -d
flag for the
qunit
binary.
The following is an example Node test script from package.json
:
"test": "./node_modules/.bin/qunit -c SomeModule:./src/SomeModule.js -d is:./node_modules/is_js _:./node_modules/lodash u:./node_modules/@maynoothuniversity/mu-qunit-util -t ./test/tests.js"
QUnit Web Interface
To use the module within QUnit's web interface include the version of the
module in the build
folder into the page before including the test suite. This
will publish the module to the global variable muQUnitUtil
. If the test suite
is expecting the module with a shorter alias like u
that shoudl be done using
a separate script tag.
<script<EMAIL_ADDRESS><script>
const util = muQUnitUtil;
</script>


save( :docs );
| Param | Type | Details | Required |
|---|---|---|---|
| docs | empty/ array/ object | The docs to save to the Meteor Collection. If nothing is passed, the method saves everything in the AngularMeteorCollection as is. If an object is passed, the method pushes that object into the AngularMeteorCollection. If an array is passed, the method pushes that all objects in the array into the AngularMeteorCollection. |
No |
| object | Returns a promise on success with the array of ids and the actions happened: "inserted" or "updated" for each one of the docs |
remove( :keys );
| Param | Type | Details | Required |
|---|---|---|---|
| keys | empty/ array/ object | The keys of the object to remove from the Meteor Collection. If nothing is passed, the method removes all the documents from the AngularMeteorCollection. If an object is passed, the method removes the object with that key from the AngularMeteorCollection. If an array is passed, the method removes all objects that matches the keys in the array from the AngularMeteorCollection. |
No |
| object | Returns a promise on success with the array of ids and the "removed" action |
subscribe( :subscriptionName );
| Param | Type | Details | Required |
|---|---|---|---|
| subscriptionName | subscriptionName | The subscription name to subscribe to. exactly like the first parameter in $meteor.subscribe service. |
Yes |
stop();


LLVM-Project comprises of many low-level utilities, The most important of which is llvm
core.
LLVM core is a big piece of software and when combined with additional packages which are part of LLVM-project. like clang and lld, The complete build size can reach up to 70-80 GB.
In case you just want to use the command line interface of llvm tools like clang
, lld
, you should download pre-built binaries. Source code is needed when you want the bits and pieces of llvm in order to build something new or add something to or modify existing code.
I spent whole day installing it and the result was super slow and 70GB Build. After setting proper option and using
ninja
I was able to build withing 40 minutes and total build size was 9GB.
I will present here the minimum steps needed to get llvm-project
source code and then build it efficiently.
Get the Source Code
This fetches complete source code, You may want to fetch only a particular version, for that refer llvm docs.
1
2
user@user:~$ git clone https://github.com/llvm/ llvm-project.git
user@user:~$ cd llvm-project
Setup Build directory and build tool
Build tools automate the compilation of source files. Most popular of these is make
and ninja
build system.
We will need a Makefile
or build.ninja
files for specifying compilation rules.
cmake
can generate these files for build system by using a CMakefile
, Which are already present in the directory.
Using ninja
is recommended. Install these tools if not already installed with.
1
2
user@user:~$ sudo apt-get install ninja-build
user@user:~$ sudo apt-get install cmake
Then generate build.ninja Files using cmake
with proper flags:
Note: Flags are case sensitive. Files are generated for Release version with proper flags to make a good substitue of Slow and Big Debug Version. Make Sure they match your needs.
1
2
3
user@user:~/llvm-project$ mkdir build
user@user:~/llvm-project$ cd build
user@user:~/llvm-project/build$ cmake -G "Ninja" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_USE_LINKER=gold -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -LLVM_CCACHE_BUILD=ON ../llvm
Build And Run Test
Tips: These Steps are probably going to take somewhere between \(1\) to \(1\frac{1}{2}\) hours, And your system will become slow ( By default ninja
uses all cores to complete jobs in parallel.) .Plug in your charger And find yourself something else to do.
1
2
user@user:~/llvm-project/build$ ninja
user@user:~/llvm-project/build$ ninja check-clang
Update PATH
Add following lines to start using llvm tools
1
2
3
4
user@user:~/llvm-project/build$ echo "export PATH="$PATH:~/llvm-project/build/bin"" >> ~/.bashrc
user@user:~/llvm-project/build$ source ~/.bashrc
# Start Using Clang or any of the tools available
user@user:~$ clang++ hello.cpp -o hello.o
Complete Bash Script
Warning: Before Using the script Make Sure you understand the steps and Change File Paths in the scrept when required.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
# Installing in home directory
cd
git clone https://github.com/llvm/ llvm-project.git
cd llvm-project
sudo apt-get install ninja-build
sudo apt-get install cmake
mkdir build
cd build
cmake -G "Ninja" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_USE_LINKER=gold -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -LLVM_CCACHE_BUILD=ON ../llvm
ninja
ninja check-clang
echo "export PATH="$PATH:~/llvm-project/build/bin"" >> ~/.bashrc
source ~/.bashrc
Why Use Ninja
ninja
is a bit faster than make
, But the main reason for using ninja is its ability to reduce the amount of time it takes to build next time.
Suppose you wrote a new source file using llvm source files and want to build and use the binary. There are two things you can do:
-
Make a seperate CMakeLists.txt file and specify various configuration. ( For e.g. if you include files from llvm folder you need to specify this : include_directories(${LLVM_INCLUDE_DIRS}))
-
Add file to the source in proper place and update CMakeLists.txt file of the source code.
Now because CMake Files of source code are obviously better than ours ( Well tested and with proper flags ) Choosing 2nd options seems logical.
But that required building whole source again.When prompted to build, Both make
and ninja
check which files are needed to build again and build only them.Here ninja
does a better job than make
. make
builds some files (other than those changed ) again,I don’t know why . Other than that it seems like make
inspects every file one by one making build time approx 4-5 minutes, While ninja
takes <1 min.
If you don’t change the source code and try to build ninja
will say “No work to do” while make
builds and links some “.inc” files.
Success: LLVM (And other tools in llvm-project) are great piece of software. The design and modularity not only makes various parts reusable, it also makes it easy to understand a particular part of software without worrying too much about the bigger picture. I am currently exploring Optimization part of Compiler (The llvm Core) and excited to learn more along the way.


  Shake treat bag meow for food, then when human fills food dish, take a few bites of food and continue meowing yet need to chase tail, but sniff other cat's butt and hang jaw half open thereafter or chew foot.
Chris is a computer programmer, musician, and intern at GovEx. He is fluent in Java, C, C++, Matlab, HTML, and CSS. Some of his personal hobbies include building computers, playing Metro Last Light, and spicy mayo. You can find him on instagram @ledk07.
  Shake treat bag meow for food, then when human fills food dish, take a few bites of food and continue meowing yet need to chase tail, but sniff other cat's butt and hang jaw half open thereafter or chew foot.
Before coming to GovEx, Lena spent three years as a legal associate for a San Francisco Bay Area wage-and-hour class action law firm representing employees and translating attorney speak into understandable English. In her career, she has worked with governmental organizations across the United States both big and small from Austin-Travis County, TX, to Glens Falls, NY. Lena is an MPA graduate of UNC Chapel Hill’s School of Government, specializing in local government and performance. Lena misses the authentic Mexican food in California, but she enjoys the East Coast seasons and baking for her co-workers.
Sophia is a front-end web developer and user experience designer turned civic technologist. She spent a year as a Code for America Fellow for Miami-Dade County in 2015, where she was introduced to open data and the many ways it can help governments make decisions.
In a former life, Sophia spent five years building storytelling interfaces at CNN.com. She holds a Master's in journalism from UNC-Chapel Hill, and another in museum studies from Johns Hopkins. When not in front of a computer screen, you can find her at a jeweler's bench or the nearest yarn shop.
  Shake treat bag meow for food, then when human fills food dish, take a few bites of food and continue meowing yet need to chase tail, but sniff other cat's butt and hang jaw half open thereafter or chew foot.
  Shake treat bag meow for food, then when human fills food dish, take a few bites of food and continue meowing yet need to chase tail, but sniff other cat's butt and hang jaw half open thereafter or chew foot.
Before joining the Center, Sheila worked on state and national broadband adoption programs. As a 2013 Code for America fellow, Sheila helped the City of Oakland develop RecordTrac, a web application that helps cities manage and respond to public records requests. Sheila holds Bachelor of Arts in Political Science from Brown University and a Masters in Public Policy from The College of William and Mary.
  Shake treat bag meow for food, then when human fills food dish, take a few bites of food and continue meowing yet need to chase tail, but sniff other cat's butt and hang jaw half open thereafter or chew foot.
Once a heroic Jedi Knight, Darth Vader Raifdog was seduced by the dark side of the Force, became a Sith Lord, and led the Empire’s eradication of the Jedi Order. He remained in service of the Emperor -- the evil Darth Sidious -- for decades, enforcing his Master’s will and seeking to crush the fledgling Rebel Alliance. But there was still good in him…
  Shake treat bag meow for food, then when human fills food dish, take a few bites of food and continue meowing yet need to chase tail, but sniff other cat's butt and hang jaw half open thereafter or chew foot.
  Shake treat bag meow for food, then when human fills food dish, take a few bites of food and continue meowing yet need to chase tail, but sniff other cat's butt and hang jaw half open thereafter or chew foot.
  Shake treat bag meow for food, then when human fills food dish, take a few bites of food and continue meowing yet need to chase tail, but sniff other cat's butt and hang jaw half open thereafter or chew foot.
Originally from Indiana, Eric has spent his career working and partnering with organizations around the world to improve public sector performance. Before coming to GovEx, Eric worked on public education initiatives as a Fulbright Grantee in South Korea and at the DC Public Education Fund in Washington, DC, where he managed grant programs to drive improved performance in the DC Public Schools. Most recently, Eric worked with local governments across North Carolina on strategic planning, economic development, and local government performance. He played baseball in college and is always happy to discuss the nuances of baseball around the world (ask him how a Mexican former major leaguer in South Korea became his favorite baseball player).
Has never gone fishing. Ever.
Carter is afraid of cats. And loves this depressingly uplifting quote from George Santayana: “The world is not respectable; it is mortal, tormented, confused, deluded forever; but it is shot through with beauty, with love, with glints of courage and laughter; and in these, the spirit blooms timidly, and struggles to the light amid the thorns.”
A heavy fish, possessing neither lungs nor swim bladders. Has a skeleton are made of cartilage rather than bone, and this, along with large deposits of fat, partially solves her weight problem. Predator.
  Shake treat bag meow for food, then when human fills food dish, take a few bites of food and continue meowing yet need to chase tail, but sniff other cat's butt and hang jaw half open thereafter or chew foot.


title = "2" url = "/register/2/:activationcode?" layout = "main" is_hidden = "0" [account] paramCode = "activationcode" == account->user()) return redirect('register/3/'); } ?> == {% partial "head" %} {% partial "nav-top" %}
We have send you an email with a link to confirm. Please click the link to continue.
If you have not received the email in the next few minutes, then check your spam folder to make sure the mail did not land there.


SwiftyTextTable
A lightweight Swift library for generating text tables.
Swift Language Support
SwiftyTextTable is now Swift 3.0 compatible! The last release to support Swift 2.3 was 0.3.1.
Installation
Carthage (OS X)
You can use Carthage to install
SwiftyTextTable by adding it to your Cartfile
:
github "scottrhoyt/SwiftyTextTable"
Swift Package Manager (OS X + Linux)
You can use The Swift Package Manager to
install SwiftyTextTable by adding the proper description to your
Package.swift
file:
import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
targets: [],
dependencies: [
.Package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", "0.5.0")
]
)
CocoaPods (OS X)
You can use CocoaPods to install SwiftyTextTable by
adding it to your Podfile
:
pod 'SwiftyTextTable'
Manual
Simply copy the *.swift
files from the Source/SwiftyTextTable
directory into
your project.
Usage
import SwiftyTextTable
// First create some columns
let foo = TextTableColumn(header: "foo")
let bar = TextTableColumn(header: "bar")
let baz = TextTableColumn(header: "baz")
// Then create a table with the columns
var table = TextTable(columns: [foo, bar, baz])
// Then add some rows
table.addRow([1, 2, 3])
table.addRow([11, 22, 33])
// Then render the table and use
let tableString = table.render()
print(tableString)
/*
+-----+-----+-----+
| foo | bar | baz |
+-----+-----+-----+
| 1 | 2 | 3 |
| 11 | 22 | 33 |
+-----+-----+-----+
*/
// Put a header on the table if you'd like
table.header = "my foo table"
print(table.render())
/*
+-----------------+
| my foo table |
+-----------------+
| foo | bar | baz |
+-----+-----+-----+
| 1 | 2 | 3 |
| 11 | 22 | 33 |
+-----+-----+-----+
*/
Any CustomStringConvertible
can be used for row values
.
Creating Tables from Arrays of Objects with TextTableRepresentable
Let’s say you have an array of objects that looks this:
enum AnimalType: String, CustomStringConvertible {
case dog = "Dog"
case cat = "Cat"
case gorilla = "Gorilla"
var description: String {
return self.rawValue
}
}
struct Pet {
let type: AnimalType
let name: String
let canHazPizza: Bool
}
let furball = Pet(type: .cat, name: "Furball", canHazPizza: false)
let bestFriend = Pet(type: .dog, name: "Best Friend", canHazPizza: true)
let scary = Pet(type: .gorilla, name: "Scary", canHazPizza: true)
let pets = [furball, bestFriend, scary]
Now you want to print a table containing your pets
. You can accomplish this
by having Pet
conform to TextTableRepresentable
:
extension Pet: TextTableRepresentable {
static var columnHeaders: [String] {
return ["Name", "Animal", "Can Haz Pizza?"]
}
var tableValues: [CustomStringConvertible] {
return [name, type, canHazPizza ? "yes" : "no"]
}
// Optional
static var tableHeader: String? {
return "My Pets"
}
}
You can now print a table of your pets
simply:
print(pets.renderTextTable())
/*
+----------------------------------------+
| My Pets |
+----------------------------------------+
| Name | Animal | Can Haz Pizza? |
+-------------+---------+----------------+
| Furball | Cat | no |
| Best Friend | Dog | yes |
| Scary | Gorilla | yes |
+-------------+---------+----------------+
*/
Fence Custimization
You can also customize the output of TextTable.render()
by using different
values for columnFence
, rowFence
, and cornerFence
.
table.columnFence = ":"
table.rowFence = "."
table.cornerFence = "."
print(table.render())
/*
...................
: foo : bar : baz :
...................
: 1 : 2 : :
: 11 : 22 : 33 :
...................
*/
Row Padding/Truncation
When adding rows, TextTable
will automatically pad the rows with empty strings
when there are fewer values
than columns. TextTable
will also disregard all
values
over the column count.
let foo = TextTableColumn(header: "foo")
let bar = TextTableColumn(header: "bar")
let baz = TextTableColumn(header: "baz")
var table = TextTable(columns: [foo, bar, baz])
table.addRow([1, 2])
table.addRow([11, 22, 33])
table.addRow([111, 222, 333, 444])
let tableString = table.render()
print(tableString)
/*
+-----+-----+-----+
| foo | bar | baz |
+-----+-----+-----+
| 1 | 2 | |
| 11 | 22 | 33 |
| 111 | 222 | 333 |
+-----+-----+-----+
*/
Console Formatting Support
SwiftyTextTable will recognize many console escape sequences used to format output (e.g. Rainbow) and account for them in constructing the table.
API Reference
Check out the full API reference here.
License
SwiftyTextTable is released under the MIT License.


Gone in 60 Seconds (2000)
Cast: Nicolas Cage, Giovanni Ribisi, Angelina Jolie, Delroy Lindo, Will Patton, Robert Duvall, Christopher Eccleston Writer: Scott Rosenberg. Director: Dominic Sena.
Review by Scott Hunt Movie Hunt: http://netdirect.net/~hunt/index.html
Rating: Near Miss (1 out of 4 stars)
The stereotypical American male has an undeniable fetishistic love of sports cars. Producer Jerry Bruckheimer plays upon that attraction with a movie so loaded with testosterone and laced titillatingly with shot after frenetic shot of powerful muscle cars, sleek foreign road huggers and iconic speed machines that many males will leave the theater in an orgasmic haze. Gone is 60 Seconds is an orgy of maleness gone horribly awry.
Cage is legendary retired car thief, Memphis Raines (don't you love cute movie names), who must call upon his time worn skills to save his thick-headed brother (Ribisi) from being killed.  Fifty cars, to be exact. Poor Kip screws the pooch and bungles the job badly. If the cars aren't delivered in three days, bossman has a casket carved out just for Kip. Literally. If only someone could save him. Hmmmm..wonder what Memphis is doing?
In order to give the film some emotional heft, there are several subplots designed to tug at our heartstrings or give us the thrill of...yawn, excuse me, dramatic tension. Shadowing Memphis is an old law enforcement foe (Lindo) who's looking to send Memphis away. Will he catch him? There's old flame Sway (Jolie), who had her heart broken by Memphis years ago. Will they get back together? Shortsighted, thrill seeker Kip idolizes his brother, yet resents him for moving away from the family. Will they reconnect? Raines old mentor (Duvall) has long since left the life of crime.  Can you answer all these questions correctly in 2 seconds without seeing the film first? I'll bet you can.
Following the opening credits, which fill you in on the accomplishments of the Raines family through a montage of old photos, we was taken full throttle into the splendor that is Memphis. He's first shown living the good life teaching young children to drive go-carts. In a later scene, as misfit brother Kip knowingly tells Memphis he has the stolen car situation under control, all the while making breakfast, a metaphor is made of Shakespearean proportions. Just as a pan of grease flares up with Kip clueless to how to quell it, big brother Memphis calmly and efficiently throws some salt on it. Looks like everything might turn out alright after all. You know this because the music swells on the crest of violins.
That's about as strong as the characterization gets, which is a shame. Bruckheimer has a real talent for loading his movies with an obscene amount of talent given the task at hand.  Or maybe it's just the cars. Duvall trots out his ornery, but sweet old codger outfit. I'm sure he's still laughing at taking a paycheck for this one. Lindo projects a warm hearted, but tightly focused detective that almost transcends the material. The biggest waste of resources is Vinnie Jones, who plays a mute accomplice of Memphis. Without saying a word, he is easily the most charismatic person in the movie. Like a blast of nitrous oxide, he attacks each scene with a straightforward zeal. Too bad his minutes onscreen are so few. Somehow, Bruckheimer manages to attract top Hollywood acting talent to high concept, poorly written movies, gussies up the film with lots of gold hues and pleasingly stylized action and they sell like proverbial hotcakes.
Every time something clever happens it's counterbalanced by something so overtly wrong that it jerks you back into realizing you're watching a movie. There's a innovative usage of black lighting that goes from being a novelty to a part of the plot. It's counterbalanced by an extremely feeble attempt at humor by having an Asian American repeatedly failing a driver's test. Imagine the yuks. There's a segment where one of the thieves shows another his cool fake fingerprint trick.  The ramifications are never explored. Then there's the ridiculousness of the many cops who actually shoot at fleeing cars.
This is a movie made of pretty, but tepid car chases strung together by just enough character interaction to move the plot along. Gone in 60 Seconds aptly describes how long it'll take for this marginally entertaining, but empty film to leave your memory.
The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


Home
(current)
Comparison
Weather Data Plots
Comparisons
City Latitude vs Max Temperature. Click pic for more details
City Latitude vs Humidity. Click pic for more details
City Latitude vs Cloudiness. Click pic for more details
Latitude vs Wind Speed. Click pic for more details


The AWT Focus Subsystem
Prior to Java 2 Standard Edition, JDK 1.4, the AWT focus subsystem was inadequate. It suffered from major design and API problems, as well as over a hundred open bugs. Many of these bugs were caused by platform inconsistencies, or incompatibilities between the native focus system for heavyweights and the Java focus system for lightweights.
The single worst problem with the AWT focus implementation was the inability to query for the currently focused Component. Not only was there no API for such a query, but also, because of an insufficient architecture, such information was not even maintained by the code.
Almost as bad was the inability of lightweight children of a Window
(not a Frame or a Dialog) to receive keyboard input. This problem
existed because Windows never received WINDOW_ACTIVATED
events and thus could never be activated, and only active Windows
could contain focused Components.
In addition, many developers noted that the APIs for FocusEvent and WindowEvent were insufficient because they did not provide a way for determining the "opposite" Component involved in the focus or activation change. For example, when a Component received a FOCUS_LOST event, it had no way of knowing which Component was gaining focus. Since Microsoft Windows provides this functionality for free, developers migrating from Microsoft Windows C/C++ or Visual Basic to Java had been frustrated by the omission.
To address these and other deficiencies, we have designed a new focus model for the AWT in JDK 1.4. The primary design changes were the construction of a new centralized KeyboardFocusManager class, and a lightweight focus architecture. The amount of focus-related, platform-dependent code has been minimized and replaced by fully pluggable and extensible public APIs in the AWT. While we have attempted to remain backward compatible with the existing implementation, we were forced to make minor incompatible changes in order to reach an elegant and workable conclusion. We anticipate that these incompatibilities will have only a trivial impact on existing applications.
This document is a formal specification both of the new APIs and of existing APIs which remain relevant in the new model. Combined with the javadoc for focus-related classes and methods, this document should enable developers to create substantial AWT and Swing applications with a focus behavior that is customized yet consistent across platforms. This document has the following sections:
- Overview of KeyboardFocusManager
- KeyboardFocusManager and Browser Contexts
- KeyEventDispatcher
- FocusEvent and WindowEvent
- Event Delivery
- Opposite Components and Windows
- Temporary FocusEvents
- Focus Traversal
- Focus Traversal Policy
- Focus Traversal Policy Providers
- Programmatic Traversal
- Focusability
- Focusable Windows
- Requesting Focus
- Focus and PropertyChangeListener
- Focus and VetoableChangeListener
- Z-Order
- Replacing DefaultKeyboardFocusManager
- Incompatibilities with Previous Releases
Overview of KeyboardFocusManager
The focus model is centralized around a single class, KeyboardFocusManager, that provides a set of APIs for client code to inquire about the current focus state, initiate focus changes, and replace default focus event dispatching with a custom dispatcher. Clients can inquire about the focus state directly, or can register a PropertyChangeListener that will receive PropertyChangeEvents when a change to the focus state occurs.
KeyboardFocusManager introduces the following main concepts and their terminology:
- The "focus owner" -- the Component which typically receives keyboard input.
- The "permanent focus owner" -- the last Component to receive focus permanently. The "focus owner" and the "permanent focus owner" are equivalent unless a temporary focus change is currently in effect. In such a situation, the "permanent focus owner" will again be the "focus owner" when the temporary focus change ends.
- The "focused Window" -- the Window which contains the "focus owner".
- The "active Window" -- the Frame or Dialog that is either the "focused Window", or the first Frame or Dialog that is an owner of the "focused Window".
- "Focus traversal" -- the user's ability to change the "focus owner" without moving the cursor. Typically, this is done using the keyboard (for example, by using the TAB key), or an equivalent device in an accessible environment. Client code can also initiate traversal programmatically. Normal focus traversal can be either "forward" to the "next" Component, or "backward" to the "previous" Component.
- "Focus traversal cycle" -- a portion of the Component hierarchy, such that normal focus traversal "forward" (or "backward") will traverse through all of the Components in the focus cycle, but no other Components. This cycle provides a mapping from an arbitrary Component in the cycle to its "next" (forward traversal) and "previous" (backward traversal) Components.
- "Traversable Component" -- Component that is in the focus traversal cycle.
- "Non-traversable Component" -- Component that is not in the focus traversal cycle. Note that a non-traversable Component can nevertheless be focused in other way (e.g. by direct focus request).
- "Focus cycle root" -- Container that is the root of the Component hierarchy for a particular "focus traversal cycle". When the "focus owner" is a Component inside a particular cycle, normal forward and backward focus traversal cannot move the "focus owner" above the focus cycle root in the Component hierarchy. Instead, two additional traversal operations, "up cycle" and "down cycle", are defined to allow keyboard and programmatic navigation up and down the focus traversal cycle hierarchy.
- "Focus traversal policy provider" - Container which has
"FocusTraversalPolicyProvider" property as true. This Container will
be used to acquire focus traversal policy. This container doesn't
define new focus cycle but only modifies the order by which its
children are traversed "forward" and "backward". Focus traversal
policy provider can be set using
setFocusTraversalPolicyProvider
on the Container.
Every Window and JInternalFrame is, by default, a "focus cycle root". If it's the only focus cycle root, then all of its focusable descendants should be in its focus cycle, and its focus traversal policy should enforce that they are by making sure that all will be reached during normal forward (or backward) traversal. If, on the other hand, the Window or JInternalFrame has descendants that are also focus cycle roots, then each such descendant is a member of two focus cycles: the one that it is the root of, and the one of its nearest focus-cycle-root ancestor. In order to traverse the focusable components belonging to the focus cycle of such a "descendant" focus cycle root, one first traverses (forward or backward) to reach the descendant, and then uses the "down cycle" operation to reach, in turn, its descendants.
Here is an example:
Assume the following:
- A is a
Window
, which means that it must be a focus cycle root. - B and D are
Container
s that are focus cycle roots. - C is a
Container
that is not a focus cycle root. - G, H, E, and F are all
Component
s.
- A is a root, and A, B, C, and F are members of A's cycle.
- B is a root, and B, D, and E are members of B's cycle.
- D is a root, and D, G, and H are members of D's cycle.
KeyboardFocusManager
is an abstract class. AWT provides a default
implementation in the DefaultKeyboardFocusManager
class.
KeyboardFocusManager and Browser Contexts
Some browsers partition applets in different code bases into separate contexts, and establish walls between these contexts. Each thread and each Component is associated with a particular context and cannot interfere with threads or access Components in other contexts. In such a scenario, there will be one KeyboardFocusManager per context. Other browsers place all applets into the same context, implying that there will be only a single, global KeyboardFocusManager for all applets. This behavior is implementation-dependent. Consult your browser's documentation for more information. No matter how many contexts there may be, however, there can never be more than one focus owner, focused Window, or active Window, per ClassLoader.
KeyEventDispatcher and KeyEventPostProcessor
While the user's KeyEvents should generally be delivered to the focus owner, there are rare cases where this is not desirable. An input method is an example of a specialized Component that should receive KeyEvents even though its associated text Component is and should remain the focus owner.
A KeyEventDispatcher is a lightweight interface that allows client code to pre-listen to all KeyEvents in a particular context. Instances of classes that implement the interface and are registered with the current KeyboardFocusManager will receive KeyEvents before they are dispatched to the focus owner, allowing the KeyEventDispatcher to retarget the event, consume it, dispatch it itself, or make other changes.
For consistency, KeyboardFocusManager itself is a KeyEventDispatcher. By default, the current KeyboardFocusManager will be the sink for all KeyEvents not dispatched by the registered KeyEventDispatchers. The current KeyboardFocusManager cannot be completely deregistered as a KeyEventDispatcher. However, if a KeyEventDispatcher reports that it dispatched the KeyEvent, regardless of whether it actually did so, the KeyboardFocusManager will take no further action with regard to the KeyEvent. (While it is possible for client code to register the current KeyboardFocusManager as a KeyEventDispatcher one or more times, there is no obvious reason why this would be necessary, and therefore it is not recommended.)
Client-code may also post-listen to KeyEvents in a particular context using the KeyEventPostProcessor interface. KeyEventPostProcessors registered with the current KeyboardFocusManager will receive KeyEvents after the KeyEvents have been dispatched to and handled by the focus owner. The KeyEventPostProcessors will also receive KeyEvents that would have been otherwise discarded because no Component in the application currently owns the focus. This will allow applications to implement features that require global KeyEvent post- handling, such as menu shortcuts.
Like KeyEventDispatcher, KeyboardFocusManager also implements KeyEventPostProcessor, and similar restrictions apply to its use in that capacity.
FocusEvent and WindowEvent
The AWT defines the following six event types central to the focus
model in two different java.awt.event
classes:
WindowEvent.WINDOW_ACTIVATED
: This event is dispatched to a Frame or Dialog (but never a Window which is not a Frame or Dialog) when it becomes the active Window.WindowEvent.WINDOW_GAINED_FOCUS
: This event is dispatched to a Window when it becomes the focused Window. Only focusable Windows can receive this event.FocusEvent.FOCUS_GAINED
: This event is dispatched to a Component when it becomes the focus owner. Only focusable Components can receive this event.FocusEvent.FOCUS_LOST
: This event is dispatched to a Component when it is no longer the focus owner.WindowEvent.WINDOW_LOST_FOCUS
: This event is dispatched to a Window when it is no longer the focused Window.WindowEvent.WINDOW_DEACTIVATED
: This event is dispatched to a Frame or Dialog (but never a Window which is not a Frame or Dialog) when it is no longer the active Window.
Event Delivery
If the focus is not in java application and the user clicks on a focusable child Componenta of an inactive Frame b, the following events will be dispatched and handled in order:
- b will receive a
WINDOW_ACTIVATED
event. - Next, b will receive a
WINDOW_GAINED_FOCUS
event. - Finally, a will receive a
FOCUS_GAINED
event.
- a will receive a
FOCUS_LOST
event. - b will receive a
WINDOW_LOST_FOCUS
event. - b will receive a
WINDOW_DEACTIVATED
event. - d will receive a
WINDOW_ACTIVATED
event. - d will receive a
WINDOW_GAINED_FOCUS
event. - c will receive a
FOCUS_GAINED
event.
In addition, each event type will be dispatched in 1-to-1
correspondence with its opposite event type. For example, if a
Component receives a FOCUS_GAINED
event, under no
circumstances can it ever receive another FOCUS_GAINED
event without an intervening FOCUS_LOST
event.
Finally, it is important to note that these events are delivered for
informational purposes only. It is impossible, for example, to prevent
the delivery of a pending FOCUS_GAINED
event by requesting
focus back to the Component losing focus while handling the preceding
FOCUS_LOST
event. While client code may make such a request,
the pending FOCUS_GAINED
will still be delivered,
followed later by the events transferring focus back to the original
focus owner.
If it is absolutely necessary to suppress the FOCUS_GAINED
event,
client code can install a VetoableChangeListener
which
rejects the focus change. See Focus
and VetoableChangeListener.
Opposite Components and Windows
Each event includes information about the "opposite" Component or
Window involved in the focus or activation change. For example, for a
FOCUS_GAINED
event, the opposite Component is the Component
that lost focus. If the focus or activation change occurs with a native
application, with a Java application in a different VM or context, or
with no other Component, then the opposite Component or Window is
null. This information is accessible using
FocusEvent.getOppositeComponent
or
WindowEvent.getOppositeWindow
.
On some platforms, it is not possible to discern the opposite Component or Window when the focus or activation change occurs between two different heavyweight Components. In these cases, the opposite Component or Window may be set to null on some platforms, and to a valid non-null value on other platforms. However, for a focus change between two lightweight Components which share the same heavyweight Container, the opposite Component will always be set correctly. Thus, a pure Swing application can ignore this platform restriction when using the opposite Component of a focus change that occurred within a top-level Window.
Temporary FocusEvents
FOCUS_GAINED
and FOCUS_LOST
events are
marked as either temporary or permanent.
Temporary FOCUS_LOST
events are sent when a Component is
losing the focus, but will regain the focus shortly. These events
can be useful when focus changes are used as triggers for validation
of data. For instance, a text Component may want to commit its
contents when the user begins interacting with another Component,
and can accomplish this by responding to FOCUS_LOST
events.
However, if the FocusEvent
received is temporary,
the commit should not be done, since the text field will be receiving
the focus again shortly.
A permanent focus transfer typically occurs as the result of a user
clicking on a selectable, heavyweight Component, focus traversal with
the keyboard or an equivalent input device, or from a call to
requestFocus()
or requestFocusInWindow()
.
A temporary focus transfer typically occurs as the result of showing a Menu or PopupMenu, clicking or dragging a Scrollbar, moving a Window by dragging the title bar, or making another Window the focused Window. Note that on some platforms, these actions may not generate any FocusEvents at all. On others, temporary focus transfers will occur.
When a Component receives a temporary FOCUS_LOST
event,
the event's opposite Component (if any) may receive a temporary
FOCUS_GAINED
event, but could also receive a permanent
FOCUS_GAINED
event. Showing a Menu or PopupMenu, or
clicking or dragging a Scrollbar, should generate a temporary
FOCUS_GAINED
event. Changing the focused Window,
however, will yield a permanent FOCUS_GAINED
event
for the new focus owner.
The Component class includes variants of requestFocus
and
requestFocusInWindow
which take a desired temporary state as a
parameter. However, because specifying an arbitrary temporary state
may not be implementable on all native windowing systems, correct
behavior for this method can be guaranteed only for lightweight
Components. This method is not intended for general use, but exists
instead as a hook for lightweight Component libraries, such as Swing.
Focus Traversal
Each Component defines its own Set of focus traversal keys for a given
focus traversal operation. Components support separate Sets of keys
for forward and backward traversal, and also for traversal up one
focus traversal cycle. Containers which are focus cycle roots also
support a Set of keys for traversal down one focus traversal cycle. If
a Set is not explicitly defined for a Component, that Component
recursively inherits a Set from its parent, and ultimately from a
context-wide default set on the current KeyboardFocusManager
.
Using the AWTKeyStroke
API, client code can specify
on which of two specific KeyEvents, KEY_PRESSED
or
KEY_RELEASED
, the focus traversal operation will occur.
Regardless of which KeyEvent is specified, however, all KeyEvents
related to the focus traversal key, including the associated
KEY_TYPED
event, will be consumed, and will not be
dispatched to any Component. It is a runtime error to specify a
KEY_TYPED
event as mapping to a focus traversal operation,
or to map the same event to multiple focus traversal operations for any
particular Component or for a KeyboardFocusManager
's defaults.
The default focus traversal keys are implementation-dependent. Sun recommends that the all implementations for a particular native platform use the same keys. For Windows and Unix, the recommendations are:
- traverse forward to the next Component:
TextAreas:CTRL-TAB
onKEY_PRESSED
All others:TAB
onKEY_PRESSED
andCTRL-TAB
onKEY_PRESSED
- traverse backward to the previous Component:
TextAreas:CTRL-SHIFT-TAB
onKEY_PRESSED
All others:SHIFT-TAB
onKEY_PRESSED
andCTRL-SHIFT-TAB
onKEY_PRESSED
- traverse up one focus traversal cycle : <none>
- traverse down one focus traversal cycle : <none>
Components can enable and disable all of their focus traversal keys en
masse using Component.setFocusTraversalKeysEnabled
. When focus
traversal keys are disabled, the Component receives all KeyEvents for
those keys. When focus traversal keys are enabled, the Component never
receives KeyEvents for traversal keys; instead, the KeyEvents are
automatically mapped to focus traversal operations.
For normal forward and backward traversal, the AWT focus
implementation determines which Component to focus next based on the
FocusTraversalPolicy
of
the focus owner's focus cycle root or focus traversal policy provider. If the
focus owner is a focus cycle root, then it may be ambiguous as to which
Components represent the next and previous Components to focus during
normal focus traversal. Thus, the current
KeyboardFocusManager
maintains a reference to the
"current" focus cycle root, which is global across all contexts. The
current focus cycle root is used to resolve the ambiguity.
For up-cycle traversal, the focus owner is set to the current focus owner's focus cycle root, and the current focus cycle root is set to the new focus owner's focus cycle root. If, however, the current focus owner's focus cycle root is a top-level window, then the focus owner is set to the focus cycle root's default component to focus, and the current focus cycle root is unchanged.
For down-cycle traversal, if the current focus owner is a focus cycle root, then the focus owner is set to the current focus owner's default component to focus, and the current focus cycle root is set to the current focus owner. If the current focus owner is not a focus cycle root, then no focus traversal operation occurs.
FocusTraversalPolicy
A FocusTraversalPolicy
defines the order in which Components within
a particular focus cycle root or focus traversal policy provider are
traversed. Instances of FocusTraversalPolicy
can be shared across
Containers, allowing those Containers to implement the same traversal policy.
FocusTraversalPolicies do not need to be reinitialized when the
focus-traversal-cycle hierarchy changes.
Each FocusTraversalPolicy
must define the following
five algorithms:
- Given a focus cycle root and a Component a in that cycle, the next Component after a.
- Given a focus cycle root and a Component a in that cycle, the previous Component before a.
- Given a focus cycle root, the "first" Component in that cycle. The "first" Component is the Component to focus when traversal wraps in the forward direction.
- Given a focus cycle root, the "last" Component in that cycle. The "last" Component is the Component to focus when traversal wraps in the reverse direction.
- Given a focus cycle root, the "default" Component in that cycle. The "default" Component will be the first to receive focus when traversing down into a new focus traversal cycle. This may be the same as the "first" Component, but need not be.
A FocusTraversalPolicy
may optionally provide an
algorithm for the following:
Given a Window, the "initial" Component in that Window. The initial Component will be the first to receive focus when the Window is first made visible. By default, this is the same as the "default" Component.In addition, Swing provides a subclass of
FocusTraversalPolicy
,
InternalFrameFocusTraversalPolicy
, which allows developers
to provide an algorithm for the following:
Given aAJInternalFrame
, the "initial" Component in thatJInternalFrame
. The initial Component is the first to receive focus when theJInternalFrame
is first selected. By default, this is the same as theJInternalFrame
's default Component to focus.
FocusTraversalPolicy
is installed on a Container using
Container.setFocusTraversalPolicy
. If a policy is not explicitly
set, then a Container inherits its policy from its nearest focus-cycle-root
ancestor. Top-levels initialize their focus traversal policies using the context
default policy. The context default policy is established by using
KeyboardFocusManager. setDefaultFocusTraversalPolicy
.
AWT provides two standard FocusTraversalPolicy
implementations for use by client code.
ContainerOrderFocusTraversalPolicy
: Iterates across the Components in a focus traversal cycle in the order they were added to their Containers. Each Component is tested for fitness using the accept(Component) method. By default, a Component is fit only if it is visible, displayable, enabled, and focusable.- By default, ContainerOrderFocusTraversalPolicy implicitly transfers focus down-cycle. That is, during normal forward focus traversal, the Component traversed after a focus cycle root will be the focus-cycle-root's default Component to focus, regardless of whether the focus cycle root is a traversable or non-traversable Container (see the pic.1,2 below). Such behavior provides backward compatibility with applications designed without the concepts of up- and down-cycle traversal.
DefaultFocusTraversalPolicy
: A subclass ofContainerOrderFocusTraversalPolicy
which redefines the fitness test. If client code has explicitly set the focusability of a Component by either overridingComponent.isFocusTraversable()
orComponent.isFocusable()
, or by callingComponent.setFocusable(boolean)
, then aDefaultFocusTraversalPolicy
behaves exactly like aContainerOrderFocusTraversalPolicy
. If, however, the Component is relying on default focusability, then aDefaultFocusTraversalPolicy
will reject all Components with non-focusable peers.
The focusability of a peer is implementation-dependent. Sun recommends that all implementations for a particular native platform construct peers with the same focusability. The recommendations for Windows and Unix are that Canvases, Labels, Panels, Scrollbars, ScrollPanes, Windows, and lightweight Components have non-focusable peers, and all other Components have focusable peers. These recommendations are used in the Sun AWT implementations. Note that the focusability of a Component's peer is different from, and does not impact, the focusability of the Component itself.
Swing provides two additional, standard FocusTraversalPolicy implementations for use by client code. Each implementation is an InternalFrameFocusTraversalPolicy.
- SortingFocusTraversalPolicy: Determines traversal order by sorting the Components of a focus traversal cycle based on a given Comparator. Each Component is tested for fitness using the accept(Component) method. By default, a Component is fit only if it is visible, displayable, enabled, and focusable.
- By default, SortingFocusTraversalPolicy implicitly transfers focus down-cycle. That is, during normal forward focus traversal, the Component traversed after a focus cycle root will be the focus-cycle-root's default Component to focus, regardless of whether the focus cycle root is a traversable or non-traversable Container (see the pic.1,2 below). Such behavior provides backward compatibility with applications designed without the concepts of up- and down-cycle traversal.
- LayoutFocusTraversalPolicy: A subclass of
SortingFocusTraversalPolicy which sorts Components based on their
size, position, and orientation. Based on their size and position,
Components are roughly categorized into rows and columns. For a
Container with horizontal orientation, columns run left-to-right or
right-to-left, and rows run top-to-bottom. For a Container with
vertical orientation, columns run top-to-bottom and rows run
left-to-right or right-to-left. All columns in a row are fully
traversed before proceeding to the next row.
In addition, the fitness test is extended to exclude JComponents that have or inherit empty InputMaps.
The figures below show an implicit focus transfer:
pic.1
pic.2
Assume the following:
- A, B and C are components in some window (a container)
- R is a container in the window and it is a parent of B and C. Besides, R is a focus cycle root.
- B is the default component in the focus traversal cycle of R
- R is a traversable Container in the pic.1, and it is a non-traversable Container in the pic.2.
- In such a case a forward traversal will look as follows:
- pic.1 : A → R → B → C
- pic.2 : A → B → C
Swing applications, or mixed Swing/AWT applications, that use one of the standard look and feels, or any other look and feel derived from BasicLookAndFeel, will use LayoutFocusTraversalPolicy for all Containers by default.
All other applications, including pure AWT applications, will use
DefaultFocusTraversalPolicy
by default.
Focus Traversal Policy Providers
A Container that isn't a focus cycle root has an option to provide a
FocusTraversalPolicy of its own. To do so, one needs to set Container's focus
traversal policy provider property to true
with the call to
Container.setFocusTraversalPolicyProvider(boolean)
To determine whether a Container is a focus traversal policy provider, the
following method should be used:
Container.isFocusTraversalPolicyProvider()
If focus traversal policy provider property is set on a focus cycle root, it
isn't considered a focus traversal policy provider and behaves just like any
other focus cycle root.
The main difference between focus cycle roots and focus traversal policy providers is that the latter allow focus to enter and leave them just as all other Containers. However, children inside focus traversal policy provider are traversed in the order determined by provider's FocusTraversalPolicy. In order to enable focus traversal policy providers to behave this way, FocusTraversalPolicies treat them in the following manner:
- Focus traversal policy providers can be passed to FocusTraversalPolicy methods instead of focus cycle roots.
- When calculating next or previous Component in
FocusTraversalPolicy.getComponentAfter
orFocusTraversalPolicy.getComponentBefore
,- if a Component is a child of a focus traversal policy provider,
the next and previous for this Component are determined using this
focus traversal policy provider's FocusTraversalPolicy. However,
in order for focus to leave the provider, the following rules are
applied:
- if at some point the
next
found Component is thefirst
Component of focus traversal policy provider, the Component after the focus traversal policy provider is returned - if at some point the
previous
found Component is thelast
Component of focus traversal policy provider, the Component before the focus traversal policy provider is returned
- if at some point the
- When calculating the next Component in
FocusTraversalPolicy.getComponentAfter
,- if an obtained Component is a non-traversable Container and it is a focus traversal policy provider, then the default Component of that provider is returned
- if the Component passed to the
FocusTraversalPolicy.getComponentAfter
method is a traversable Container and it is a focus traversal policy provider, then the default Component of this provider is returned
- When calculating the previous Component in
FocusTraversalPolicy.getComponentBefore
,- if an obtained Component is a Container (traversable or non-traversable) and it is a focus traversal policy provider, then the last Component of that provider is returned
- if a Component is a child of a focus traversal policy provider,
the next and previous for this Component are determined using this
focus traversal policy provider's FocusTraversalPolicy. However,
in order for focus to leave the provider, the following rules are
applied:
- When calculating the first Component in FocusTraversalPolicy.getFirstComponent,
- if an obtained Component is a non-traversable Container and it is a focus traversal policy provider, then the default Component of that provider is returned
- if an obtained Component is a traversable Container and it is a focus traversal policy provider, then that Container itself is returned
- When calculating the last Component in FocusTraversalPolicy.getLastComponent,
- if an obtained Component is a Container (traversable or non-traversable) and it is a focus traversal policy provider, then the last Component of that provider is returned
Programmatic Traversal
In addition to user-initiated focus traversal, client code can
initiate a focus traversal operation programmatically. To client code,
programmatic traversals are indistinguishable from user-initiated
traversals. The preferred way to initiate a programmatic traversal is
to use one of the following methods on KeyboardFocusManager
:
KeyboardFocusManager.focusNextComponent()
KeyboardFocusManager.focusPreviousComponent()
KeyboardFocusManager.upFocusCycle()
KeyboardFocusManager.downFocusCycle()
Each of these methods initiates the traversal operation with the current focus owner. If there is currently no focus owner, then no traversal operation occurs. In addition, if the focus owner is not a focus cycle root, then downFocusCycle() performs no traversal operation.
KeyboardFocusManager
also supports the following variants
of these methods:
KeyboardFocusManager.focusNextComponent(Component)
KeyboardFocusManager.focusPreviousComponent(Component)
KeyboardFocusManager.upFocusCycle(Component)
KeyboardFocusManager.downFocusCycle(Container)
Alternate, but equivalent, APIs are defined on the Component and Container classes themselves:
Component.transferFocus()
Component.transferFocusBackward()
Component.transferFocusUpCycle()
Container.transferFocusDownCycle()
KeyboardFocusManager
variants, each of these methods
initiates the traversal operation as though the Component is the focus
owner, though it need not be.
Also note that hiding or disabling the focus owner, directly or indirectly via an ancestor, or making the focus owner non-displayable or non-focusable, initiates an automatic, forward focus traversal. While hiding any ancestor, lightweight or heavyweight, will always indirectly hide its children, only disabling a heavyweight ancestor will disable its children. Thus, disabling a lightweight ancestor of the focus owner does not automatically initiate a focus traversal.
If client code initiates a focus traversal, and there is no other Component to focus, then the focus owner remains unchanged. If client code initiates an automatic focus traversal by hiding the focus owner, directly or indirectly, or by making the focus owner non-displayable or non-focusable, and there is no other Component to focus, then the global focus owner is cleared. If client code initiates an automatic focus traversal by disabling the focus owner, directly or indirectly, and there is no other Component to focus, then the focus owner remains unchanged.
Focusability
A focusable Component can become the focus owner ("focusability") and participates in keyboard focus traversal ("focus traversability") with a FocusTraversalPolicy. There is no separation of these two concepts; a Component must either be both focusable and focus traversable, or neither. A Component expresses this state via the isFocusable() method. By default, all Components return true from this method. Client code can change this default by calling Component.setFocusable(boolean).
Focusable Windows
To support palette windows and input methods, client code can prevent a Window from becoming the focused Window. By transitivity, this prevents the Window or any of its descendants from becoming the focus owner. Non-focusable Windows may still own Windows that are focusable. By default, every Frame and Dialog is focusable. Every Window which is not a Frame or Dialog, but whose nearest owning Frame or Dialog is showing on the screen, and which has at least one Component in its focus traversal cycle, is also focusable by default. To make a Window non-focusable, use Window.setFocusableWindowState(false).
If a Window is non-focusable, this restriction is enforced when the
KeyboardFocusManager
sees a WINDOW_GAINED_FOCUS
event for the Window. At this point, the focus change is rejected and
focus is reset to a different Window. The rejection recovery scheme
is the same as if a VetoableChangeListener
rejected the
focus change. See Focus
and VetoableChangeListener.
Because the new focus implementation requires that KeyEvents intended for a Window or its descendants be proxied through a child of the Window's owner, and because this proxy must be mapped on X11 in order to receive events, a Window whose nearest owning Frame or Dialog is not showing could never receive KeyEvents on X11. To support this restriction, we have made a distinction between a Window's "window focusability" and its "window focusability state". A Window's focusability state is combined with the showing state of the Window's nearest owning Frame or Dialog to determine the Window's focusability. By default, all Windows have a focusability state of true. Setting a Window's focusability state to false ensures that it will not become the focused Window regardless of the showing state of its nearest owning Frame or Dialog.
Swing allows applications to create JWindows with null owners. Swing constructs all such JWindows so that they are owned by a private, hidden Frame. Because the showing state of this Frame will always be false, a JWindow constructed will a null owner can never be the focused Window, even if it has a Window focusability state of true.
If the focused Window is made non-focusable, then the AWT will attempt to focus the most recently focused Component of the Window's owner. The Window's owner will thus become the new focused Window. If the Window's owner is also a non-focusable Window, then the focus change request will proceed up the ownership hierarchy recursively. Since not all platforms support cross-Window focus changes (see Requesting Focus), it is possible that all such focus change requests will fail. In this case, the global focus owner will be cleared and the focused Window will remain unchanged.
Requesting Focus
A Component can request that it become the focus owner by calling
Component.requestFocus()
. This initiates a permanent
focus transfer to the Component only if the Component is displayable,
focusable, visible and all of its ancestors (with the exception of the
top-level Window) are visible. The request will be immediately denied if
any of these conditions is not met. A disabled Component may be
the focus owner; however, in this case, all KeyEvents will be discarded.
The request will also be denied if the Component's top-level Window is not the focused Window and the platform does not support requesting focus across Windows. If the request is denied for this reason, the request is remembered and will be granted when the Window is later focused by the user. Otherwise, the focus change request changes the focused Window as well.
There is no way to determine synchronously whether a focus change
request has been granted. Instead, client code must install a
FocusListener on the Component and watch for the delivery of a
FOCUS_GAINED
event. Client code must not assume that
the Component is the focus owner until it receives this event.
The event may or may not be delivered before requestFocus()
returns. Developers must not assume one behavior or the other.
The AWT supports type-ahead if all focus change requests are made on the EventDispatchThread. If client code requests a focus change, and the AWT determines that this request might be granted by the native windowing system, then the AWT will notify the current KeyboardFocusManager that is should enqueue all KeyEvents with a timestamp later than the that of the event currently being handled. These KeyEvents will not be dispatched until the new Component becomes the focus owner. The AWT will cancel the delayed dispatching request if the focus change does not succeed at the native level, if the Component's peer is disposed, or if the focus change is vetoed by a VetoableChangeListener. KeyboardFocusManagers are not required to support type-ahead if a focus change request is made from a thread other than the EventDispatchThread.
Because Component.requestFocus()
cannot be implemented
consistently across platforms, developers are encouraged to use
Component.requestFocusInWindow()
instead. This method
denies cross-Window focus transfers on all platforms automatically.
By eliminating the only platform-specific element of the focus transfer,
this method achieves consistent cross-platform behavior.
In addition, requestFocusInWindow()
returns a boolean value.
If 'false' is returned, the request is guaranteed to fail. If 'true' is
returned, the request will succeed unless it is vetoed, or an
extraordinary event, such as disposal of the Component's peer, occurs
before the request can be granted by the native windowing
system. Again, while a return value of 'true' indicates that the
request is likely to succeed, developers must never assume that this
Component is the focus owner until this Component receives a
FOCUS_GAINED
event.
If client code wants no Component in the application to be the focus
owner, it can call the method KeyboardFocusManager
.
clearGlobalFocusOwner()
on the current
KeyboardFocusManager
. If there exists a focus owner
when this method is called, the focus owner will receive a permanent
FOCUS_LOST
event. After this point, the AWT
focus implementation will discard all KeyEvents until the user or
client code explicitly sets focus to a Component.
The Component class also supports variants of requestFocus
and
requestFocusInWindow
that allow client code to specify
a temporary state.
See Temporary FocusEvents
Focus and PropertyChangeListener
Client code can listen to changes in context-wide focus state, or to changes in focus-related state in Components, via PropertyChangeListeners.
The KeyboardFocusManager
supports the following properties:
focusOwner
: the focus ownerfocusedWindow
: the focused WindowactiveWindow
: the active WindowdefaultFocusTraversalPolicy
: the default focus traversal policyforwardDefaultFocusTraversalKeys
: the Set of defaultFORWARD_TRAVERSAL_KEYS
backwardDefaultFocusTraversalKeys
: the Set of defaultBACKWARD_TRAVERSAL_KEYS
upCycleDefaultFocusTraversalKeys
: the Set of defaultUP_CYCLE_TRAVERSAL_KEYS
downCycleDefaultFocusTraversalKeys
: the Set of defaultDOWN_CYCLE_TRAVERSAL_KEYS
currentFocusCycleRoot
: the current focus cycle root
A PropertyChangeListener
installed on the current
KeyboardFocusManager
will only see these changes within
the KeyboardFocusManager
's context, even though the
focus owner, focused Window, active Window, and current focus cycle
root comprise the global focus state shared by all contexts.
We believe this is less intrusive than requiring client code to pass
a security check before installing a PropertyChangeListener
.
Component supports the following focus-related properties:
focusable
: the Component's focusabilityfocusTraversalKeysEnabled
: the Component's focus traversal keys enabled stateforwardFocusTraversalKeys
: the Component's Set ofFORWARD_TRAVERSAL_KEYS
backwardFocusTraversalKeys
: the Component's Set ofBACKWARD_TRAVERSAL_KEYS
upCycleFocusTraversalKeys
: the Component's Set ofUP_CYCLE_TRAVERSAL_KEYS
In addition to the Component properties, Container supports the following focus-related properties:
downCycleFocusTraversalKeys
: the Container's Set ofDOWN_CYCLE_TRAVERSAL_KEYS
focusTraversalPolicy
: the Container's focus traversal policyfocusCycleRoot
: the Container's focus-cycle-root state
In addition to the Container properties, Window supports the following focus-related property:
focusableWindow
: the Window's focusable Window state
Also note that a PropertyChangeListener
installed on a
Window will never see a PropertyChangeEvent
for the
focusCycleRoot
property.
A Window is always a focus cycle root; this property cannot change.
Focus and VetoableChangeListener
The KeyboardFocusManager
also supports
VetoableChangeListener
s for the following properties:
- "focusOwner": the focus owner
- "focusedWindow": the focused Window
- "activeWindow": the active Window
VetoableChangeListeners are notified of the state change before the change is reflected in the KeyboardFocusManager. Conversely, PropertyChangeListeners are notified after the change is reflected. It follows that all VetoableChangeListeners will be notified before any PropertyChangeListener.
VetoableChangeListeners must be idempotent, and must veto both loss
and gain events for a particular focus change (e.g., both
FOCUS_LOST
and FOCUS_GAINED
). For example,
if a VetoableChangeListener
vetoes a FOCUS_LOST
event, a KeyboardFocusManager
is not required to search the
EventQueue
and remove the associated pending
FOCUS_GAINED
event. Instead, the
KeyboardFocusManager
is free to attempt to
dispatch this event and it is the responsibility of the
VetoableChangeListener
to veto it as well. In addition,
during processing of the FOCUS_GAINED
event, the
KeyboardFocusManager
may attempt to resync the global
focus state by synthesizing another FOCUS_LOST
event.
This event must be vetoed just as the first FOCUS_LOST
event was.
A KeyboardFocusManager
may not hold any locks while
notifying PropertyChangeListener
s of a state change.
This requirement is relaxed for VetoableChangeListeners
,
however. Therefore, client-definied VetoableChangeListener
s
should avoid acquiring additional locks inside
vetoableChange(PropertyChangeEvent)
as this may lead to deadlock.
If a focus or activation change is rejected, the KeyboardFocusManager
will initiate rejection recovery as follows:
- If a focused or active Window change was rejected, then the
focused or active Window will be reset to the Window which was
previously the focused or active Window. If there is no such
Window, then the
KeyboardFocusManager
will clear the global focus owner. - If a focus owner change was rejected, then the focus owner will be
reset to the Component which was previously the focus owner. If
that is not possible, then it will be reset to the next Component
in the focus traversal cycle after the previous focus owner. If
that is also not possible, then the
KeyboardFocusManager
will clear the global focus owner.
VetoableChangeListener
s must be careful to avoid vetoing focus
changes initiated as a result of veto rejection recovery. Failure
to anticipate this situation could lead to an infinite cycle of
vetoed focus changes and recovery attempts.
Z-Order
On some native windowing systems, the Z-order of a Window can affect its focused or active (if applicable) state. On Microsoft Windows, the top-most Window is naturally the focused Window as well. However, on Solaris, many window managers use a point-to-focus model that ignores Z-order in determining the focused Window. When focusing or activating Windows, the AWT adheres to the UI requirements of the native platform. Therefore, the focus behavior of Z-order-related methods such as:
Window.toFront()
Window.toBack()
Window.show()
Window.hide()
Window.setVisible(boolean)
Window.dispose()
Frame.setState(int)
Window.toFront()
:
Microsoft Windows: The Window is moved to front, if possible. While we will always be able to move this Window in front of other Windows in the same VM, Windows 98 and Windows 2000 do not allow an application to bring any of its windows to the front unless one of that application's windows is already in the foreground. In this case, Windows will instead flash the Window's icon in the taskbar. If the Window is moved to the front, it will be made the focused and (if applicable) active Window.
Solaris: The Window is moved to front. In a point-to-focus window manager, the Window will become the focused Window if it is the top-most Window underneath the cursor. In a click-to-focus window manager, the focused Window will remain unchanged.Window.toBack()
:
Microsoft Windows: The Window is moved to back. Note however that Microsoft Windows insists that an owned Window always be in front of all of its recursive owners. Thus, after the completion of this operation, the Window may not be the lowest Java Window in the Z-order. If the Window, or any of its owners, was the focused Window, then the focused Window is reset to the top-most Window in the VM.
Solaris: The Window is moved to back. Like Microsoft Windows, some window managers insist than an owned Window always be in front of all of its recursive owners. Thus, after the completion of this operation, the Window may not be the lowest Java Window in the Z-order. If the Window was the focused Window, it will lose focus in a point-to-focus window manager if it is no longer the top-most Window under the cursor. In a click-to-focus window manager, the focused Window will remain unchanged.Window.show()/Window.setVisible(true)/Frame.setState(NORMAL)
:
Microsoft Windows: The Window is moved to front and becomes the focused Window.
Solaris: The Window is moved to front. In a point-to-focus focus window manager, the Window will be focused if it is now the top-most Window under the cursor. In a click-to-focus window manager, the Window will become the focused Window.Window.hide()/Window.setVisible(false)/Window.dispose()/ Frame.setState(ICONIFIED)
:
Microsoft Windows: If the Window was the focused Window, the focused Window is reset to a window chosen by the OS, or to no window. The window may be in a native application, or a Java application in another VM.
Solaris: If the Window was the focused Window, in a point-to- focus window manager, the top-most Window under the cursor will become the focused Window. In a click-to-focus window manager, the focused Window is reset to a window chosen by the window manager. The window may be in a native application, or a Java application in another VM.
Replacing DefaultKeyboardFocusManager
KeyboardFocusManager
s are pluggable at the browser context
level. Client code can subclass KeyboardFocusManager
or
DefaultKeyboardFocusManager
to modify the way that WindowEvents
related to focus, FocusEvents, and KeyEvents are handled and
dispatched, and to examine and modify the global focus state. A custom
KeyboardFocusManager
can also reject focus changes at a more
fundamental level then a FocusListener or WindowListener ever could.
While giving a developer ultimate control over the focus model,
replacing the entire KeyboardFocusManager
is a difficult process
requiring a thorough understanding of the peer focus layer.
Fortunately, most applications do not need this much control.
Developers are encouraged to use KeyEventDispatchers,
KeyEventPostProcessors, FocusTraversalPolicies,
VetoableChangeListeners, and other concepts discussed in this document
before resorting to a full replacement of the KeyboardFocusManager
.
First note that, because unhindered access to Components in other
contexts represents a security hole, the SecurityManager must grant a
new permission, "replaceKeyboardFocusManager", before client code is
permitted to replace the KeyboardFocusManager
with an arbitrary
subclass instance. Because of the security check, replacing the
KeyboardFocusManager
is not an option for applications that will be
deployed in environments with a SecurityManager, such as applets in a
browser.
Once installed, a KeyboardFocusManager
instance has
access to the global focus state via a set of protected functions.
The KeyboardFocusManager
can only call these functions
if it is installed in the calling thread's context. This ensures
that malicious code cannot circumvent the security check in
KeyboardFocusManager.setCurrentFocusManager
.
A KeyboardFocusManager
should always work with
the global focus state instead of the context focus state.
Failure to do this will lead to incorrect behavior of the
KeyboardFocusManager
.
The primary responsibility of a KeyboardFocusManager
is the dispatch of the following events:
- all
KeyEvent
s - all
FocusEvent
s WindowEvent.WINDOW_GAINED_FOCUS
WindowEvent.WINDOW_LOST_FOCUS
WindowEvent.WINDOW_ACTIVATED
WindowEvent.WINDOW_DEACTIVATED
KeyboardFocusManager
with all of the above events except WINDOW_ACTIVATED
and WINDOW_DEACTIVATED
. The KeyboardFocusManager
must synthesize WINDOW_ACTIVATED
and
WINDOW_DEACTIVATED
events when appropriate and target them
accordingly.
The KeyboardFocusManager
may need to retarget the events
provided by the peer layer to its own notion of the focus owner or
focused Window:
- A KeyEvent must be retargeted to the focus owner. Because the peer layer is unaware of any lightweight Components, KeyEvents will arrive from the peer layer targeted to the focus owner's heavyweight Container, not the focus owner.
- A
FOCUS_LOST
event must be retargeted to the focus owner. Again, this is necessary because the peer layer is unaware of lightweight Components. - A
WINDOW_LOST_FOCUS
event must be retargeted to the focused Window. The implementation of the Window class may cause the native focused Window to differ from the Java focused Window.
A KeyboardFocusManager
must ensure proper event ordering,
and a 1-to-1 correspondence between an event and its opposite event type.
The peer layer does not make any of these guarantees. For example, it is
possible for the peer layer to send a FOCUS_GAINED
event before a WINDOW_GAINED_FOCUS
event.
The KeyboardFocusManager
is responsible for
ensuring that the WINDOW_GAINED_FOCUS
event is dispatched
before the FOCUS_GAINED
event.
Before redispatching an event via KeyboardFocusManager
.
redispatchEvent
, a KeyboardFocusManager
must attempt to update the global focus state. Typically, this
is done using one of the KeyboardFocusManager.setGlobal*
methods; however, an implementation is free to implement its own methods.
After attempting an update, the KeyboardFocusManager
must verify that the global focus state change
was not rejected. A rejection is detected when a call to the
corresponding getGlobal*
method returns a value different than the
value just set. Rejections occur in three standard cases:
- If the
KeyboardFocusManager
attempts to set the global focus owner to a non-focusable Component. - If the
KeyboardFocusManager
attempts to set the global focused Window to a non-focusable Window. - If the change is rejected by an installed
VetoableChangeListener
.
Client-defined implementations of KeyboardFocusManager
can adjust the set of focus transfers which are rejected by overriding the
accessor and mutator methods for the global focus state.
If a request to change the global focus state is rejected, the
KeyboardFocusManager
must discard the event which prompted
the focus change request. The Component to which the event was targeted
must not receive the event.
The KeyboardFocusManager
is also expected to initiate rejection
recovery as outlined in Focus
and VetoableChangeListener.
Finally, a KeyboardFocusManager must handle the following set of special cases:
- When handling a
WINDOW_GAINED_FOCUS
event, theKeyboardFocusManager
must set focus to the appropriate child Component of the Window. If a child Component of the Window previously requested focus, but the focus change was rejected because the platform does not support cross-Window focus change requests, then focus should be set to that child Component. Otherwise, if the Window has never been focused, focus should be set to the Window's initial Component to focus. If the Window was previously focused, focus should be set to the Window's most recent focus owner. - The
KeyboardFocusManager
must ensure that the opposite Component or Window are as accurate as the native windowing platform permits. For example, theKeyboardFocusManager
may need to retarget the opposite Component to a lightweight child of the heavyweight initially specified by the peer layer.
If the peer layer states that the opposite Component or Window isnull
, it is acceptable for theKeyboardFocusManager
to propagate this value.null
indicates that it is highly probably that no other Component or Window was involved in the focus or activation change. Because of platform limitations, this computation may be subject to a heuristic and could be incorrect. Nevertheless, this heuristic will be the best possible guess which the peer layer could make. - Focus and activation changes in which a Component or Window loses focus or activation to itself must be discarded.
- Events posted by the peer layer claiming that the active Window has lost focus to the focused Window must be discarded. The peer implementation of the Window class may generate these spurious events.
Incompatibilities with Previous Releases
Cross-platform changes:
- The default focus traversability for all Components is now
'true'. Previously, some Components (in particular, all
lightweights), had a default focus traversability of 'false'. Note
that despite this change, however, the
DefaultFocusTraversalPolicy
for all AWT Containers will preserve the traversal order of previous releases. - A request to focus a non-focus traversable (i.e., non-focusable) Component will be denied. Previously, such requests were granted.
Window.toFront()
andWindow.toBack()
now perform no operation if the Window is not visible. Previously, the behavior was platform-dependent.- KeyListeners installed on
Component
s will no longer seeKeyEvent
s that map to focus traversal operations, andComponent.handleEvent()
will no longer be invoked for such events. Previously, AWT Components saw these events and had an opportunity to consume them before AWT initiated focus traversal. Code that requires this functionality should instead disable focus traversal keys on itsComponent
s and handle focus traversal itself. Alternately, the code can use anAWTEventListener
orKeyEventDispatcher
to pre-listen to allKeyEvent
s.
Changes specific to Microsoft Windows:
Window.toBack()
changes the focused Window to the top-most Window after the Z-order change.requestFocus()
now allows cross-Window focus change requests in all cases. Previously, requests were granted for heavyweights, but denied for lightweights.


Hi! I'm a telecom-turned-biomedical-turned-software engineer. Born and raised in Madrid, Spain, moved to Copenhagen a few years ago, where my favorite things are cycling through the city, eating tebirkes and the long days of summer. My colleagues and I do pretty cool things developing a computer vision virtual coach for racket sports at Clutch. Previously spent a few years in the health-tech domain, augmenting radiology at Radiobotics. I like to capture life with my camera, take trips on my bike, rock climb and write. I devour podcasts, books, wikipedia, blogs and any source of interesting information. I might be too curious for my own good.


Monaco editor comes with localized translation for most major languages. When that is not
sufficient, you can also provide your own translation. To do so, you need to specify the
localeUrl
option on the widget. It must point to a JavaScript file that
adds writes the localized translation to the window.MonacoEnvironment.Locale
object. See for example the Japanese localization for how this file should look and what
needs to be translated:
Japanese localization file
Below you can see the editor in Hindi (try opening the context menu with a right click).
Note: Looks like Hindi for demonstration purposes, but it is completely non-sensical.
Do not use this in production, but it should illustrate how you can create your own localization.
This sample translation file might also be missing new keys added in later versions of Monaco editor.
${showcase:getFileContent('/sections/monacoEditor/example-customLocalization.xhtml')}
${showcase:getFileContent('/org/primefaces/extensions/showcase/controller/MonacoEditorController.java')}


{% extends 'main/base.html' %} {% block title %} LE - Password Reset {% endblock %} {% load widget_tweaks %} {% block content %}
The password reset link was invalid. Please request another link.


Get Translink bus locations and arrival time updates in real-time! Find all the information you need to get around in Vancouver including live wait times, bus locations, and stop info on a clear, simple, and easy to use interface.
Email: transitappvancouver@gmail.com