X

Recent Posts

NetBeans

A quick JFileChooser demo

Today, I noticed that many new NetBeans users have a difficulty of implementing a file chooser functionality. Usually, you just write all the code by hand, but there is also a way how to achieve several goals using the designer in the NetBeans IDE. This tutorial should demonstrate how to leverage the NetBeans GUI Builder for implementing a custom file chooser. As a setup, we will also create a small Java desktop application. You can download the resulting project with file chooser. Prerequisites Before you start, make sure you have NetBeans IDE 6.8 and JDK 1.6. Step-by-step guide As a first thing, we create a new Java Desktop Application: Invoke File>New Project, select Java category and choose Java Desktop Application project type Click Next, fill in some application name ("JFileChooserDemo") and make sure Basic Application is selected Click Finish At this moment, a new Java Desktop application with three important files is created: JFileChooserDemoApp JFileChooserDemoView JFileChooserDemoAboutBox  Just as on this picture:  Double-click the JFileChooserDemoView to make sure it is opened in the designer. Open the component palette (Ctrl+Shift+8). Drag a new Menu Item (JMenuItem, from Swing Menus category) in the menu bar that was created by default. Right-click this item in the designer and invoke Change Variable Name - rename the item to openFileMenuItem. Then, press Space (to start editing the text of the component that is selected in the designer) and change the text to "Open text file". To set an action to this menu item, right click it and invoke Events>Action>Action Performed. A new method is generated, it is called for example openFileMenuItemActionPerformed - copy the name to the clipboard for a while. Drag a Tool Bar (from Swing Containers category) to the designer and add one button (JButton, from Swing Controls) to the tool bar. Change the button's text to "Open" by selecting it and pressing Space. Rename both components' variable names again using the context menu, so that you don't have to stick with the ugly "jButton1"-like names. Currently, you have an event handler for the "Open" menu item. To set the same event handler to the button, single-click the button and select Events tab in the Properties view. Paste the name of the method in the "actionPerformed" event and press Enter to confirm. At this moment, the method "openFileMenuItemActionPerformed" (or similar name) is set as an event handler for both button in the toolbar and menu item. Finally, add a JTextArea (Swing Controls) in the form (and rename the variable). The form should look like this: So, now we have finished the basics. Let's add a JFileChooser to the form. Open the inspector window if it is not opened (Window>Navigating>Inspector) and right-click Form JFileChooserDemoView node. Invoke "Add From Palette>Swing Windows>File Chooser". A JFileChooser is added in the inspector. Right-click the node and rename the variable to "fileChooser". Note: You can also drag&drop the File Chooser from the palette to the white area of the GUI Builder - it will have the same result. It is a bit harder, though, because the default preview of the JFileChooser is rather big and you might end up with the window being inserted inside some of the panels, which is not what you want. Note: If you don't create a Java Desktop Application or if you just have a JFrame form, you can right-click the "Other components" node instead of the "Form JFileChooserDemoView" node - it will add the JFileChooser component to the JFrame (to the JFrame class) but not in its visual part... Now, you can click the JFileChooser in the inspector and edit some of its properties in the Properties view. For example, you can edit the title of the dialog by editing the dialogTitle property (change it to "This is open dialog"). To display the file chooser from your application, just paste this code to the openFileMenuItemActionPerformed method and press Ctrl+Shift+I to fix the imports (otherwise, there will be some errors in your code): int returnVal = fileChooser.showOpenDialog(this.getFrame());if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile();// ... code that loads the contents of the file in the text area} else {// ...} Let's do some minor work to add some custom filter. Note: Users who used to work with MS Visual Studio and .NET might be familiar with a quick but ugly way of making custom filters - typing extensions and descriptions of the filter with a vertical separator in a special property, like this: openFileDialog.Filter = "Bitmap images|\*.bmp|All files|\*.\*"; see - http://msdn.microsoft.com/en-us/magazine/cc300434.aspx#S1. Java does it in a more difficult but cleaner way... Select the File Chooser in the Inspector window. Click the asterisk ("...") button by the File Filter property in the properties view. Select Custom code from the combobox in the dialog that shows up and type "new MyCustomFilter()" in the text field and confirm the dialog - yes, the code will not be compilable now, we will fix it. All we need to do is to write an inner (or outer, if you like) class that extends the FileFilter class. Just copy and paste following code in the source of your class to create an inner class. class MyCustomFilter extends javax.swing.filechooser.FileFilter { @Overridepublic boolean accept(File file) { // Allow just directories and files with ".txt" extension...return file.isDirectory() || file.getAbsolutePath().endsWith(".txt");} @Overridepublic String getDescription() { // This description will be displayed in the dialog, // hard-coded = ugly, should be done via I18N return "Text documents (\*.txt)";}} OK, so that should be it. If there is still something unclear, do not hesitate to ask in the discussion below. If you start the sample project, the result should look something like this: If you want to have more switchable file filters, see addChoosableFileFilter method. You can indeed implement all the stuff yourself, following the tutorial on How to use File Choosers.

Today, I noticed that many new NetBeans users have a difficulty of implementing a file chooser functionality. Usually, you just write all the code by hand, but there is also a way how to...

NetBeans

Use the new Netbeans.org site the right way - from the IDE

