fancy tooltips in Swing - swing

I have a JTable that I would like to display a fancy tooltip (basically a JTextArea) for particular cells in a column. I am using a custom cell renderer, so it would be easy if I could figure out how to popup a window when I hover over the cell renderer's component.
Are there any examples of how to do this?

You can use HTML in tooltips, if you use the <html> and </html> tags around the content.
Use HTML to format the tooltip. Using colored (<font>) and multi-line (<br>) tooltips is now easy.
Creating and overwriting the default JToolTip is a bit harder. Every component has a JToolTip instance and you can retrieve this one with JComponent.createToolTip(). To create a custom tooltip, extend the cell renderer and override it's createToolTip to implement your custom functionality (return a custom extended version of JToolTip).

I'm not sure I totally am clear on what sort of customizations specifically you're hoping to do, so I'll be general here.
There is a class, UIManager, that controls the look and feel of components, including the swing ToolTip class. The simple way to make an easy change is to call a method in UIManager to set properties for the tooltips. Doing this you could do things like use BorderFactory to add a decorative border, or change the background color, etc.
Here are some examples of changing some of these properties:
UIManager.put("ToolTip.background", new ColorUIResource(255, 247, 200)); // The color is #fff7c8.
Border border = BorderFactory.createLineBorder(new Color(76,79,83)); // The color is #4c4f53.
UIManager.put("ToolTip.border", border);
ToolTipManager.sharedInstance().setDismissDelay(15000);// 15 seconds
If you want to change a whole bunch of things about their look and feel, it is better to extend your current look and feel with a class implementing custom tooltip look and feel. A full example of this can be found in this blog post by a former Sun developer.
You might also have a look at this Stack Overflow question on how to set the insets on a tooltip.

Related

Display an element only up to a certain depth until expanded

This seems dissimilar to the accordion functionality provided by bootstrap.
To give an example, let's take the "how to format" info starting me in the face right now. I'd want it so that it only displays up to X pixels deep, and then stops until expanded. So it might look like:
and then, once expanded,
I happen to be using bootstrap. Is there a bootstrap native or other HTML solution to create this kind of experience?
Assume that the thing that I only want to show of is a single element, such as an image, rather than a series of text. This means a solution like min-height:50px and overflow:hidden won't work, as it will simply hide the entire image rather than part of it.
We can use jQuery .height() to accomplish knowing the rendered height of an element then making conditional modifications.
Documentation and examples for jQuery .height().
A combination of height and overflow in combination with the toggling of a class should work here.
http://jsfiddle.net/fm56je84/1/
The click of the arrow is bound to the following function:
function expandCollapse() {
$("#container").toggleClass("expanded");
$(".glyphicon").toggleClass("glyphicon-arrow-down"); // Flip Arrow
}

Is there a possibility to increase font size of the spark label truncation tip in Flex 4?

I use Spark Label (Flex 4.6 SDK) in my project to show some text on a form and in case when the text does not fit in one line a truncation tip is shown (using maxDisplayedLines="1" and showTruncationTip="true" properties). But the font size in the tip is very small and I want to increase it but actually I have no idea how to do this.
OK so this is doable but not so easy to see how at first.
showTruncationTip tells the label to create a toolTip if isTruncated is true when you mouse over it. So with this knowledge, we can listen for the events that get fired regarding the tooltip being created and do some replacing or stylizing of the toolTip.
private var myTip:IToolTip;
// somewhere in your code
label.addEventListener(ToolTipEvent.TOOL_TIP_SHOWN, createCustomTip);
private function createCustomTip(event:ToolTipEvent):void {
myTip = event.toolTip;
// do stuff to the existing toolTip or replace it with a custom one
}
There is full docs on how to create and replace custom tool tips here Creating Custom Tool Tips
There's a much simpler answer. See this link
http://blog.flexexamples.com/2008/05/22/changing-the-background-color-of-an-error-tip-in-flex/
and observe how they use <mx:Style> tags to modify the default CSS properties for .errorTip.

Flex 4 -- Adding blur below pane

