Java Swing-Call an actionlistener of the external class

Hi I am new to Java Swing. Have a Swing class as follows- Class A extends JDialog { JButton button=new JButton(" test"); button.addActionListener(new TestAction()); //Inner class private class TestAction extends AbstractAction { public void acti

Java jframe adding canvas and jpanel

The following class creates a window/frame. public class Window { private int width, height; private JFrame frame; private Canvas canvas; private String title; private JButton button; private JPanel panel; public Window(String title){ System.out.prin

how to display values ​​on java form labels

I was trying to make a salary calculator using java in netbeans. I coded it with the design. When I enter the employee registration number employee's name then the basic salary and allowance values should be displayed in the relevant field in the for

Selection change JComboBox

everyone i am quite new to Java GUI, i am having an issue with a JComboBox , where it is firing when i removeAllItems from a combo box to refresh it, this is an issue because i am getting the selected items Details and populating a textboxes with the

Run events in an infinite loop

public void actionPerformed(ActionEvent event) { // TODO Auto-generated method stub JButton src = (JButton) event.getSource(); //get which button is clicked if(src.equals(GO)) //if GO button is clicked { try { runHack(); } catch (AWTException e) { //

How to put images in the .jar file?

first i'd like to say that yes, i searched, i searched real hard and unfortunatelly, i did not find any answer good enough for me, i think i know what to do, but i don't know how to do it ! Well, i put a lot of images in my program, and it worked out

how to set jcheckbox inside jtable dynamically

In this picture the return table head values show in the checkbox . here jtable the values from database I tried it but classcastexception occured because of boolean value cast to string i don't know why that error occured this is my code static Obje

Force JLabel Subclass to display

I have a class, that extends JLabel, to display an image on the whole innerArea of the label. To achieve this, I overwrite paintComponent like this: protected void paintComponent(Graphics g) { super.paintComponent(g); if(image != null) { SwingUtiliti

Get an error in the checkboxes

I am extremely new to Java. I tried to create a checkbox program that will italicize and bold text on click. I have completed the coding but getting error and don't know how to resolve it.Here is my code: import javax.swing.JFrame; import java.awt.*;

How to print a JTable object in the Java application

Question Now once the data is fetched from the database and shown in the JTable object "table" embedded in the scrollPane, how do we create a print job that makes it possible to print the displayed table as such in A3 sized paper ? My code to fe

Use two JPanels in a JFrame

I'm attempting to create a program that allows the user to click a button to place something in the JPanel and allowing them to move this item around. I have already found a good layout to use to allow the moving components (see this link). However,

how to recover data from mysql to java

I am making a java program about library computer seat monitoring. If the library custodian enters the student's student number, he/she will be logged in and his/her firstname and lastname will be displayed on a JLabel in java GUI. The student number

Java JTextArea does not fill correctly. Help me please

Can some one please assist me, I have homework due tonight but have one stumbling point because I don't seem to be updating the JTextArea correctly. The loop runs on its own and produces 6 lines to the consol but will not do the same to the GUI? Any

How to access the dynamically created element (JAVA)?

I have dynamically created several jCheckBox elements: for (j=0;j<j1;j++){ final JCheckBox cb = new JCheckBox(""); cb.setText(col_name); mainPanel12.add(cb,BorderLayout.NORTH); mainPanel12.repaint(); ... } How can i access some particular che

Insert radio buttons in JTable NetBeans

I am populating Employee Data in JTable using Netbeans. I want to add Radiobutton in each row, so that user can select any row and can perform actions like Update/Delete,etc. Here is my code for TableModel: DefaultTableModel model = new DefaultTableM

How to create Listview in Java?

How to create ListView in Java? Can you give me a simple sample code on how to create ListView?Do you mean JList?, see java tutorials: How to Use Lists

JMenuitem - click - action - Java

I have written code to perform click event on JMenuItem but that is not firing when I am debugging. (I know that I am not supposed to ask these questions in this forum but I am new to this forum) public class ClsMenu extends JMenuItem implements Acti

Make an open panel when I click a button

does anyone know how to make a GUI button open up a new JPanel in java? its not on google. its to show an about panel. thanks for the help!I guess JDialog is what you need. See this for details : How to Make Dialogs Here is a sample : import javax.sw

Java code does not work on Mac OS X

I made a swing application, where I have need to shape the windows as I want. So for this purpose, I made a polygon which is equivalent to my desire shape, and then call setShape(myPloygon) method, by which a frame is create in custom shape. final Wi

JProgressBar update

Could someone help me ? I would be grateful. I've got example code: .... int sizeFile; RandomAccessFile raf; InputStream in; int val= 0; int downloaded= 0; while(( != -1) { raf.write(buff, 0, val); downloaded+= val; float wartosc =

Problem entering JTable from the keyboard

i want to know how to give input to the cell in a jtable from key board... and when i try to do dis when i move on to next cell the previous enter data is removed or erased automatically.... iam using abstracttable model for creating jtable.... pleas

Capitalize all the letters in a text field in Java

Is it to possible to capitalize the letters in a Textfield as they are being typed by the user in Java? E.g. The user would type 'hello' and 'HELLO' would appear in the Textfield. (Odd request and I don't like the idea either).Format JTextField's tex

How to update JLabel in Swing?

I am trying to use Swing Timer and I wanted to start from a very simple program. I have a window with text: "You have n seconds", where n changes from 10 to 0 every second. I know how to generate a window with text. And I understand how Timer wo

Swing JTextField how to remove the border?

Is there anyway to remove a border in a JTextField? txt = new JTextField(); txt.setBorder(null); // <-- this has no effect. I would really want it to look like a JLabel - but I still need it to be a JTextField because I want people to be able highlig

Open Source Improvements or Replacements for Swing Components

I develop a number of desktop Java applications using Swing, and while Swing is quite powerful (once you get the hang of it), there are still a lot of cases where I wish some advanced component was available right out of the box. For example, I'd rea