A story of a young boy's dream... WhenI was a young boy, I wanted to be a NetBeans developer. Since the ageof five, I dreamt of writing my first line of the NetBeans code. (Well,when I was five, there was no NetBeans nor Java but since I am tryingto advertise a bit, the story doesn't really have to make sense, right?) Ihad to wait until I was 23 before the guys from the NetBeans teampicked me for a tester, and half a year more before they allowed me totouch the code ("Hey, you, could you fix that typo in the messagethere? I am having a lunch and I don't want to touch my keyboard...").Now, I am trying to learn how to write a code without hearing smartboys' (translate as "Jesse Glick's") remarks on what strange thing my code does - I am trying to become a good occasional NetBeans programmer... Duringthe wonderful time I spent in the NetBeans team so far, I learnedalmost all the stuff around the NetBeans community and majority of theNetBeans related processes. I learned how to submit an issue with adescription that actually makes sense (hopefully, no developer readsthis...) and how to work with the IDE's sources. I slowly gotaccustomed to the ancient idea of mailing lists and I happily observedhow we introduced the forums integrated with them. I almost started tounderstand why we have a wiki that looks completely different from thewebsite. I became a young but already a bit gray NetBeans wolf... Well- now, these days of beautiful complexity are gone... Beautiful simplicity of Kenai Sinceour website is now Kenai-smart (after the months of nervous devil'sengineering, we managed to do that), anyone who is interested in theparticipation in NetBeans community can achieve in about one hour(maybe I should add "depending on the connection speed") what Iachieved in more than a year and a half. Let me share with you how tosubmit bugs for the NetBeans IDE and how to get the NetBeans IDEsources right from the NetBeans IDE. But first - to give you better insight - everything starts here: https://netbeans.org/api TheNetBeans.org website is actually a "smart website", defining thedescription of the components/projects of the NetBeans IDE using the Kenai API.One could say that this approach blurs the border between a project andits website as those two things are now tightly connected. Sincethe NetBeans IDE includes the support for the Kenai API, it is notsurprising you can work with the NetBeans IDE components using theNetBeans IDE itself. One of the big positives is that the NetBeans team"eats its own dog food" - we work on the infrastructure that we try tosupport. Getting started - Connect with the NetBeans website So - ready to find out about the new NetBeans infrastructure? Here is what you need to get started: Download the development version of the NetBeans IDE (this thing is implement just recently - you can try it while it's hot) Start the NetBeans IDE and open the Services view (Ctrl+5) - you should see a new node Kenai Instances Right-click the Kenai Instances node and choose Add Instance Fill in the name ("NetBeans.org"), server ("https://netbeans.org" - mind it's HTTPS) and confirm the dialog Right-click the new instance and invoke Set As Default - the NetBeans.org node get's bold Now, you should see a new Kenai instance pointing to the NetBeans.orgwebsite and you can start exploring the Kenai projects located on thisserver. Understand the structure, get started... ... with sources BeforeI tell you how to work with the sources and so on, I will describe howthe NetBeans sources physically look. This should help you tounderstand some choices we made while designing Kenai projects onNetBeans.org website.The NetBeans sources consist of manymodules. Each module provides a part of the NetBeans IDE functionality.However, the modules are not very useful on their own - they make senseonly with the rest of the modules (or - at least - with a relativelylarge subset of the modules, such as openide modules, API supportmodules, project or editor infrastructure modules, etc.). Therefore,there is not any direct mapping of the NetBeans functionalities (forexample Ruby or Java support) to unique set of the NetBeans modules(both Java and Ruby support use editor and projects infrastructuremodules, for example, and doesn't work without those).Accordingly, if you are not a NetBeans expert (which I am still not) and if you need to get the NetBeans sources for playing with them a bit, you should get it all or nothing.Also - if you think you are a NetBeans expert and you want to get justpartial sources, this will disappoint you -  as we use the Mercurial for versioning, you have no other choice: you can clone the whole repository or nothing...Becauseof above mentioned points, it makes no sense to have sources under allKenai projects on NetBeans.org (cloning the sources for project Javawould clone the same repository as cloning the sources for projectRuby). Instead, all NetBeans repositories are located under a single project, called simply "IDE".Conclusion: If you need to get the NetBeans sources, you will find them in the IDE project. No matter which specific repository you need...So - let's do it: Make sure the Mercurial is installed on your machine - if not, install it and restart the NetBeans IDE (... sorry for the inconvenience...) Open the Kenai dashboard (Ctrl+8) Clickthe button for opening a new Kenai project and wait until featuredprojects load. You should see the IDE project right at the top - openit... A new project should show up in the Kenai dashboard (Ctrl+8) - expand it's Sources node (it can take a while) Find main-golden repository (this is the one we use for the daily builds) and click "get" link Specify a location for the clone and click Get From Kenai button - a clone should start, you can see the progress in the lower right corner or in the Output view(Ctrl+4). Clone should take some time depending on the connection speed- do not be impatient. Keep on reading this post while waiting! :) Set up your environment and build the NetBeans sources (you need to use Java5 and give some more memory to ant and javac). The most important step: develop the code + enter issues with your patches attached (you won't be able to push code changes directly into the repository). This is how you became a NetBeans community developer... ... with issues Incontrast to how we have dealt with the sources, it makes a perfectsense to submit an issue for example for the Java support, as issuesare specific for given functionality. Therefore, every Kenai project onNB.org has an issue tracker associated with it. The "IDE" project alsohas an issue tracker - use this one if you are not sure where to reportan issue.Try to open some other project, for example a project for the Kenai infrastructure support: Invoke the Open Kenai Project dialog again Search for "ConnectedDeveloper" (write it as a one word, note the list of all projects can be found on http://netbeans.org/projects). Expand the Issuesnode - it takes a bit (30s) for the very first time (then it's fast).You should see a link for finding an issue or for submitting a newreport. Also, if you are a registered member of the NetBeans.org community already, you can login and see the issues you submitted (in the case, you will see a link "My Issues" too). Trysearching for the issues using the "Fins issues" link, submittingissues will work for you only if you are registered on NetBeans.orgwebsite (for obvious reasons...). OK- this was a pretty brief startup for the NetBeans community tester...Once you register on NetBeans, you can do my job from the comfort ofyour home;-)! ... with other features, just to keep you posted You can review the details of any project by clicking the "Details" link in the Kenai dashboard -  this opens a view with Kenai project details.Try it for the "ConnectedDeveloper" project you just opened or for someother nice project - for example the project for Japanese speakingcommunity members called "ja" :) - this one even has a project pictureand it's own wiki...The project details view provides a niceand comprehensive access to all Kenai project features, even to thosethat cannot be directly accessed via the NetBeans IDE, such as thewikis, mailing lists or downloads. This view should help you to findthe good ways to keep in touch with what is going on in the particularproject. But please note that project mailing lists are usually moreabout receiving the information (notification about the project issuesor commits, for example) and you should not post to them directly. Ifyou want to complain on how horrible the NetBeans IDE is (in any areas)or ask a question related to NetBeans, please use the public mailing lists that are all available under project WWW. List "NBUsers" is probably the right one for you (mailing lists are still integrated with forums on http://forums.netbeans.org/)... By commenting on the mailing lists, you will give us a valuable feedback and you will become a community commentator;)... Conclusion Whilethe Kenai support in the NetBeans IDE works pretty well in ouropinions, we are still looking for the community feedback and for some new ideas on how to improve it.Generally speaking, you can improve the way the NetBeans+Kenai marriageworks in 2 ways: by participating in the NetBeans community or byparticipating in the Kenai community. I think it is worth the try oneof those, even if it wasn't your dream when you were five... :)

