3,978 Topics
![]() | |
Hi, I'm newbie on Jython and on this forum as well. I need to create a GUI with Swing. My original code is based on Tkinter (see below, code adapted from Tony Veijalainen's [URL="http://www.daniweb.com/code/snippet283859.html"]Tkinter Info Grid by loops and tuples[/URL]). The main point is the use of mainloop() allowing the … | |
I'm trying to create a program in Java that I have in C++. In my C++ file, I have main the main method outside of any classes. Eclipse does not seem to like this. Is this not possible in Java? Do I need to put main in a class? import … | |
hello im having problems on how to make a column sorter for my JTable. i want to make a sorter for each column. but i dont know what to do. any advices will be glady accepted :) i've seen other tables that their column headers can be clicked to sort … | |
Hello Guys, Im Using GridbagLayout as LayoutManager, but I am not able to place my button at top-right of my frame. I'm also attaching my current output and what i actually want to do. here's my code: [CODE]package projectilemotion; /** * * @author Taimoor */ import javax.swing.*; import java.awt.*; public … | |
[code=text]jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=C:/Users/Kix/Desktop/IMPORTANT DOCS/oop/BANKSYSTEM/Accounts.mdb;DriverID=22;READONLY=false} Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at banksystem.BankDBDriver.retrieveData(BankDBDriver.java:200) at banksystem.BankSystem.actionPerformed(BankSystem.java:109) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6267) at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) at java.awt.Component.processEvent(Component.java:6032) at java.awt.Container.processEvent(Container.java:2041) at java.awt.Component.dispatchEventImpl(Component.java:4630) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Component.dispatchEvent(Component.java:4460) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4577) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168) at java.awt.Container.dispatchEventImpl(Container.java:2085) at java.awt.Window.dispatchEventImpl(Window.java:2478) at java.awt.Component.dispatchEvent(Component.java:4460) … | |
I'm working on a program where I need to have the user enter the size of the array and then enter the numbers to be stored in the array. If the user enters in -99999 the program quit. I also need to display the sum of numbers enter into the … | |
Hi I get the following errors when I changed something - I don't know what, but these occur now. Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError at sun.awt.Win32GraphicsConfig.getBounds(Native Method) at sun.awt.Win32GraphicsConfig.getBounds(Win32GraphicsConfig.java:240) at java.awt.Window.init(Window.java:368) at java.awt.Window.<init>(Window.java:407) at java.awt.Frame.<init>(Frame.java:402) at java.awt.Frame.<init>(Frame.java:367) at javax.swing.JFrame.<init>(JFrame.java:163) at ExitJoke.<init>(ExitJoke.java:22) at ExitJoke.<init>(ExitJoke.java:43) <-- Keeps repeating itself over and over … | |
[CODE] import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class EmployeeEntry extends JFrame implements ActionListener, KeyListener,ItemListener { JTextField id, last,first,mi,age,branch,hours,pay,items,rate; JRadioButton male,female; JComboBox emptype; JButton add,delete, back; JPanel p1,p2,p3,p4,p5,p6,p7; JPanel p1_1,p1_2, p2_1,p2_2, p3_1,p4_1, p4_2,p5_1,p5_2,p6_1,p6_2,p7_1; JLabel labelMessage; EmployeeList emplist=new EmployeeList(); Employee empH=new HourlyEmployee(); Employee empP=new PieceWorker(); Employee [] employee; String … | |
Hello Guys, I'm trying to learn how to use the GridBagLayout manager... but when I write it like the following: [B]JPanel panel = new JPanel(new GridBagLayout());[/B], Java tells me the following: [U]cannot find symbol symbol: constructor JPanel(gridbaglayout.GridBagLayout) location: class.javax.swing.JPanel.[/U] When this didn't work, I tried type casting [B]JPanel panel = … | |
In my program when i close the save file chooser it opens another one ??? heres the code [CODE] import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import java.awt.*; import java.awt.event.*; import java.io.*; public class JB extends JPanel implements ActionListener{ protected JTextArea textArea; public JB() { setLayout(new BorderLayout()); JTextArea textArea = new JTextArea(); textArea.setFont(new … | |
Hello there, I'm trying on Gui exercises. One of them requires a simple GUI class for Vehicle. The GUI should have buttons for creating new SportsCar and new Van objects. and then should display the values of the instance variables of these variables. The GUI should also calculate and display … | |
I'm very new to Java 4 1/2 weeks into my intro to java, I have to write a program that asks user for an integer, the program will then add up all integers from 1 to N and display output message the sum of integers from 1 through (integer input … | |
Hi I was looking help with a null pointer error I get everytime I use my newgame button or start the newgame method. What the game should do is guess 1-1000 then change the screen when the user's guess is too low , too high, and correct. Once the user … | |
[code]import java.awt.*; import javax.swing.*; public class image extends JFrame{ JButton b1; ImageIcon im; Container c=getContentPane(); public image() { im=new ImageIcon("Pictures/sad.jpg"); b1=new JButton(" ",im); c.setLayout(new FlowLayout()); add(b1); setSize(500,500); show(); } public static void main(String [] args) { new image(); } }[/code] | |
I am trying to pass an object as parameter to another class wich contains a SQL connection: Base class is a swing class where this method is the essential to know for my question: [CODE] public void actionPerformed(ActionEvent e) { ModelNY mo = new ModelNY(); mo.setPersonID(txtField1.getText()); mo.setFName(txtField2.getText()); mo.setLName(txtField3.getText()); mo.setAdress(txtField4.getText()); mo.setEmail(txtField5.getText()); … | |
I am having a problem with the below applet. It compiles just fine and when it is ran it shows up with the multiplication problem at the bottom of the applet as expected. The problem is that it says if the answer is correct or not before an answer is … | |
Hello! I'm currently working on a sort of simple imperial-to-metric converter application for myself, but I seem to have hit a snag. I've got the UI built, and the logic for one of the calculations built, but the button to make it all happen is giving me a problem. [CODE]import … | |
Hi! Basically what im trying to do is to add a JPanel onto another JPanel that has painted graphics on it using the paintComponent() method. But the JPanel I am trying to add is not shown because it is covered up by the JPanel w/ Graphics on it. How can … | |
Hey, I have completed my code for Java and I have to put it in GUI, problem is I dont know a thing about GUI or if my program works correctly with it or not. Here is my code and what the code does is you type in random numbers … | |
Hello everyone- I'm currently working on a GUI solution for a school assignment which creates a tabbed window with only the 'Pool' tab actually populated. I have successfully created all of the labels, textfields and buttons for the 'pool' pane, but I am really struggling with setting up the listener … | |
Hi!. Well, we have an assignment, and we will make a program in which I will be selecting a subject from the JComboBox, and when I have my selected subject. It will appear in the Text Field below the Combo Box. any ideas? //not the codes :) [CODE]import java.awt.*; import … | |
I need used one button to change the state of the light, and the light should have green, amber, and red lights and cycle through green -> amber -> red -> green each time the button is pressed. My code [CODE]import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics; import java.awt.event.ActionEvent; … | |
How can i run my Subclass where my GUI code are written from my Main Class?What codes should i write in my main class??Here are my codes: Main Class: my main class is blank because i really dont know what to write. [CODE] */ package classpkg; /** * * @author … | |
I don't know why but nothing is appearing? I suppose to have a applet of a house. [CODE]import javax.swing.*; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.*; import java.applet.Applet; import java.awt.Graphics; public class color extends JApplet { public void init() { addMouseListener(new MyMouseListener()); getContentPane().setBackground(Color.white); } public class MyMouseListener implements MouseListener … | |
Hi all, I am new to java swing programming.I want to develop an application which has a panel with an array of grid points(not grid cells). The number of columns and rows of the grid points must be user specific. Once such an environment is created, the user's mouse click … | |
ahmmm i have a few problem in my java game... my game is a quiz game..can u help me? .. or track it? heres my code... [CODE] package Games; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class QandASample extends JWindow implements ActionListener { JWindow window = new JWindow(); JFrame que1 … | |
I want the program to draw the key that is pressed on the screen. When I press a key, nothing happens. Class where the draw code is: [CODE]/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package lab5; import java.awt.Color; … | |
Hey, this is the first program I've tried writing using any GUI and I have gotten everything so far, except every time I click my button to try and run my program it just freezes and does not do anything. import javax.swing.*; import BreezySwing.*; public class piGUI extends GBFrame{ private … | |
My homework is Write an applet that draw the house shown on the left in Figure 14-32. When the user clicks on the door or windows, they should close. The figure on the right shows the house with its door and windows closed. I basic want a java applet that … | |
I want in java applet if a user clicks on a rectangle another one is draw. [CODE]import javax.swing.; import java.awt.; import java.awt.event.*; public class stuff extends JApplet { public void paint(Graphics g) { super.paint(g); g.drawRect(40, 40, 200, 200); if(g.isSelected()) { g.drawRect(20, 20, 50, 50); } } }[/CODE] | |
I don't know why. At all. Just that it won't repaint! My code: [CODE]import java.awt.Graphics; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JFrame; import javax.swing.JPanel; @SuppressWarnings("serial") public class Frame extends JFrame implements KeyListener{ JPanel content; int W = 200; int H = 200; public Frame(){ setSize(700,250); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setResizable(false); content = new JPanel(); … | |
Hello everybody I have a problem with my code. On two lines (14 & 17) I get this error: cannot return a value from method whose result type is void. But I don't have add void to my class. Thanks in advance. Greets MeandJava Here's my code: [CODE]package oop_po2; import … | |
Hi, I've got a basic javax.swing.Timer that I use to repeat itself to darken an image over and over again. This should give a fade out effect for the image however the delay on this is set to 0010 which should be so quick however it takes half a second. … | |
I am having some trouble with my Java program. I completed a PoolVolume class project and am trying to add a login and password page before the PoolVolume class starts. I completed the login and password script but can not get the login page to access the next class page. … | |
[ICODE] here's my code below and i cant seem to find out how to return to public static void main after selecting yes in the dialog box. this cud be a very damn question however i get confuse about how to resolve this. thanks. by the way, this program is … | |
Hello! I am trying to finish this Recursive multiplication program and I am stuck. What I need to do is write a recursive function that accepts two arguments into the parameters x and y. The function should return the value of x times y. I used this program from the … | |
when ever i try to compile/run my game in eclipse it says this [QUOTE]Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at OurGame.Board.checkCollisions(Board.java:78) at OurGame.Board.actionPerformed(Board.java:40) at javax.swing.Timer.fireActionPerformed(Unknown Source) at javax.swing.Timer$DoPostEvent.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at … | |
Hello Lovely People, Please have a look at my GUI first, before reading the rest (I've attached a picture, see at the end of my post). I'm having two problem with this GUI. 1) I don't want my Start button to be as long as it is. I want it … | |
okay so I have an array of buttons, and at some point in the program I want to access the index of a button clicked in order to perform some calculations....so there are two options that I can think of...maybe there is a method to pull out the index (2d … | |
Hello, I have two classes, Help and RecylingGui. I have a button on the RecyclingGui called Help, which when clicked should open the text area created in the Help class. I added the ActionListener for this but nothing is happening. Any help would be appreciated. Thanks. The Code: Recycling Class … | |
My friend and I are in a Computer Science I class, and we are momentarily working on a project which asks you to import a method from a previously edited source, into another java source file. Here is our code. [CODE]import java.awt.Graphics; import java.awt.Color; import java.awt.Image; import java.awt.Container; import javax.swing.JFrame; … | |
I am trying to compile my simple java code and receive two errors. Any help will be appreciated. 1. Java1_Week2.java:19: illegal start of expression public Java1_Week2() { 2. Java1_Week2.java:19: ';' expected public Java1_Week2(){ Here is my code: [CODE]import java.text.DecimalFormat; import javax.swing.*; public class Java1_Week2 { public static void main(String[] args) … | |
Okey now the problem is that if the previewFrame is set to the default layout the buttons show but since it is using a layout manager the setBounds,setLocation,setSize commands dont work. So I used the code previewFrame.setLoayout(null) which would let me set my own position of the buttons on the … | |
I started developing an HTML editor using Java. After spending a lot of time I am now stuck in between. Most of the things are done but now I don't find any way to implement some of very important features. [B]I think[/B] java is too weak too support these features. … | |
please help me import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.net.*; import javax.swing.border.*; /** * Summary description for userlogin * */ public class userlogin extends JFrame { public static ServerSocket ssoc1; public static Socket sousoc1,ss1; // Variables declaration private JLabel userlabel; private JLabel jLabel2; private JLabel jLabel3; private JLabel jLabel4; … | |
Hi, I have this really important project where in, I must perform the following tasks. VIEW - view records that are present in the database using a "primary key" ADD - add new records to the database EDIT - a specific line in the said record within the database [INDENT]Under … | |
I'm currently working on a tic-tac-toe program and it is working to the point that it runs and X's and O's appear. However when the right combination is made or the board gets full the method "Resultat();" should recognize it and "Clear();" should clear out the board and a JFrame … | |
[ICODE] import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MainFrame extends JFrame{ JMenuBar main=new JMenuBar(); JMenu menu1=new JMenu("File"); JMenu menu2=new JMenu("Search"); JMenu menu3=new JMenu("Display"); JMenu menu4=new JMenu("About"); JMenuItem exit=new JMenuItem("Exit"); JMenuItem pw=new JMenuItem("Piece Worker"); JMenuItem hw=new JMenuItem("Hourly Employee"); JMenuItem pcw=new JMenuItem("Piece Worker"); JMenuItem hrly=new JMenuItem("Hourly Worker"); JMenuItem author=new JMenuItem("Author"); JLabel … | |
'Lo everyone, I am having some pretty frustrating issues that I can not seem to get rid of. The main goal of my program is to make a GUI with buttons that trigger custom events. [quote] C:\Java Tests>javac JGUITest.java JGUITest.java:13: cannot find symbol symbol : class ButtonHandler location: class LabelFrame … | |
I feel like I'm really close... I'm supposed to have some other things configured and use JOptionPane... but I can't get the numbers to output correctly... [CODE]import javax.swing.JOptionPane; public class M3_2E5 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //declare variables … |
The End.