swing

Swing: Passing a value back to the UI from a scheduled thread

I have a system tray UI in Java that requires a schedule database poll. What is the best method for spawning a new thread and notifying the UI? I'm new to Swing and it's threading model. ...

Custom slider UI Swing

I'm trying to create a custom extension of BasicSliderUI. I'm just trying to make the thumb a circle (note I'm in the Windows L&F). I've created a very simple implementation that just calls g.drawOval, but whenever I drag it, it leaves a "trail" behind. Any ideas why this is? thanks, Jeff ...

Where are these icons as a java resource?

I've got a custom tree cell renderer that I'm using to render custom icons a JTree, and I really like the warning icon and the error icon that JOptionPane displays for both warning messages and error messages respectively. Obviously I can use the following code to get the icons for my own use, but this is way heavy handed and requires me...

How do make an infinite jscrollpane?

I've implemented drag scroll before, but what's the best way to go about creating an infinite scroll pane? Of course there won't be any scrollbars and I will implement drag scroll. What I am trying to do is implement dynamic loading on an infinite surface. EDIT Of course it wouldn't actually be infinite. I am asking how to fake it. ...

displaying links in java's JTextPane without html

I need to take text from a source as plain text and display it in a JTextPane or JEditorPane. The source text is not HTML but will contain URLs between square brackets which need to be displayed and function as hyperlinks. I've considered setting the pane's content type to text/html and surounding the url in html tags but that ends up i...

[JavaFX] AWT bridge's "Hello World"

Hi everyone, I've heard about the JavaFX->AWT bridge (or hack) for a moment now. But examples I find are quite fuzzy or blur to me. So, if anyone knows an "Hello World" example for this bridge I'd be really interested ! (Just to be clear I don't need a way to embed a Swing component in a JFX animation or to launch a JFX from a Swing b...

AWTUtilities Transparent JFrame

Using this article from sun. I am trying to create a transparent window. I have one image inside a label on the frame. I want the image to be visible but the frame invisible. When i use try { Class awtUtilitiesClass = Class.forName("com.sun.awt.AWTUtilities"); Method mSetWindowOpacity = awtUtilitiesClass.getMethod("setWindowO...

Specify antialias property in the command line

I remember, not too long ago, somebody post a link on how to specify the global rendering hints to use anti-alias in java. Unfortunately I can't find the question. How can I specify the rendering hint to use anti-alias in swing? ...

[swing] hyperlinks in JEditorPane in a JTable

I swear... i hope this is the last question I have to ask like this, but I'm about to go crazy. I've got a JTable using a custom TableCellRenderer which uses a JEditorPane to display html in the individual cells of the JTable. How do I process clicking on the links displayed in the JEditorPane? I know about HyperlinkListener but no mou...

Swing application -> Drag & drop to the desktop / folder

When Finder of Mac, Explorer of Windows did drag & drop of a specific item in the Swing application to a desktop and a folder, How to get the former path which I dropped? I am happy teach me a necessary class and method. ...

Can I get file path from Swing to explorer

I read FileTreeDragSource Can I get file path from Swing to explorer. Not explorer -> Swing!! Swing -> explorer I wanna get path with explorer ...

Using Java's Graphics or Graphics2D classes, how do I paint a String?

I have a String and I want to paint it onto an image. I am able to paint points and draw lines, however, even after reading the Text part of the 2D Graphics tutorial, I can't figure out how I can take a String and paint it onto my drawing. Unless I'm looking at the wrong tutorial (but it's the one I get whenever I search for anything ab...

Error running Jar File

Hi, I have created a project in java project using NetBeans IDE. I have few forms in it. The netBeans created a Jar file by its own. when i try to run that Jar file its give an error "Failed to load Main-Class manifest attribute from". I Have set my Starting form in application and when i run from netbeans its running correctly but when...

Action commands vs Action classes?!

A shout out to the Swing gurus out there!! I've been doing Swing programming for several years but have always been unclear on this. As you know Swing/AWT gives you several ways to execute a particular action when a button is clicked. I've seen it done several different ways in the applications I've worked on. The project I'm currentl...

Java Code Design Question and Example

Hey everyone, I've been writing code in Java for awhile now, however I feel as though I lack in code "design" - that is, creating packages and separating classes and such. I'm just not sure when to create what. So, I'm practicing :) I am setting out to write a Calculator (with a Swing GUI), and I want to create a really good design for...

example/tutorial for using TreeModel+AbstractTreeModel?

I have a database containing a hierarchy that I want to display within a JTree. Is there a good example/tutorial for TreeModel and/or AbstractTreeModel that explains how to implement a custom treemodel? I'm going through a lot of head-scratching and can't seem to find some code out there which is a good starting point. edit: I did find...

Handling Swing focus events with Jython

Jython 2.5 I'm trying to bind a method to the focusGained event of a JText control, but all the examples that I found are Java samples, not Jython. Here's the code, I want to run a custom method when each text control gains focus (to select all the control's text, for instance) from javax.swing import * from java.awt import * class Te...

Remap keyboard navigation with Jython / Swing

Hi, I'm trying to remap several navigation keys: ENTER: to work like standard TAB behavior (focus to next control) SHIFT+ENTER: to work like SHIFT+TAB behavior (focus to previous control) UP / DOWN arrows: previous /next control etc I tried with a couple of options but without luck: from javax.swing import * from java.awt import * ...

Resizing JPanel to prepare for printing without removing it from its original position

In my program I frequently need to print various JComponents (generally JPanels) and I like them to be full-page. The way I do it now is by using the following code: g2d.scale(pf.getImageableWidth()/componentToPrint.getWidth(), pf.getImageableHeight()/componentToPrint.getHeight()); but this often stretches or otherwise deforms whatev...

Not loading images from the web in a html document?

Hi, is there an easy way to dell htmldocument (inside a JTextPane) to not load images from the web? i cant think of anything smarter then to simply remove the tags or similar. and cant seem to find any "build in" functionality for it. ...