A story of a young boy's dream... When I was a young boy, I wanted to be a NetBeans developer. Since the age of five, I dreamt of writing my first line of the NetBeans code. (Well,when I was five,...

NetBeans

Another step further - Kenai services on NetBeans projects

While the Kenai integration in the NetBeans IDE works pretty well overall, we are not resting on one's laurels. There are still many things that have to be done to make this marriage perfect. After we released NetBeans 6.7, a wild discussion on this matter started: "The UI is not cool enough!", "I don't like it done this way!", "It is not working together closely enough!", etc.. But this would lead us nowhere. As we are rational people at Sun, we had several very productive meetings (with several very unproductive moments) and we collected the set of use-cases for the NetBeans/Kenai integration. Subsequently, we have requested some new server API's, we started to slightly rethink the concept of the Kenai dashboard to make it more comprehensive and - the most important thing - we started to integrate Kenai services in the NetBeans stuff (and vice versa, indeed). An improvement from the last category is what I am going to show you today. If you have a NetBeans project opened in your NB IDE, the IDE knows the remote repository information for the project. If the project is versioned and its repository is a Kenai repository, the NetBeans project has to be a part of some Kenai project. This way, we are able to determine what Kenai project the NetBeans project belongs to. When a project is already on Kenai, there is no point of having the "Share on Kenai" action on it - instead, we replaced this action with a "Kenai" submenu. Currently, you can use it to navigate to the associated Kenai project in the Kenai dashboard or to file/find a bug on the Kenai project: Note: For implementation reasons, the project must be opened in the Kenai dashboard before you can file/find a bug for it (as we need to know an information that is stored on the server side - the presence of an issue tracker). If the corresponding Kenai project is not opened in the Kenai dashboard yet, only the "Open Corresponding Kenai Project..." action is available in the Kenai menu at this point... We are also thinking about how to integrate versioning in this popup (maybe some SCM independent "Synchronise" action?) and if we should place some other Kenai services to this menu... What do you think?

While the Kenai integration in the NetBeans IDE works pretty well overall, we are not resting on one's laurels. There are still many things that have to be done to make this marriage perfect. After we...

NetBeans

Issue recognition in the chat window - Freshly baked!

