473,503 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

create buttons with jpanel

59 New Member
i can some one help me with jframe and panel. i want to create button using jpanel. i look online but they seem to have different ways to do it and i have no idea which is the best way to do this. ex some people extends jframe at top. other create jframe j = new jframe in main etc...

This is what iam trying to do. dont worry about my logic here. this is just so i can understand how to extends etc....
**
main.java will call aaaa.java.
aaaa.java will call bbbb.java
bbbb.java will create one button and that button will have a actionlistener.
**


Expand|Select|Wrap|Line Numbers
  1.     public class Main extends JFrame{
  2.  
  3.         public Main() {
  4.             // TODO Auto-generated constructor stub
  5.         }
  6.  
  7.         public static void main(String[] args){
  8.             aaaa a = new aaaa(); //??
  9.         }
  10.     }
  11.  
  12.  
  13.  
  14.  
  15.     public class aaaa extends JFrame{    //???
  16.  
  17.         public aaaa() {
  18.             bbbb b = new bbbb(); //??
  19.         }
  20.     }
  21.  
  22.  
  23.  
  24.  
  25.  
  26.     public class bbbb implements ActionListener{  //????
  27.  
  28.         JButton b1 = new JButton("check here");
  29.  
  30.         public bbbb() {
  31.             //??
  32.         }
  33.  
  34.  
  35.     public void actionPerformed(ActionEvent e) {
  36.  
  37.     }
  38.     }
  39.  
  40.  
Jun 5 '13 #1
1 1760
r035198x
13,262 MVP
You rarely need to extend JFrame. Most code that extends JFrame does so for bad reasons.
You can read more general swing tips here: http://bytes.com/topic/java/insights...ng-swing-right
Jun 11 '13 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
6617
by: Ralph Freshour | last post by:
Is it possible to inhibit the browser Back/Fwd buttons via PHP? Thanks...
4
422
by: Bob Lehmann | last post by:
Hi, I pretty sure I've seen this problem addressed before, but I can't find any references. The short story is that I have I have multiple submit buttons on a page, each providing different...
2
2418
by: Aravind | last post by:
Hi folks. I have a form, frmHistory, which has 4 command buttons: Sort Title (cmdSortTitle), Sort Name (cmdSortName), Due Today (cmdDueToday), and Due List (cmdDueList). Sort Title and Sort...
5
5031
by: Lyn | last post by:
Hi, I hope someone can help. I have a main form which mostly fills the Access window. In the bottom half of this form I have a tab control to display various types of data related to the main...
0
8746
Denburt
by: Denburt | last post by:
This code is for a Toggle Button layout on a form, with this code you can set a number of toggle buttons visible and have multiple submenus that will stay hidden when not in use. My main menu is set...
4
1407
by: Ron | last post by:
I want to create 10 buttons on a form at runtime, the code below is only creating one button labeled 1. Any idea what I am doing wrong? Public Class Form1 Public code(10) As String Public...
3
1509
by: Ron | last post by:
Can anyone help me out? I am trying to add buttons numbered one through 10 at runtime to a form. I think they are getting added but they seem to be getting stacked one on top of each other. so...
2
5877
by: dpazza | last post by:
Hi, I'm creating a quiz on using a form in VB 2005 express. I have four sets of questions and answers (labels and radio buttons) and I change between which set of questions is currently shown on...
4
2504
by: Blasting Cap | last post by:
I have a page that has a number of radio buttons that will be displayed to different access levels of a user who logs in to my website. For instance, if there are a dozen buttons, user1 will see...
2
2176
by: remya1000 | last post by:
hai i'm using Vb.net. i'm creating 64 dynamic created buttons of 8 rows and 8 columns. And i have 1 Go button, 1 textbox. those were created dynamically. if i enter one number inside textbox and...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7093
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.