Microsoft Internet Explorer 7 Logo

Related Topics:

Posted on Mar 10, 2009

About java swing..

How to make java program using swing?

1 Answer

Anonymous

Level 1:

An expert who has achieved level 1.

Mayor:

An expert whose answer got voted for 2 times.

Problem Solver:

An expert who has answered 5 questions.

  • Contributor 2 Answers
  • Posted on Mar 18, 2009
Anonymous
Contributor
Level 1:

An expert who has achieved level 1.

Mayor:

An expert whose answer got voted for 2 times.

Problem Solver:

An expert who has answered 5 questions.

Joined: Sep 13, 2008
Answers
2
Questions
2
Helped
5200
Points
6

Hi, if you have a specific query about java Swing, I can try to help you. Please find a small java code with using swing as example.

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JToolBar;
public class ToolbarDemo extends JFrame {
public static final String FontNames[] = { "Serif", "SansSerif", "Courier" };
protected Font fonts[];
protected JMenuItem[] fontMenus;
protected JToolBar toolBar;
public ToolbarDemo() {
super("Toolbars & actions");
setSize(450, 350);
JMenuBar menuBar = createMenuBar();
setJMenuBar(menuBar);
setVisible(true);
}
protected JMenuBar createMenuBar() {
final JMenuBar menuBar = new JMenuBar();
JMenu mFile = new JMenu("File");
ImageIcon iconNew = new ImageIcon("file_new.gif");
Action actionNew = new AbstractAction("New", iconNew) {
public void actionPerformed(ActionEvent e) {
System.out.println("new action");
}
};
JMenuItem item = mFile.add(actionNew);
mFile.add(item);
menuBar.add(mFile);
toolBar = new JToolBar();
JButton saveButton = new JButton("Save");
toolBar.add(saveButton);

getContentPane().add(toolBar, BorderLayout.NORTH);
return menuBar;
}
public static void main(String argv[]) {
new ToolbarDemo();
}
}
Thanks and Regards,
Supa.

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1helpful
1answer

Wirte a pogram in java using for loop,that will print out the first 1 numbers of a fibonacii series that is:1 1 2 3 5 13 21 34 55

package com.gpt;

import javax.swing.JOptionPane;

/*
This program computes Fibonacci numbers using a recursive
method.
*/
public class Fibonacci
{
public static void main(String[] args)
{
String input = JOptionPane.showInputDialog("Enter n: ");
int n = Integer.parseInt(input);

for (int i = 1; i {
int f = fib(i);
System.out.println("fib(" + i + ") = " + f);
}
System.exit(0);

}

/**
Computes a Fibonacci number.
@param n an integer
@return the nth Fibonacci number
*/
public static int fib(int n)
{
if (n return 1;
else
return fib(n - 1) + fib(n - 2);
}
}
0helpful
1answer

How to convert a Java Desktop application to Web-based?

1. No, it will take lots of code changes
2. Maybe
3. That depends on what its functions are
4. You may not have to convert it at all
5. Maybe, that's your choice
0helpful
1answer

Java coding to deduct virus

visual basic 6.0 plese example timer uses
4helpful
2answers

I want to know how various forms are interconnected

Here is an example of HTML And Javascript:

<HTML>
<HEADER>
<TITLE>Welcome To My Webpage</TITLE>
</HEADER>
<BODY>
<P><B><H1><U>Welcome To My Webpage</B><H1></U></P>
<script:"type/javascript">
alert("Welcome To My Webpage!");
</script>
</BODY>
</HTML>
0helpful
1answer

Table creation via textfields using swings

import java.lang.Object;
import javax.swing.table.DefaultTableModel;


public class tabletest extends javax.swing.JFrame {
String[][] row = null;
String[] title=new String[3];
private int i;


/** Creates new form tabletest */
public tabletest() {
initComponents();
setTitle("table test");
setVisible(true);
System.out.print("NO Database Needed");
title[0]="Name";
title[1]="Desig";
title[2]="id";
}


/*
" In middle of this two source one generated code will be there that will be done by dragging ur fields to ur frame. THIS IS FOR netbeans IDE "
*/

private void b1ActionPerformed(java.awt.event.ActionEvent evt) {
row=new String[4][3];
// TODO add your handling code here:

String s1=t1.getText();
System.out.println(" event 1");
String s2=t2.getText();
System.out.println(" event 2");
int k=Integer.parseInt(t3.getText());
String s3=""+k;
System.out.println(" event 3");
try{
// for(int i=0;i<=2;i++)
row[i][0]=s1;
row[i][1]=s2;
row[i][2]=s3;
i++;

}catch(Exception e){
e.printStackTrace();

}
table.setModel(new DefaultTableModel(row,title));
}

private void b2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:

t1.setText("");
t2.setText("");
t3.setText("");

}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new tabletest().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JButton b1;
private javax.swing.JButton b2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel l1;
private javax.swing.JLabel l2;
private javax.swing.JLabel l3;
private javax.swing.JPanel p2;
private javax.swing.JScrollPane scp1;
private javax.swing.JTextField t1;
private javax.swing.JTextField t2;
private javax.swing.JTextField t3;
private javax.swing.JTable table;
// End of variables declaration

}
0helpful
1answer

What is swing components?

Swing is java library that provides basic GUI controls [also called widgets like buttons, checkboxes, labels, menus, etc.. You can use it to create a interactive application with nice interface.

More info here http://en.wikipedia.org/wiki/Swing_(Java)
44helpful
2answers

Java project (core and advanced)

Hi I am Nitin Daharwal .. If you want make project in Java using Swing only. You may opt for these options 1. Java Image Viwer 2. Exam Simulator 3. Bulk E mail 4. Snake Game 5. Chatting Client 6.Inventory Mangement System you can mail at [email protected] for any help ..

Happy Programming!!!
2helpful
3answers

Java mini projects

Normaly using Searching Result moduls develop by OS

in this concept by using the own coding in JAVA Applet Programming with Swing using.
Not finding what you are looking for?

218 views

Ask a Question

Usually answered in minutes!

Top Microsoft Computers & Internet Experts

Grand Canyon Tech
Grand Canyon Tech

Level 3 Expert

3867 Answers

k24674

Level 3 Expert

8093 Answers

Brad Brown

Level 3 Expert

19187 Answers

Are you a Microsoft Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...