Today, I am faster than the last time I was writing about the chat feature as I am writing about it before you can try it yourself. The changes I have made in the Kenai chat window are not in the trunk builds yet, they are pushed just a few minutes ago... But since it is Friday and I might not survive tomorrow (it's a "paintball war" day), I am going to share the new feature with you right now... Since every chatroom is associated with a Kenai project and most of the Kenai projects have an issue tracker, it is now possible to navigate to an issue from the chat window and to send an issue reference. See the screenshot: Now just a few words about how it works (loosely copied from my closing text to issue 169037): Kenai project related to the chatroom must have an issue tracker for the links to be recognized Bugzilla issues are opened in the IDE Jira issues are opened in the web browser patterns "issue 123", "issue #123", "bug 123" and "bug #123" are recognized for Jira, the form "bug JIRA_ISSUE-123" is equivalent with "bug 123" (the "JIRA_ISSUE" string representing a Jira category does not have to be included - chatroom is associated with the Kenai project) for Bugzilla, if you specify an issue that is not in your project, it gets opened (problem with the fact that theissue numbering is global for BZ). You can see that the issue is not in your project in the issue details. So that's about it for today - any comments and suggestions are welcome!

Today, I am faster than the last time I was writing about the chat feature as I am writing about it before you can try it yourself. The changes I have made in the Kenai chat window are not in the...

NetBeans

Student projects wanted!

The university/student projects have their own specifics. One of the most visible one is that the innovation and enthusiasm is often combined with rather weak software engineering and poor execution. I know it from my own experience. When I and my team of three students started our software project at the MatFyz (Charles University in Prague), we had to deal with a lot of issues on our own. For example, we were looking for the right development tools and for the infrastructure for our project... As we didn't have much practical experience with this, we ended up with our own instance of wiki (MediaWiKi on a free hosting), we used our own issue tracker (really - I am serious, we wrote our own PHP application just for the purpose - yeah, we were... young...), we placed our code in the Mercurial repository located on our faculty server and we used Google Groups as an alternative to the mailing lists. If we had to make the same decisions these days, all our questions would be answered by words: "Use NetBeans and Kenai..." Want to know why? Short introduction What does Kenai.com give you? Generally speaking, Kenai.com is an on-line place for your projects. More specifically, if you decide to start your project on Kenai, you get an instance(s) of: a version control system (SVN, Hg, git) an issue tracking system (Bugzilla, Jira) mailing lists and forums chatroom (Jabber) wiki other features, in my opinion less relevant for the student projects What does the NetBeans IDE give you (except for a great IDE)? A tight integration with Kenai.com... Kenai.com is not just a "web page", it is a set of web-service APIs and the NetBeans IDE is a client to the web service. What does it mean practically? That you can create a project in the NetBeans IDE and share it on Kenai quickly. It also means that your friends can easily join the project and they can get an access to all the features the project has (repository, chatroom, issues). You can chat from the IDE as well as submit or read issues from the IDE... A sample of how it works for you/students Lets show how simple it can be on a model example... Assume you have a team of 3 students: Peter, Philip and Kate. Peter (the smartest one:)...) decides that the team should use the Netbeans IDE as a development tool and Kenai.com for the infrastructure. We can assume that the project will be a JavaSE application, to keep it simple (it is not a precondition, it can be PHP/C++/... as well). Peter is already registered on Kenai.com (he is the one who suggested to use it, after all) and so he can start the development and share the application. Meanwhile, the other members of the team proceed by the free online registration on Kenai. Step 1 - create a project Peter starts his NetBeans IDE and he creates an empty JavaSE application. When the application is created, he right-clicks the project's node in the Projects view and invokes "Share on Kenai" action. He fills in some basic data (project's name, description, ...) and he chooses a license (project will be on-line, visible to anyone - this step is needed). Then he clicks "Finish" button of the wizard and he does not need to care any more - the project is created with a subversion repository, sources (empty, at the moment) are checked in, bugzilla issuetracker is available as well as the wiki, chatroom, web forum and some basic mailing lists... Note: SVN and Bugzilla are used by default for the quick "Share on Kenai" method. Of course it is possible to create a new Kenai project (from the IDE) that uses Mercurial or Jira, for example (see Team>Kenai menu)... Also, other features (more repositories, for example) can be configured via the on-line interface (visit Kenai.com for details)... Step 2 - Set up the team Once Philip and Kate are registered on Kenai.com, they can participate in the project (theoretically, they can join any Kenai project at least as the "observers"...). The easiest way to join the project Peter just created is to let Peter know about their Kenai nicknames (to send an e-mail to him). Peter can add anyone in his project via the web interface and give that person the "developer" role... ... ok, assume that Peter added Kate and Philip in his project... So from now on, there is a project on-line with 3 members who have at least a "developer" role (Peter is "admin"...). Once users are added in the project, they receive an e-mail about this fact and they can login to Kenai service from the NetBeans IDE... Step 3 - Everyone has everything from now on Philip and Kate start the NetBeans IDE and they login to the Kenai service from the IDE (Team>Kenai>Login to Kenai). Once they are logged in, the Kenai dashboard opens and they can see the project Peter created instantly (it is a project they are members of). They can easily get the sources - this is the first thing they probably want to do... Then they can develop and check the sources in as if they were working with any other svn repository... No special repository configuration is needed, everything "just works". Furthermore, all team members can submit issues directly from the IDE (and see the issues that are submitted). They can enter the chatroom and exchange some quick words, they can also go to wiki (opens in the web browser) and edit it (which is likely Philip's job, he is not very good in coding, after all)... or they can answer their professor's questions on the mailing list/forum... ;) What do we want from you? Plain and quick answer - your projects and your comments about the NetBeans/Kenai integration, submitted issues are welcome too. We will give you the infrastructure for free and we will take care of the technical stuff, you will provide a meaningful content and great innovative applications so that the service gains attractivity and fame. It really is so simple, no mystery;)... This is one of the many ways how the cooperation of big IT companies with you students can look like...

The university/student projects have their own specifics. One of the most visible one is that the innovation and enthusiasm is often combined with rather weak software engineering and poor...

NetBeans

NetBeans IDE is scanning/parsing/indexing for ages? Yeah, it's a bug!

"Scanning in progress..." - I believe that everyone have met the issue. You open some larger project and you can not use the NetBeans IDE for a few minutes until the sources are "scanned", whatever it means... Some unsorted facts first li { margin-bottom: 10px;} scanning is needed and must be performed, otherwise features that need a knowledge of the source code structure (code completion, refactoring, go to ...) could not be used only the first scanning should be slow - the result is cached in your userdir ($HOME/.netbeans/$VERSION) and further parsing is incremental (only the part that is modified is scanned again) editor infrastructure is very new - Parsing API was introduced in 6.5 for Java and in 6.7 for other languages, therefore, some optimizations are not made yet (for example scanning files in a more intelligent order, allowing to use some features while scanning, etc.). Scanning itself is absolutely no problem - the problem is that the IDE is not very usable while scanning is in progress... scanning&indexing issues are the most commonly heard "deal-breakers" for the Netbeans IDE and the NetBeans dev team knows about them Submitting scanning&indexing issues If you are in the situation when the scanning&indexing takes too much time or if the IDE freezes during scanning a project, it is an issue. The only way to increase the chance someone is able to fix it is to submit the issue and to have enough patience to handle the issue (reply questions, provide more details, don't get offended by developer's questions/comments...). Let's summarize what you need to do in order to file a useful bug report on scanning: In order to improve logging of the scanning related issues, please run IDE with a command-line switch that improves logging:-J-Dorg.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.level=FINE Include the version of NetBeans, Java and OS in you report (copy information from Help>About) and attach IDE log file ($HOME/.netbeans/$VERSION/var/log/messages.log) Describe your problem as precisely as you can but please try to be brief too (these requirements are contradictory). Specifically for scanning issues, include the answers to following questions: Does the scanning ever finish? If yes, how long did it take? Was it only the first scan issue, or is the problem met whenever you open the project? If scanning didn't finish, did IDE freeze so that it needs to be killed? If yes, did the main window repaint (was AWT blocked)? Provide as much information about your project's setup as you can - we cannot reproduce all bugs as we don't have every possible setup: What is your project type? How big is your project (number of classes, disk size, ...)? Does your project use some libraries (how many)? What is the structure of your project (i.e.: long "string of dependencies"...)? Is your project public, so that everyone can get the sources and open it? It very often happens that the performance issues are a result of some specific setup and they can be unrelated to the place where they actually occur - we need to identify possible external cause of the problem: Do you use any version control system for your project? Is your project located on the network drive? When you meet some performance problem and you intend to submit an issue, please don't forget to capture a thread dump or a profiler snapshot so that we can readily see where the activity is. These are the points that I see as the most important when submitting the scanning and indexing issues. If you think of some other information that can be useful, please add your comment/hint to the discussion...

"Scanning in progress..." - I believe that everyone have met the issue. You open some larger project and you can not use the NetBeans IDE for a few minutes until the sources are "scanned", whatever it...

NetBeans

Enhancements of the NetBeans Output view

... or rather "Finally, a font size can be configured for Output view"? Today, I was sitting in my office with Tomas Holy, a dev guy who was responsible for the Output view (the view where build output is written, for example). We were chatting for a while as we needed to relax a bit after the hard labor we do. I suddenly recalled a very commonly heard RFE's: "Thomas, you know what you should implement? Settings for the font size in the Output view..."Tomas's reply was plain as usual - with his traditionally bored voice he said: "Yeah, it is already there..." He was right, it really showed up in NetBeans 6.7... Those are great news for many people (especially for teachers/professors who use NB IDE at their lessons). So currently, you can right-click the output window a do quite a lot of cool stuff, such as: Resize the font (Ctrl+MouseWheel works as well) Change a font ("wrapping mode" must be disabled) Set a filter for the output lines (so that only lines matching a regexp can be shown, for example) Furthermore, Tomas told me he did some rather major enhancements regarding the search functionality (in the Output window), therefore the search should be much faster and should be more memory efficient. I bet everyone has noticed better coloring of the text output... I hope you will be happy of this enhancement as much as I am! :)

