473,657 Members | 2,499 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 1765
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
6622
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 functionality. For example, I have a search option, a log in option and a save text option. I would like to handle the submits in the Click event of each button. the
2
2428
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 Name uses VBA code, and sorts the form either ascending or descending, by title and by name respectively. Due Today and Due List uses macros, and filters the form to display
5
5049
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 form record. In each page of the tab control, there are three buttons: Add, Update, Delete. Any of these buttons will open another, smaller form to add, update or delete the related data record. Originally, I had placed the smaller form such...
0
8765
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 up with this code and the way I set it up the first button is my search toggle button no submenu (this prevents a submenu from displaying when the form is first opened) TabIndex set to 0 (I like using the keyboard) the second toggle button is called...
4
1409
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 buttons(10) As Button Const buttonwh As Integer = 30 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
3
1516
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 I only see 1, and not the others. here is what I am doing can anyone tell me what I am doing wrong? Public Class Form1 Public buttons(9) As Button
2
5887
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 the form by changing the visible state of the radio buttons and labels utilising back and next buttons. E.g. Next button makes current radio buttons and labels invisible and
4
2512
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 all twelve. User2 would see buttons 1-3,10-12 and NOT any others, and so on. Since there are several buttons on the page (each one would run a report for them), is there a way to - in an onclick event for each of the buttons - to...
2
2197
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 hit Go Button, then it checks corresponding Database and display buttons on page. and inside Database i have a field called Item, that tells the button number to display. for eg: if Database1 contain items 0,10,20,50. then i need to display...
0
8397
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7333
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4158
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2731
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 we have to send another system
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.