suved
about swing
2 Answer(s)      4 years and 10 months ago
Posted in : Java Beginners

View Answers

August 25, 2008 at 3:26 PM


this is the logic for addition of two numbers
public class AddNumbers{
public static void main(String[] args) {
System.out.println("Addition of two numbers!");
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
int sum = a + b;
System.out.println("Sum: " + sum);
}
}

August 27, 2008 at 4:28 PM


Hi friend,

import javax.swing.*;
import java.awt.*;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

class AddTwoNumber extends JDialog {
public AddTwoNumber(JFrame parent) {
super(parent, "Add two number", true);
int x = 10;
int y = 20;
int num = x + y;
System.out.println("num:" + num);
Container cp = getContentPane();
cp.setLayout(new FlowLayout());
cp.add(new JLabel("Add two number is: " + num));
JButton ok = new JButton("OK");
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
cp.add(ok);
setSize(300, 150);
}
}

public class AddNumber extends JApplet {
private JButton jb = new JButton("Click Me");

private AddTwoNumber dlg = new AddTwoNumber(null);

public void init(){
jb.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dlg.show();
}
});
getContentPane().add(jb);
}

public static void main(String[] args) {
Save(new AddNumber(), 300, 200);
}

public static void Save(JApplet applet, int width, int height) {
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(applet);
frame.setSize(width, height);
applet.init();
applet.start();
frame.setVisible(true);
}
}

---------------------------

Thanks.