... or rather "Finally, a font size can be configured for Output view"? Today, I was sitting in my office with Tomas Holy, a dev guy who was responsible for the Output view (the view where build output...

NetBeans

Hudson integration in NetBeans 6.7

Are you a Java developer and did you ever need to build your sources automatically? In this case, you must have already heard about Hudson... If you have used this tool, you must also know how great it is... But there is one more cool thing now (get ready to get excited:-)). We have integrated Hudson in the NetBeans IDE 6.7. But first things first for those who are not in the picture yet.... Briefly about Hudson - automate your builds Hudson is a tool for continuous integration (CI) written in Java that runs as a server. It allows you to create a task ("Hudson job"...) that is executed either manually, or when some condition is valid, or periodically (in a given schedule). This job can be for example an Ant task - Hudson can be used for periodic building. Furthermore, the version control systems are very well integrated with the Hudson  -  you can have one computer with running Hudson instance and some other computer with the source code repository where you and your team commit the sources. (These are typically not the computers that are used by developers.) Build is performed on the computer with running Hudson instance (slaves can be configured for more complex building but let's keep it simple for now) and it is performed with all committed changesets. This means the resulting build artifact is more representative than the one that programmer has on his/her computer (as the local sources can be outdated). Sample of how the architecture can look: Hudson can be easily run on any computer with: $ java -jar hudson.war This launches a server on localhost (port 8080 by default). Hudson and Hudson jobs are easily configurable via the web interface... More information about the Hudson CI Tool are online. Hudson and NetBeans - making it even simpler Since NetBeans 6.7, the Hudson Builders node is present in the services. You can easily create and manage some properties of the Hudson job. Before you can create a Hudson job from IDE, you need to do following: Download Hudson and run it on some machine that you have access to ... so that you have a running Hudson instance ... You need to have your NetBeans project versioned either with SVN or Hg - install SVN/Hg on some other machine ... so that the sources are on some well defined place ... Your project must have sharable libraries ... so that the build can be performed - build cannot be successful if your project uses some libraries that Hudson does not have access to... ... otherwise you cannot even to run JUnit tests remotely ("junit.jar" library is needed)... Note: In order to make libraries sharable, open project properties, select "Libraries" section, click "Browse" button by the "Libraries Folder". Click "Next", click "Finish"... Now how to create a Hudson job from the IDE: Register a Hudson instance in the IDE Open services view (Ctrl+4) Right-click the "Hudson Builders" node Invoke "Add Hudson Instance" action, fill in some alias for the instance and the URL Confirm the dialog - a new Hudson instance should be visible in the view (if there are some jobs on the instance, they are visible too) Create a new Hudson job (or "build"...) Right-click the Hudson instance you just added Invoke "New Build" action Fill in some alias for the build Browse for your NetBeans project Optionally, check what parts of the job should be performed (build Javadoc, run tests) Click the "Create" button - a new build will show up in the view Run the Hudson job Right-click the build you just created Invoke "Start job" action Expand the build's node - you will see a running instance of the job Right-click the running job and invoke console output - you can see the progress of the build that runs remotely (!) on the machine where the Hudson instance runs How can you helps us? Hudson integration is new in 6.7 and it definitely needs testing on various configurations. We are not able to test the Hudson integration in all scenarios - this is basically not technically possible. Your Hudson might use various authentication methods, your jobs can have specific configurations... If you encounter any difficulties, you can submit an issue on the Hudson component and it will help us a lot (General: How do I file an issue?). You can provide a valuable feedback by writing comments on our mailing lists and forums. If you like the feature, help us to promote it, for example by writing some nice blog posts (if you intend to write an ugly one, please, file an issue first;-)) or by spreading the word.

