swing

Swing Panel Question

Ok, so I've been pulling my hair out over this all day. I cannot get my panels to resize. I add a panel to anything.. a frame, a content pane, and It wont .. "force" setBounds for some strange reason. Container pane = window.getContentPane(); JPanel calendarPanel = new JPanel(); pane.add(calendarPanel); calendarPanel.setBounds(0,0, 3...

Having a problem getting my ActionListeners, Handlers, and GUI to communicate.

So I am trying to get my GUI to work. When I run the code below, it does nothing, and I'm sure I'm probably just doing something dumb, but I am completely stuck... public void actionPerformed(ActionEvent e){ UI.getInstance().sS++; if((UI.getInstance().sS %2) != 0){ UI.getInstance().startStop.setName("STOP"); UI....

single column of JTable into a scroll pane

Can we add a single column of a JTable inside a scroll pane? ...

How to save image drawn on a JPanel?

I have a panel with transparent background which i use to draw an image. now problem here is when i draw anything on panel and save the image as a JPEG file its saving the image with black background but i want it to be saved as same, as i draw on the panel. what should be done for this? plz guide me j Client.java public class Client e...

How can I do printing in Java with layouts instead of low level coordinates?

I need to do some printing from my Java Swing application. I have tried to use Java Tutorials, but everything is very low level, and time-consuming. I have to specify the coordinates for every line that I want to print. It is also very lowlevel to use text, because I have to use FontMetrics and calculate what space all text fills up. Is...

Background image in a JFrame.

Hi, This question has been asked a lot but everywhere the answers fall short. I can get a JFrame to display a background image just fine by extending JPanel and overriding paintComponent, like so: class BackgroundPanel extends JPanel { private ImageIcon imageIcon; public BackgroundPanel() { this.imageIcon = Icons.getIc...

Create a Visual Studio type look using Java Swing

I would like to create extend a Java Swing application to have a look somewhat similar to an IDE such as Eclipse or Visual Studio. That’s, there would be a panel at the left that displays a tree, and a tab panel on the right that allows several elements of the tree to be opened and edited on right. For this I could easily use a BorderL...

how to select a line in a Jtextarea?

Hello everyone, I have a jtextarea that is not editable. It has some text in it. What i want is that when a user clicks in the jtextarea, (preferably single click), the entire line be highlighted, and this highlighted text be retrieved. Each line actually has an email of the form [email protected]. To select the entire text would requi...

Simple MPEG Video Stream player, cross-platform, in java, via NetBeans + Swing?

Hello all, Trying to build a very simple video player component in a JPanel (or something similar) to sit in a swing app, connect to an mpeg (or, really, anything VLC can output) video stream, and play it. Don't need any controls or anything -- just a live connection to the video stream. It has to be cross-platform -- at least Mac and...

JScrollPanel without scrollbars

I'm trying to use a JScrollPanel to display a JPanel that might be too big for the containing Jpanel. I don't want to show the scrollbars (yes, this is questionable UI design, but it is my best guess of what the customer wants. We use the same idea other places in the application, and I feel this case have given me enough time to ponder...

Swing button repaint issue

Hello, I'm new to java and I have to get a school project done by Sunday and got a problem. Here's the code: private abstract class GamePanel { JPanel panel = null; } private class PutPanel extends GamePanel { JButton putShip1 = new JButton(""); JButton putShip2 = new JButton(""); JButton putShip3 = new JButton("");...

System.exit(0) in java

I am writing an application program using swing. I need to exit from the application by clicking the JButton for that can i use System.exit() or should i use some other methods, which is the best practice. If calling System.exit() is not best practice then tell the reason and tell the alternative way to exit from the application. ...

"Change" panel on jframe

I have 2 panels, the first one is the menu, and the second is the application main panel. Firstly the menu panel shows up, than i need to switch to the other panel if a specific button is pressed on the menu (the menu is hidden but the app returns to it after running is completed). && i need to resize the frame too if it's possible. can...

Swing - how to mix JTextField and JTextAreas and have same visual appearance?

I am using miglayout to create a form in which there are JTextFields (short input answers) as well as JTextAreas (Longer answers). The problem is twofold. The border placed around a Scrollpane wrapped text area does not match that of a Text Field. The width and placement of the textarea/textfield differ, causing them not to line u...

How to list all available LookAndFeel themes?

How to list all available LookAndFeel themes? I want to show then in a JComboBox for the user to select. ...

Insert one DefaultStyledDocument into another DefaultStyledDocument

I want to insert one DefaultStyledDocument into another DefaultStyledDocument. How do I do this? I know of this method: AbstractDocument.insertString(int offs, String str, AttributeSet a) What I really want is something like this: DefaultStyledDocument.insertDocument(int offs, ...

LookAndFeel not changing in Ubuntu

Anyone knows Why the laf is not changing in the following code? (running in Ubuntu) import java.awt.Dialog; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.UIManager; import javax.swing.UIManager.LookAndFeelI...

Implementing a recently used or favorites dropdown in JComboBox

I am looking for code that will add favorites / MRU type behavior to a JComboBox. I could code this myself, but it sure seems like someone else has probably already done it. I found the following (which looks exactly like what I want, but the source code is nowhere near complete): http://java.sys-con.com/node/36658 Any suggestions? I...

Java swing app can't find image

Hello, I'm making a torpedo game for school in java with swing gui, please see the zipped source HERE. I use custom button icons and mouse cursors of images stored in the /bin/resource/graphics/default folder's subfolders, where the root folder is the program's root folder (it will be the root in the final .jar as well I suppose) which...

How to organise my code in order to be able to use two different view type ?

I have setup my models and now I would like to build the application so that I can easly switch between swing views and html views (2 differents builds). Could you recommand me any library that let me do that ? or a Controller/View architecture that let me do that myself ? edit: MVC architecture in java is the point of my question, if ...