I'm looking to create a component like an Alert but with a bunch of components inside the pane. How can I create the blur effect below a pane?
Have a look at the AS docs here, there's a good example that will do what you want. Any DisplayObject can have filters applied to it
Alternatively, you can use something like TweenMax's dropShadowFilter to do it quickly and easily

Google Maps API V3 custom controls position

I've read docs about positioning controls on the map(TOP, TOP_LEFT, etc), but Is there any way to make custom position? For example: left: 20px; top: 200px;
I just want to have in top_left corner my logo and zoom control right under logo.
And how to remove pan control in navigation controls? I want to have only zoom control in default style(not minimized).
Thank you.
Although the question is rather old, with almost 3k views it still seems to draw interest - So, here is my solution:
Wrap the controls!
First we have to find the container-element, where Google puts the control. This depends on which controls we want to use on the map. Google doesn't use unique ids for those containers. But all the controls have the class "gmnoprint" in common. So just counting the elements with "gmnoprint" does the job. Say we only want to use the "ZoomControlStyle.SMALL"-control. It's always the last element with "gmnoprint".
Now, we can simply style the element - Right? No. As soon as you zoom or resize the map, Google resets the styling of the controls. Bad luck, but: We can wrap a container around the controls and style this container!
Using jQuery, this is a really simple task:
$('div.gmnoprint').last().parent().wrap('<div id="newPos" />');
We only have to make sure, the control is fully loaded by the time we try to wrap it. It's not totally bulletproof I guess, but using the MapsEventListener "tilesloaded" does a pretty good job:
google.maps.event.addDomListener(map, 'tilesloaded', function(){
// We only want to wrap once!
if($('#newPos').length==0){
$('div.gmnoprint').last().parent().wrap('<div id="newPos" />');
}
});
Check out http://jsfiddle.net/jfPZH/ (not working, see Update Feb 2016)
Of course if you don't like the initial flicker and want a more reliable version you can do all kinds of improvements like fadeIn etc: http://jsfiddle.net/vVLWg/ (not working, see Update Feb 2016)
So, I hope some of you will find this useful - Have fun!
Update: With this method you can position any other control (e.g. the controls of the Drawing Library) as well. You just have to make sure to select the right container! This is a modified example: http://jsfiddle.net/jP65p/1/ (somehow still working)
Update: As of Feb 2016 Google seems to have changed the positioning of the map controls. This does not break my solution. It just needs some adjustment. So here are the updated fiddles:
Simple: http://jsfiddle.net/hbnrqqoz/
Fancy: http://jsfiddle.net/2Luk68w5/
It is extremely simple, just add this to your css file!
div.gmnoprint { padding-top: 50px; }
It will move the control 50px down with no hacks or anything!
You can create a custom control for your logo, and add it to the map to position it. You can't set the location of the control directly beyond the constants, but you can offset the location using padding on your control div.
http://code.google.com/apis/maps/documentation/javascript/controls.html
set
panControl : false,
in the ZoomControlsOptions which you set

How to create a custom GControl

I'm trying to create a gray "frame" (see pic below) around a google map, to try to convey the concept of an area of focus, as oppose to a point (which is usually represented with a marker). Note that this is not an overlay, that is, the gray "frame" should not move when you drag the map.
Edited: image link added
It appears that only option is to "subclass" GControl to create a custom control. I have 3 questions
1) First of all, is GControl subclassing the best course of action?
2) In my example, the canvas (div) where map renders can change its size (i.e is not fixed width). Do I have to delete and add custom control when canvas changes size? See docs http://code.google.com/apis/maps/documentation/controls.html#Custom_Controls on how to create a custom map control.
3) Now, how to do it. Naively, I thought I could create a table with 3 columns and 3 rows, and set display: none for the cell in the middle. But that doesn't work. I've also experimented with clipping, that didn't work either. My css skills are quite lacking, so there must be way to do this more elegantly than adding four rectangular gray divs. If I wanted to add an inner border, with divs, I would need to paint 8 then. In a nutshell, what's the best way to create a "hollow" rectangle?
Thanks
P.S. This is my first entry to StackOverflow. Just discovered it. It's impressive how well SO is put together.