Are you a Java developer and did you ever need to build your sources automatically? In this case, you must have already heard about Hudson... If you have used this tool, you must also know how great...

NetBeans

Dialogs in NetBeans RCP, DialogDisplayer class

Friends of mine who tried to play around with the NetBeans platform usually didn't know how to correctly create a custom dialog. They tend to reason about this task in the basic "swingy" way: create a new JOptionPane, set it visible when needed and hide it when not needed anymore. This approach certainly works and maybe it is more understandable from the beginner's point of view. On the other hand, the NetBeans platform has much better and more structured way of displaying a dialog. The classes that are important for this are NotifyDescriptor and DialogDisplayer: NotifyDescriptor is a class that carries the information about how the dialog should look (the actual content, the main buttons, etc.). DialogDisplayer is a (singleton) class that actually displays the dialog that is described by the NotifyDescriptor and handles the return value of the dialog. So what do you need to do in order to create a dialog in NetBeans? Add the "Dialogs API" dependency for the module invoke project properties, select libraries section and add the dependency on the "Dialogs API" Create a JPanel Design the content of the JPanel Do not create the OK/Cancel/Yes/No/etc. buttons - those are handled in the NotifyDescriptor (later) Create the public API for getting some values from the JPanel (for example method like getNameFieldValue()) Create the NotifyDescriptor and pass the instance of the panel you have just created to it You can create your own NotifyDescriptor or you can use one of the predefined ones: NotifyDescriptor.Confirmation NotifyDescriptor.Exception NotifyDescriptor.InputLine NotifyDescriptor.Message Tip: If the description of methods makes no sense since there is no reasonable JavaDoc and if the parameter names are not saying too much, go to Tools>Plugins, select Available Plugins tab and install "NetBeans API Documentation" plugin. This will install JavaDoc for the NetBeans Platform API and the descriptions of the constructors should be more comprehensive  (and coding with NB Platform becomes more pleasant)... Get the default instance of the Dialog displayer, call the notify method on it and evaluate the dialog result. Few source code lines says more than thousand words;-): // Create instance of your panel, extends JPanel... MyCustomPanel myPanel = new MyCustomPanel(); // Create a custom NotifyDescriptor, specify the panel instance as a parameter + other params NotifyDescriptor nd = new NotifyDescriptor( myPanel, // instance of your panel "Title", // title of the dialog NotifyDescriptor.YES_NO_OPTION, // it is Yes/No dialog ... NotifyDescriptor.QUESTION_MESSAGE, // ... of a question type => a question mark icon null, // we have specified YES_NO_OPTION => can be null, options specified by L&F, // otherwise specify options as: // new Object[] { NotifyDescriptor.YES_OPTION, ... etc. }, NotifyDescriptor.YES_OPTION // default option is "Yes" );// let's display the dialog now...if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.YES_OPTION) {// user clicked yes, do something here, for example: // System.out.println(myPanel.getNameFieldValue()); }

