Align the contents of the panel to the top of the panel

I have following example. What I would like is that the content of the panel is aligned to the top of the panel but it get's aligned in the center of the panel. I thought using GridBagLayout as manager and setting the anchor to NORTH should do the tr

Check box to change the actionlistener button

I'm trying to make in a small program I'm creating that when one checkbox is selected the action performed for a specific button to be changed to another action performed, let's say the button action performed gives the result of 1+2, I want when I c

JLabel - On Mouse Came, move on to a JTextField

I have a JLabel with the text "Enter mouse" on it. As soon as the user enters the mouse on it I'd like a JTextField to be appeared so the user can search some things. If the mouse is removed then the previous JLabel has to appear again. I use: i

Adding a submenu

So I tried to look at the Java docs for help for this but got confused pretty quickly. I am trying to add a submenu to the menu item 'Edit' which will have submenus Copy and Paste, and I'm note sure how to do it. I have a submenu variable created, do

How to detect a button pressed in a normal Java file?

In JavaScript, I entered a code which opens a Paint JFrame. I made a separate JFrame to change the colour. The button says 'Change Colour' which I plan to write a code which goes to the next colour when clicked. However, I do not know how to make a k

Deploying the Java application on the Windows system

I have created a Client-Server System using Sockets to send files over same network. Now I have created their respective JARs. I have placed the option in context menu using regedit in my Windows 8 I use Batch script to direct argument from this cont

Implementing the GUI

I need to get a GUI which should have two rows and two columns [ 1st column with labels and the second column with text fields]. I have written the below code but i am unable to get it into columns and rows.Could you please help to make it into colum

What is the conventional way to write a GUI in Java?

I have finished a GUI app. I have four classes: Main, UserWindow, Task1, Task2. Main class contains a boolean variable buttonStartPressed. Main method starts an instance of the UserWindow class, and waits until the user presses the Start button. As u

unable to identify the current visible map in CardLayout

i have a JPanel like: public class CardLayoutPanel extends JPanel { String[] option = {"login", "register"} public CardLayoutPanel() { super(); combo_box = new JComboBox(option); login_panel = new LoginForm(); register_panel = new Regi

A small guessing game GUI opens in two windows

Alright so here's the problem: I created this small guessing game and wanted to make it gui based... but it appears in two different windows - first window is the menu(button and label) second window is activated by the button and has the game in it.

Origin of Java.awt.component for MouseEvent.getX ()

I am trying to calculate the distance I move a mouse within a box, I am using the MouseEvent.getX() and MouseEvent.getY() to calculate the start position of the mouse and then I have another method saving the position and calculating the distance the

The image does not appear inside JPanel

I want to display an image inside a panel. So I pass the path of the image to this method, open image file and pass it to the method of a private class dedicated to draw image inside the panel. The problem is the panel remains empty all the time and

Clean drawing folder

my java application contains a JPanel on which I draw certain shapes. Now I would like to label these shapes with some kind of tooltips. Therefore I tried to create my own "Tooltips" by using the drawString, setBackground, setColor method.: publ

Need to extend both MouseAdapter and KeyAdapter

Just wondering what is the best practice way of creating a class that needs to handle mouse clicks and key presses. Obviously it is not possible to inherit multiple classes in Java so at the moment I am using the MouseListener and KeyListener interfa

MVC a lot of view and a controller

In my application there are many views(sub components) and only one controller. Selecting some options in one view can change the layout and number of components in another view. The controller initialises the view, which in turn creates all the sub

Remove the selected JList index

So I have a JList in my program and it starts with the selected index 0. However, during the program I want to do myJList.setSelectedIndex(-1) or something like that so that nothing is selected ? Hope I was clear. ThanksJList has a method to clear th

The action listener of my program will not work

It's me again and I just can't seem to get this code to work. I'm basically asking for any advice on why the button does nothing when clicked. Would you like me to attach the source code? The method I'm trying to implement: public static void UserInp

Method of transmitting significant messages between classes?

I would like for the GUI/JFrame of my Java application to display meaningful loading messages as is commonplace. How is it possible or what is the most refined way of passing loading messages to the JFrame class from a Class which is only running one

JNI - connect STDOUT to a JTextArea?

I am wondering if it is possible to connect STDOUT of a C/C++ dll to a JTextArea? The thing is, I am using 3rd party DLL's so I can't manually alter them. Basically I have my Java applet, and then my own DLL which Loads and manages the 3rd party DLL'

TimerTasks in Swing

I'm trying to write a message acknowledgement application where I need to: a) Add every new message on a message queue. Just using an Arraylist for creating a message queue. b) Notify a timertask to expect an acknowledge in 50 sec for the message so

draw an image or draw a filled circle?

We have an old Java Swing application. we need to display thousands, hundreds of thousands small circle spots on the canvas based on the real data. Right now we have an image file of a small circle spot. When we need it, we draw that image onto the c

Can you host a Java swing application in a WPF application?

I suppose the question I'm asking is it possible to host a JVM inside a WPF application? WPF = Windows Presentation Foundation Found this so far: you can P/invoke out to anything, you could create a nati

How to justify the icon correctly in a JLabel?

For a JLabel with icon, if you setHorizontalTextPosition(SwingConstants.LEADING), the icon is painted right after text, no matter how wide the label is. This is particularly bad for a list, as the icons would be all over the place depending on how lo