swing

JLabel which hides text after reaching certain length or number of values

The purpose of the JLabel is to show who a message is to, like in a mail client e.g. To: John, Mary, Peter, Frank, Tom, Harry I will have the names in a vector so can build up a string from that and then set the label's text to this string. However it has the potential to get quite long. I was think it might be nice to have something ...

Java Swing Resource for jRuby developer?

I'm looking to develop GUI apps using jRuby but, am not sure which would be a good Swing book or tutorial to start with in my studies. ...

What is the correct way to set size of elements of GUI?

I am using swing to create my GUI. J have a JFrame containing one main JPanel which, in its turn contain several JPanels which, in their turn, contain buttons. I would like to set certain sizes to mu buttons and JPanels. How does it work? Should I set sizes of my buttons and then the size of the JPanel and the JFrame will be set accordi...

Java Swing Generate JTable from POJO at runtime

I'm looking for a library able to build at runtime, using some configuration (xml, annotations, ...) and reflection, a complete JTable (model + searchable and sortable jtable) from a collection of POJOS. I did not found anything like that on the web and I'm wondering if something already exist before I start to coding this. ...

What is the easiest way to output only a certain number of digits after a decimal place in a JTextComponent (Java swing)?

I am using both JLabels and JTextFields, and need to be able to truncate my doubles to two decimal places when they are outputted to the application. What is the easiest way of doing this (preferably without switching to JFormattedTextFields)? Thanks, badPanda :D ...

Java swing examples - Ants running around a world getting food from piles?

I haven't done any swing programming in a while, so I'm looking for some GUI examples that are at least close to what I'm trying to do. The gui that I'll need to be representing is small nodes (let's say ants) travelling around collecting food from food piles (which just means small nodes travelling to bigger nodes). Once the node (ant...

Swing Menu dimensions

Greetings. I am trying to learn Java and Swing (today is my first day). I have been able to set up a menu in my test application. but the items occupy very little space (they are narrow). How do I go about extendng the amount of space it uses? I am studying Teach Yourself Java 6 in 21 Days 5th Ed, Java Swing, 2nd Edition, 2002 and Te...

how to disable minimize button in frame?

can i disable minimize button in frame?how?(i hav already tried setUndecorated() and setResizable().both didnt work). i m trying to add imags to a panel at a random location which i m able to do) bt wen frame is minimized by clicking at the minimize button (not wen frame minimizes by clicking at the background window) images assemble at ...

search data from FileReader in Java

hi I'm new in java how to read and search data from file (txt) and then display the data in TextArea or Jtable. for example I have file txt contains data and I need to display this data in textarea after I clicked a button, I have used FileReader , and t1 t2 tp are attributes in the file import java.io.FileReader; import java.io.IO...

JList - deselect when clicking an already selected item

If a selected index on a JList is clicked, I want it to de-select. In other words, clicking on the indices actually toggles their selection. Didn't look like this was supported, so I tried list.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent evt) { java.awt.Point point = evt.getPoint(); int in...

only one swing frame window opened at time

I developed one swing application but each time you run application new window is opened. I want that if one window is already opened other not allow to open. ...

how to include more than two panel in a frame?

Sir, We are working on a project.Here we encountered with a problem ie we are unable to include more than two panels on the same frame .What we want is one panel above the other. Can you please help us with this? ...

Java JFrame is very strange

When I am running this, JLabel is not visible, but when I resize window (with mouse) JLabel is showed. Why? import javax.swing.*; import java.awt.*; public class FrmTaoLogin extends JFrame { private JPanel pnlLeft = new JPanel(); public FrmTaoLogin() { super(); pnlLeft.setBorder(BorderFactory.createEtchedBorder()); ...

java AWT native OS library ?

Hi, As we know AWT classes uses native OS libraries for creating GUIs but Swing uses Java library itself for creating the GUI.Can anyone please give me an example of the Windows OS library corresponds to a AWT GUI ? Thx ...

MVC Pattern in Java Swing ?

Hi, Please give me an example for MVC pattern used in Java SWING package ? ...

Java Swing UI Changing Method

I would like to use Swing to program a simple learning game. I am wondering what would be best way to switch between UI screens. For example, I would have a screen for the Main Menu, and then when the user presses a button on that screen, I would swap out the whole screen for a completely different one. Then, arbitrary screens can be...

How to save file using JFileChooser??

Hi, I have a method in my application called "Save as" which Saves the image of my application on computer my into a file. I used the JFileChooser to let the users choose their desired location for saving the file. The problem is unless user explicitly types in the file format, it saves the file with no extension. How can I have formats...

Filling combobox from database by using hibernate in Java

Heyy; I am developing a small swing based application with hibernate in java. And I want fill combobox from database coloumn.How ı can do that ? And I don't know in where(under initComponents, buttonActionPerformd) ı need to do. For saving ı'am using jbutton and it's code is here : private void jButton1ActionPerformed(java.awt.event...

Drawing multiple lines with Java Swing

I'm learning drawing lines with Java Swing in order to draw a labyrinth. I can draw one line at a specified position and it shows just fine. But when I want to draw multiple lines, only the last one shows. My code: public class LabyrinthGUI extends JFrame { ... Line line; for (int i = 0; i < 10; i++) { line = new Line(i*25, 0, (i+1)*...

Did Hans Muller ever publish "Mastering JList Programming" as promised?

This article was Part 1 of a two part article. I cannot find Part 2, "Mastering JList Programming". Google cannot find it. Did it get lost in the Oracle-Sun move, or was it never published? ...