Related Pages:
About jcombobox - Swing AWT
About jcombobox  Hi all, I am new to this forum. Can we do auto suggest jcombobox in swing? If yes is there any jar file for that or any code if you have. Thanks in advance.   Hi Friend, Try the following code
about swing - Java Beginners
about swing  how implement a program of adding two numbers by entering two numbers separately by other user on the input dialog box and after that also show the result of the addition in other dialog box... your regardly
about java swing - Java Beginners
about java swing   How to upload the pictures and photo on the panel in java swing ,plz help thank a lot.  Hi Friend, Try the following code: import java.awt.*; import java.io.*; import javax.swing.*; import
about java swing - Java Beginners
about java swing   How to send date in data base if i use the combobox like as dd,mm,yyyy. plz reply thanx a lot  Hi Friend, Try the following code: import java.sql.*; import java.awt.*; import javax.swing.
ABOUT Jtable
ABOUT Jtable  My Project is Exsice Management in java swing Desktop Application. I M Use Netbeans & Mysql . How can retrive Data in Jtable from Mysql Database in Net Beans
Sitemap Java Swing Tutorial
Home | About-us | Contact Us | Advertisement | Ask Questions | Site...-to-One Relationship | JPA-QL Queries Java Swing Tutorial Section Java Swing Introduction | Java 2D API | Data Transfer in Java Swing
SWING
SWING  A JAVA CODE OF MOVING TRAIN IN SWING
How to convert a swing form to PDF
How to convert a swing form to PDF  Sir, I want to know about how convert a swing form containing textbox,JTable,JPanel,JLabel, Seperator etc swing menus to a PDF file using java code
swing
swing  Write a java swing program to delete a selected record from a table
swing
swing  How to make swing component auto-resizable when JFrame resize
Swing Applet Example in java
Java - Swing Applet Example in java       Introduction In this section we will show you about using swing in an applet. In this example, you will see that how resources of swing
Swing
Swing  Write a java swing program to search the details of the students. Searching is performed on studentā??s first name. The details of all those students having same name as in given in searching criterion will be displayed
Swing
Swing  Write a java swing program to search the details of the students. Searching is performed on studentā??s first name. The details of all those students having same name as in given in searching criterion will be displayed
about swings - Java Beginners
about swings   Dear sir,Good evening, i am doing mca sir,i am doing the project in swings,so plz provide the material about swings sir...: http://www.roseindia.net/java/example/java/swing/ Hope
computer - Swing AWT
computer  What is a Computer and why we should use it? I am new to this technologies so please let me know the benefits of using computer.   What you what to know about computers?Is it a software or hardware related
What is Java Swing?
What is Java Swing?       Here, you will know about the Java swing. The Java Swing provides... and GUIs components. All Java Swing classes imports form the import
AutoSuggestion Box in Java Swing
Auto Suggestion Box in Java Swing In this section, you will learn how to create autosuggestion/autocomplete box in java swing. For this, we have created combo box and add array of countries using DefaultComboBoxModel to it. Now
java swing problem - Java Beginners
java swing problem  i doesn't know about the panel in swings here i had created one frame then created a panel and i added that to my frame but which is not adding any item and it not showing that item on the panel tell me how
How to save data - Swing AWT
How to save data  Hi, I have a problem about how to save data...); frame.setVisible(true); } } For more information on Swing visit to : http://www.roseindia.net/java/example/java/swing/ Thanks
JAVA SWING JTabbedPane - Java Beginners
JAVA SWING JTabbedPane  Hi all, I would like to ask a question about how to place a tab in JTabbedPane in the middle rather than from left to right order. Many thanks. Jun   Hi friend
Java Swing Tutorials
swing? Here, you will know about the Java swing. The Java Swing provides... In Java In this section, you will learn about the event handling for a swing... Java Swing Tutorials      
Loading Manifest File - Swing AWT
file is not loading and main class is not read.Please help me about
Progress Bar in Java Swing
Progress Bar in Java Swing     ... in java swing. This section shows you how the progress bar starts and stops.... The label display the information about the Downloading process whether completed
Changing Look and Feel of Swing Application
Changing Look and Feel of Swing Application  ... and feel for your Swing Application. The look and feel feature of Java Swing provides more interactivity of the frame for user application. Swing allows
Java Swing Set And Get Values
Java Swing Set And Get Values In this tutorial we will learn about how to set... methods in swing. This example is about showing the address of a person in two... to use setter and getter method in Java Swing. Example Here I am giving
java swing - Swing AWT
java swing  how i can insert multiple cive me exampleolumn and row in one JList in swing?plz g  Hi Friend, Please clarify your question. Thanks
swing-awt - Swing AWT
swing-awt  Hi, Thanks for replying to my question...I'm getting some confusion to add action events in my application(Rich Text Editor).How to add action events? Thank U
swing/awt - Swing AWT
swing/awt  How to create richtexteditor using swings...?I'm very much new to swings....It's urgent.....Thank u...   hello read this book you get idea; JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second
Swing paint - Swing AWT
Swing paint  hi, i want to print something on window using swing applet.. m doing dis.. protected void paintComponent(Graphics g... the Swing Applet, use html file with the following code: Java Applet Demo
swing sms
swing sms  HOW TO SEND SMS MESSAGE FROM SWING USING SQL DATABASE
Swing Program
Swing Program  Write a java swing program to calculate the age from given date of birth
SWING FRMES
SWING FRMES  hai SIR? HOW TO DESIGN swing Frames send source code
SWING FRMES
SWING FRMES  hai SIR? HOW TO DESIGN swing Frames send source code
Jigloo SWT/Swing GUI Builder
Jigloo SWT/Swing GUI Builder   ... both Swing and SWT GUI classes. Jigloo creates and manages code for all the parts of Swing or SWT GUIs as well as code to handle events, and shows you
java swing - Swing AWT
java swing  how to add image in JPanel in Swing?  Hi Friend, Try the following code: import java.awt.*; import java.awt.image....: http://www.roseindia.net/java/example/java/swing/ Thanks
java swing - Swing AWT
java swing   how i can insert in JFrame in swing?  Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class FormDemo extends JFrame { JButton ADD; JPanel
GUI - Swing vs. AWT
Java: GUI - Swing vs. AWT The original graphical user interface (GUI... as Swing. Swing provides replacements for most of the AWT components, altho... in almost all cases; an AWT continues to work in Java. Must choose between Swing
SWING - Swing AWT
SWING  how can i insert image in Jpanel by extending class with JFrame in swing?  Hi Friend, Try the following code: import java.awt.*; import java.awt.image.*; import java.io.*; import javax.imageio.*; import
java swing - Swing AWT
java swing   Iam developing a java web browser.Actually my code works fine ie. i can load a web page without proxy.But in my place i have only proxy servers through which i should visit any web site.So, i want my browser also
Java swing
Java swing  Does Swing contains any heavy weight component
java swing
java swing  view the book details using swing
Java swing
Java swing  what are the root classes of all classes in swing
printing in swing
printing in swing  How can i print payslip in swing
Jva swing
Jva swing   How to create the model form like "Notepad
AWT & SWING
AWT & SWING  What is diffennce between AWT & SWING
swing program
swing program  Write a java swing program to getname and email id. Display the message if email id contains the name of theuser