I can fade out a normal JLabel using a Timer, as follows:
public static void main(String[] args) {
JFrame frame = new JFrame();
// final JLabel label = new JLabel("<html><font color=red>Red</font><font color=blue>Blue</font>");
final JLabel label = new JLabel("Hello");
label.setOpaque(true);
label...
I have a custom swing component that is implemented similar to a JTree. It has a ComponentUI that renders an object list using a CellRenderer. The tooltip now correctly shows for each rendered cell, however it doesn't track the mouse as I would like. For instance, if I have boxes layed out like this;
[ box A ] [ box B ] [ box C ]...
We are designing physics app, and we would like to have it written in Java, and also we want to use root (root is writen in C++). Root has some nice graphical features -- it is able to draw very nice 3D charts, and I'm thinking whether it's possible to embedd those charts in Java app.
Is there any way to make C++ code draw on for examp...
JPanel pMeasure = new JPanel();
....
JLabel economy = new JLabel("Economy");
JLabel regularity = new JLabel("Regularity");
pMeasure.add(economy);
pMeasure.add(regularity);
...
When I run the code above I get this output:
Economy Regularity
How can I get this output, where each JLabel starts on a new line? Thanks
Economy
Regular...
I overrode DefaultKeyboardFocusManager to provide some special behavior for the Alt key. However, after setting this, I notice that hitting Tab on some of my text fields does not work.
I also experimented with even calling the following on the AWT, but this still exhibited the broken Tab behavior:
KeyboardFocusManager.setCurrentKey...
I wud like know the way to set the text that is typed in a Jtextfield to the table.Cud anyone help me in it.
...
I need to make an image map using Swing that displays a background image, and then when the mouse hovers over (or clicks) specific hotspots, I need to pop up a 'zoomed-in' image and have it display.
I was thinking of extending JPanel to include an image reference and have that drawn thru the paintComponent(g) method. This part I have d...
Is there a way to sort a JTable programmatically?
I have my JTable's sort working (with setRowSorter) so that when the user presses any of the columns, the table gets sorted.
I know, SWingX JXTable would probably work, but I'd rather not go through the hassle because everything else is pretty much working now and I don't know how wel...
Why does Swing JComponent class implement the interface Serializable? The way I've implemented my views, they are stateless, all the state data is stored in a Presentation Model. So I don't need to serialize my views. I've used a @SuppressWarnings("serial") annotation to remove the warnings. Are there better ways to remove them?
...
Hi,
I have a jlist with a lot of items in it, of which one is selected. I would like to scroll to the selected item in this jlist, so the user can quickly see which item is selected.
How can I do this?
thanks!
String[] data = {"one", "two", "three", "four", /* AND A LOT MORE */};
JList dataList = new JList(data);
JScrollPane scrollPa...
I have built my own component extending JPanel. I've added a few methods like calculateWhatever()...
Should I call those methods with invokeLater() as well?
Substance L&F is not complaining about it but I'm having rare random painting problems and I'm wondering If they're happening because of those calculations inside the extended swing...
what is the best and easiest way to link a JSlider and a JTextField so that if one changes, the other gets updated too, but there is no recursive loop?
thanks!
...
I'm having a problem adding a JPanel on top of an Image. This is what I'm trying to do:
Image bgImage = loadImage(filename);
JPanel jp = new JPanel();
jp.setBounds(100,100,100,100);
jp.setOpaque(true);
jp.setBackgroudColor(Color.red);
bgImage.add(jp);
After doing this, I only see the bgImage. I tried everything but I still can't sho...
I'm trying to create a simple WYSIWYG editor that will allow users to select text and bold/underline/italicise it. Currently the user can select text, right-click it and select bold from a popup menu, which ends up applying the bold style to the selected text like so:
this.getStyledDocument().setCharacterAttributes(this.getSelectionStar...
I am a student at ISU. I was working on a homework assignment where I wanted to get text that was selected (highlighted) in a TextArea to appear in a JOptionPane dialog. I tried many of the methods for JOptionPane, but I could not get any of them to place the text the user selected in the input field of the dialog.
I guess that I could ...
The Problem
I create a dialog box in swing (JRE 6 update 10, Ubuntu linux). When the user has finished using the dialog box it is hidden. When the users click on a button in another frame, a label on the box is changed according to the button, and then the box is shown again.
The problem I'm having is that the box is shown before the l...
I'm trying to display a local image in package1/package2/myImage.gif in a JTextPane. I first tried to load the resource into a BufferedImage:
BufferedImage image = ImageIO.read(ClassLoader.getSystemResourceAsStream(
"package1/package2/myImage.gif"));
But then I didn't know how to use that in the setText method, so I tried just poi...
I am attempting to embedd webrenderer (a Swing based web browser) within a JDialog that has a default button defined. Hitting return in any of the form textareas within the loaded HTML is causing the JDialog default button to fire and close the dialog.
Due to the nature of the application I can't simply not use a default button on the d...
Background:
To add some basic HTML/rich text editing to our application that is compatible with our web interface I am attempting to embedded CKEditor within the swing based webrenderer browser. Webrenderer acts like a swing component and then loads up my simple HTML page containing an invocation to start CKEditor.
This works fine and ...
I don't understand the rationale of this code, taken from javax.swing.event.EventListenerList docs:
protected void fireFooXXX() {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
// those that are interested in this event
f...