![]() |
|
SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here. |
![]() |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||||
|
||||
Java GUIs for Dummies
Anybody know a good guide/tools/tips for building a GUI app in Java? Now that Sage supports pulling in metadata on it's own, I think DVDPro2Sage needs to go down a different path.
Ideally the goal is a gui that would list off your DVDs/Movies, auto associate them as best possible with DVD Profiler entries, allow overrides to associate missed movies, or fix wrongly chosen ones, and finally to generate xxx.properties files for each DVD/Movie that Sage can then import and copy image files. Unfortunatly I'm a bit overwhelmed by where to start on this project, any advice would be most welcome. |
#2
|
|||
|
|||
Do you already have the SDK you want to use? Those typically ship with lots of examples. Why not use swing?
|
#3
|
||||
|
||||
Eclipse would be great, I've taken a bit of a look at the Java Visual Editor project for that. But like I said, kind of overwhelming.
|
#4
|
||||
|
||||
Here's what I used to learn Swing:
http://java.sun.com/docs/books/tutor...ing/index.html You'll also find working examples of Swing UI code (including source) in my Studio Tools package.
__________________
-- Greg |
#5
|
|||
|
|||
I understand you already have an application that you want to build a UI for? Why not use the same editor you used before? You are not building an enterprise class app, do you?
|
#6
|
||||
|
||||
Well that was the idea
![]() But when I was looking at it last night (same tutorial linked by Greg), it appeared much more daunting than today. I sort of figured I was either missing something or that there had to be a better way. Well, guess I was missing something because it makes more sense today. Thanks for the suggestions |
#7
|
|||
|
|||
Swing is great, once you know how. I would say that to get good at swing and not find it scary, it takes a good 6 months of use. The layout managers at first might not do what you are looking for. But once you get used to Swing, it can do anything you want.
Start reading, but mainly start programming and try it out.
__________________
Server: Athlon 64 X2 4200+, 2GB Memory, 2x750GB HDD (DVD Library), 1x500GB (Recordings), 1x500GB(Data), 1x80GB(OS), nVidia 7600GS, PVR-500, HDHomerun |
#8
|
||||
|
||||
When I was a co-op I did a little gui work with TK, and there's a lot of similarities (build gui object, then pack them together).
One thing I will say is that I finally broke down and downloaded Netbeans 5.5 and I must say, it's a better than the Visual Editor for Eclipse, I'm not sure how much exactly. But there's a more important difference, and that is that the tutorials for NetBeans are much better: http://www.netbeans.org/kb/55/quickstart-gui.html I'd previously been frustrated trying to get anywhere just laying out a GUI, but at least now I've got a reasonable start on on that so I'm a little more motivated to continue. Thanks for the advice guys. |
#9
|
||||
|
||||
OK, I'm back, got at least the basics of the GUI layed out so I've been picking away at functionality. First thing I want to do is search a directory (entered) and find all the potential/probable mediafiles underneath that directory.
Listing the contents of a folder seems simple enough, but is there a better way to get a recursive list of all files in a path than making my own recursive list function? Second, it seems the easiest way to separate misc files from "mediafiles" is with a regular expression, something like: ".*VIDEO_TS.*|.*\.mpg|.*\.avi". However I've run into a roadblock on how to filter a list of files (File[]) with a regex. Only way I can come up with is to loop over the File[] and match each entry with the regex and copy the new ones over. But that just seems horribly inelegant. Any thoughts would be appreciated. |
#10
|
||||
|
||||
java.io.File has methods for returning filtered lists, given an object to do the filtering based either on filename (java.io.FilenameFilter) or File (java.io.FileFilter). In the latest version of my Studio Tools you'll find a class called REFilenameFilter that uses regular expressions to implement a FilenameFilter.
It's hard to believe this isn't a standard feature of the Java runtime, but when I Googled it I found everybody rolling their own, so that's what I did too. You can either use the compiled class from my JAR, or just copy and paste the code into your own class: Code:
import java.io.*; import java.util.regex.*; public class REFilenameFilter implements FilenameFilter { private Pattern pattern; /** * Creates a new instance of REFilenameFilter. * @param szPattern The pattern to be matched. */ public REFilenameFilter(String szPattern) { this.pattern = Pattern.compile(szPattern); } /** * Creates a new instance of REFilenameFilter. * @param pattern The pattern to be matched. */ public REFilenameFilter(Pattern pattern) { this.pattern = pattern; } /** * Tests if a specified file should be included in a file list. * * @param dir the directory in which the file was found. * @param name the name of the file. * @return <code>true</code> if and only if the name should be * included in the file list; <code>false</code> otherwise. */ public boolean accept(File dir, String name) { return pattern.matcher(name).matches(); } }
__________________
-- Greg |
#11
|
||||
|
||||
Just tried that, and it works great (thanks), except, doing that ends up filtering the list before I recurse into subdirectories, and thus filters out all the subdirectories before I enter.
|
#12
|
||||
|
||||
Right, I forgot about that part. See DirFileFilter in my Tools package, or just copy the code below. This makes for a two-pass filtering process on each directory, one pass using REFilenameFilter to get the directly contained files, and another pass using DirFileFilter to get the subdirs for recursion.
Code:
import java.io.*; public class DirFileFilter implements FileFilter { /** * Tests whether or not the specified abstract pathname should be * included in a pathname list. * * @param pathname The abstract pathname to be tested * @return <code>true</code> if and only if <code>pathname</code> * should be included */ public boolean accept(File pathname) { return pathname.isDirectory(); } }
__________________
-- Greg |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Java question | matrix35 | General Discussion | 0 | 12-04-2006 04:12 PM |
Testing Sagetv with Java Access bridge | nallan | SageTV Software | 0 | 04-01-2006 07:31 PM |
Sage UI disappears during playback | Keith | SageTV Software | 17 | 03-03-2006 03:31 AM |
Good/Bad Versions of Sun JAVA Related to SageTV | AWS | General Discussion | 6 | 11-10-2005 02:17 PM |
Java problem with AwtToolkit | Ctrl-Z | SageTV Beta Test Software | 0 | 11-01-2005 09:32 AM |