Friends of mine who tried to play around with the NetBeans platform usually didn't know how to correctly create a custom dialog. They tend to reason about this task in the basic "swingy" way: create a...

NetBeans

NetBeans chat window tweaking... and thinking afterwards

If there is not enough time to implement a feature, the main focus is put on the functionality, not on the UI. Logical but sometimes sad reasoning. And this was exactly the case with the IM feature in the NetBeans IDE. As Kenai.com introduced the IM feature just before the NetBeans code freeze, we had very little time for testing it and also for making the chat window look nice - we needed it functional (achieved - thanks to great work of Honza Becicka), not sexy. However, I was not willing to accept this trade-off. I believe that if you want people to use some new feature, it must be attractive, or at least attractive enough. So I decided to contribute in the NetBeans ("kenai.collab" module) and I tweaked the chat window a bit. Last changes were made literally in the last-second, on the day of the "code freeze"... I made mainly following changes: Added background colors to the messages ("pseudo-unique" for every user) Messages from one user are grouped if there is less than 2 minutes between them Added smileys URL recognition See the "before-after" picture: Thanks to the guys from the NetCat 6.7 It is worth to say that the feature was tested by some members of the NetCat 6.7 team and it was perceived as "cool". We have received a great feedback and gathered a lot of valuable information. Many clever suggestions were made too. Luckily, there were almost no issues found and if some, they were either resolved or not too serious (issues that were found are already reported and they will be dealt with). There was a thing that I liked about the IM testing with the NetCat guys. I was fixing some chat issues "on-the-fly", immediately as they were reported in the chat itself. I received a comment, I looked up the wrong code, pasted it in the chat window so that the problem's cause is exhibited to the public audience, NetCat member said "Oh, I see! :-)" and I fixed the code... This can make development very efficient! Now just a little thinking... Maybe this might be a new way how the NetBeans development could be handled. Every NetBeans component would be a project on Kenai.com (or maybe on a private deployment of the same system?) and thus we would have everything we already have plus every component would have a chatroom where issues could be discussed and immediately resolved with the developer of the component. How do you like this idea?

If there is not enough time to implement a feature, the main focus is put on the functionality, not on the UI. Logical but sometimes sad reasoning. And this was exactly the case with the IM feature in...

Sun

How to set up Pidgin for a Kenai project chatroom

This short "How To" should help you to set up the Pidgin client for the chatroom of your Kenai project. The process consists of three steps. 1. Bookmark a project on the Kenai.com web page Join the Kenai.com project and log in Search for the desired project Click "Bookmark This Project" link by the project - this will give you an Observer role for the project 2. Set your client to use the Kenai.com XMPP account Start Pidgin Right-click the icon in the system tray and invoke "Accounts" Click "Add" button Choose "XMPP" as the protocol Fill in your username and password - the same credentials as on Kenai.com You must use the form that can be seen in the upper-right corner of the Kenai.com page after you log in - the e-mail address will not work Fill in "kenai.com" in the "Domain" field Optionally, you can fill in the local alias Switch to the "Advanced" tab and check "Require SSL/TLS" Click "Add" button and accept the certificate after prompted Close the "Accounts" dialog by clicking "Close" (an account should be already visible in the dialog) 3. Join a chatroom of your project Open a Pidgin window and invoke "Buddies>Join a chat" Make sure that the right account is selected Fill in the project name in the "Room" field and click the "Join" button

This short "How To" should help you to set up the Pidgin client for the chatroom of your Kenai project. The process consists of three steps. 1. Bookmark a project on the Kenai.com web page Join the Kenai...

NetBeans

Build the latest NetBeans yourself

This blog post describes how to clone and build NetBeans from the Hg repository. Italso contains some notes that I received from my friends who followed my originalinstructions. Official (and maybe less detailed) info can be found here: http://wiki.netbeans.org/WorkingWithNetBeansSource Any comments are verywelcome! What do I need to start? Approximatelly 3+ hours of your time (you don't need to work for 3hours, but some time is needed for the download and the build) Mercurial VCS: Distributed version control system, used for developmentin NetBeans team (and in Mozilla, for example). Note for non-english speaker: Hg =Mercurial (chemistry: Hg → Mercury)... JDK5: NetBeans cannot be (easily) built with JDK6. The build issomehow possible, but currently it is not very simple, even for more experienced user...The main reason for using JDK5 is that NetBeans must be runnable with JDK5 or newer - byusing 1.5.0 you will ensure that you don't use APIs and features available only in JDK 6or newer. Ant: It is - simply said - "make for Java", a build tool using XMLfiles to specify build targets, ... How do I install Mercurial, Ant and JDK5? Ubuntu linux: sudo apt-get install ant ant-optionalsun-java5-jdk mercurial Windows: Download and install (follow the guidelines on the product's pages) binaries fromthese pages: Mercurial (note: use this one, do NOT useTortoiseHg!) JDK 5.0 Update17 Ant Test if you have properly set PATH variables: typehg and ant in the command line, you should get a response from theapplication (not just an "Application not found" message). Set the PATH variable to thefolders of appropriate binaries if needed... Please note that if you have newer version of JDKinstalled together with the older version, and your Ant is throwing an error message, youcan add an environment variable JAVA_HOME pointing to the previous version ofJDK. How to clone NetBeans repository? Both operating systems: If you have proper Hg installation, you shouldbe able to call: hg clone http://hg.netbeans.org/main-golden Note: This will clone themain-golden repository (this is the one that dailies of NB come from) in the directorywhere you called "hg clone". Navigate to desired folder first! Note: be patient, clone can take more than 2 hours(depends on the speed of connection) Note: Hg is not very chatty - you canimprove it little by -v (verbose) switch, but it is still more quiet then feelsconvenient... How to set up the build environment? Before you attempt to build NetBeans from the sources for the first time, you must dofollowing: Create files {$NB_REPO_CLONE}/main-golden/nbbuild/user.build.properties {$HOME}/.nbbuild.properties Place following content (desctiption/explanation is inline) to the files nbjdk.home=/path/to/jdk15/folder Note: Windows users must use "\\\\"("escaped backslash") as a path separator! build.compiler=extJavac javac.compilerargs=-J-Xmx512m Note: If this option was ignored, settingenvironmental variable ANT_OPS (to ANT_OPTS="-Xmx512m") should help How to build NetBeans for the first time? Follow previous steps!!! Start terminal Navigate to the {$NB_REPO_CLONE}/main-golden and type:ant Wait - full "clean" build takes quite long (expect 30-60 minutes). My build was sucessfull. How to run NetBeansnow? There are 2 possibilities: Stay in {$NB_REPO_CLONE}/main-golden and type ant tryme, or... Navigate to {$NB_REPO_CLONE}/main-golden/nbbuild/netbeans/bin folderand run netbeans from there I built NetBeans X months ago and I would like to build aversion with updated sources - how do I do it? Start terminal, navigate to {$NB_REPO_CLONE}/main-golden folder If you made some local changes, commit them: hg ci -m "my commit message" Note: you mustn't have uncommittedchanges before performing the next step Note: committing will change only yourlocal repository - see how Hg works, you are not allowed to mess with the officialNetBeans, so don't worry you break something by committing Fetch the changes: hg fetch Note: the fetchcommand is a convenient one-command-only way of performing pull(download remote changes), update (update local copy) andmerge (merge changes) Note: if fetch does not work for you,use "hg pull -u; hg merge" Build updated version of sources using ant (the same as the firstbuild)

This blog post describes how to clone and build NetBeans from the Hg repository. It also contains some notes that I received from my friends who followed my originalinstructions. Official (and maybe...

Sun

It's here - Java Plugin for Firefox on 64bit Linux (tested with Ubuntu)

An issue that bothered many usersof 64bit Linux is hopefully a history since JavaSE 6u12, which is nowavailable in development version (therefore it is not a stable buildand it is not recommended for "production use"). I have managed toinstall a Java plugin for Firefox on my 64bit Ubuntu - installation waspretty flawless... Confirmed here: https://jdk6.dev.java.net/6uNea.html So, what do you need to do in order to have a working Java in your Firefox on 64bit Linux? Update: Use Firefox from your distro repository. Rollbackall your previous attempts to make Java work - if you don't performthis step, the result is uncertain... This includes especiallyfollowing: Make sure you have 64bit version of Firefox (previous workaround was to use 32bit version of browser). Note that there is also a 64bit Flash plugin for Linux available, so 32bit version of browser should not be needed anymore... Remove IcedTea/gcj/... plugin if you were using it Download JRE 6u12 (an early access) from pages with JavaSE 6u12 dowloads (you can use this link pointing to the b03) and install Java to any desired folder (I would suggest /usr/lib/jvm folder for Ubuntu users, this is where Ubuntu places Java by default)... Create a link (ln) pointing to the Java plugin (file <JRE_FOLDER>/lib/amd64/libnpjp2.so) in the ~/.mozilla/plugins folder (to let Firefox know where the new plugin is...) - maybe you will have to create this folder (I had to) Makesure the installation didn't interfere with the rest of your Javaenvironment and that you are using stable Java system wide (call java -version). If not, reconfigure your Java environment, for example using update-java-alternatives command (thank's to Petr Chytil for the hint) Note/Update: Are you getting "LoadPlugin: failed to initialize shared library/opt/java/jre1.6.0_12/lib/amd64/libnpjp2.so[/opt/java/jre1.6.0_12/lib/amd64/libnpjp2.so: wrong ELF class:ELFCLASS64]" message? Try to use the Firefox that is in your distro's repository. The problem Werner was facing (see the discussion below) was resolved by installing official openSUSE packages instead of the Firefox from mozilla site... Werner, thank you a lot for not giving up and elaborating on the issue! Hope this works for you, now you should be able to check some sweet JavaFX demos out... If you experience any troubles, please share them in discussion below...Update: Users of RHEL, please read the discussion for troubleshooting...

An issue that bothered many users of 64bit Linux is hopefully a history since JavaSE 6u12, which is now available in development version (therefore it is not a stable buildand it is not recommended...