Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners java GUI program

Have Programming Question? Ask it here!
 
 
 


lancau
java GUI program
1 Answer(s)      6 years ago
Posted in : Java Beginners



Advertisement
View Answers

August 25, 2008 at 4:25 PM


Hi friend,

import javax.swing.*;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComponent;


public class TextExampleDemo extends JPanel implements ActionListener {
protected JTextField textField;
protected JTextArea textArea;

private final static String newline = "\n";

public TextExampleDemo() {
super(new GridBagLayout());

textField = new JTextField(20);
textField.addActionListener(this);

textArea = new JTextArea(5, 20);
textArea.setEditable(false);
JScrollPane scrollPane = new JScrollPane(textArea,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

//Add Components to this panel.
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
add(textField, c);

c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0;
c.weighty = 1.0;
add(scrollPane, c);
}

public void actionPerformed(ActionEvent evt) {
String text = textField.getText();
textArea.append(text + newline);
textField.selectAll();
textArea.setCaretPosition(textArea.getDocument().getLength());
}

private static void createAndShowGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);

//Create and set up the window.
JFrame frame = new JFrame("Text display in textarea example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Create and set up the content pane.
JComponent newContentPane = new TextExampleDemo();
newContentPane.setOpaque(true); //content panes must be opaque
frame.setContentPane(newContentPane);
frame.setSize(300,300);
frame.setVisible(true);
}

public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
----------------------------------

Read for more information,

http://www.roseindia.net/java/

Thanks.

Amardeep


Related Tutorials/Questions & Answers:
java GUI program - Java Beginners
java GUI program  java program that creates the following GUI, when user enter data in the textfield, the input will be displayed in the textarea...://www.roseindia.net/java/ Thanks. Amardeep
Java GUI Program - Java Beginners
Java GUI Program  How is the following program supposed to be coded... by Day 7 under a thread in your Team Forum called Week Three Program for 10 points...://www.roseindia.net/java/ Thanks. Amardeep
Advertisements
Writing a GUI program - Java Beginners
Writing a GUI program  Hello everyone! I'm trying to write a program... if that number is prime or not. When the second button is pressed the program... to write the code for the GUI. Could anyone please help?  Hi Friend
Java gui program for drawing rectangle and circle
Java gui program for drawing rectangle and circle   how to write java gui program for drawing rectangle and circle? there shoud be circle.... and the program must also show message dialog "this is a red circle" when click
GUI convert to celsius program - Java Beginners
GUI convert to celsius program  how to write java GUI program... information on Swing Examples visit to : http://www.roseindia.net/java/example/java/swing/ Thanks
Java GUI to build a Student Registration Program
Java GUI to build a Student Registration Program   Write a program... in sorted order by last name. Demonstrate the correct operation of your program by creating a driver program to load the student data base and the course data
GUI application program
GUI application program  Write a GUI application program that meets the following requirements: Create an array with 100 randomly chosen integers. Create a textfield to enter an array index and another textfield to display
java gui
java gui   friends... good day.. i have doubt in java gui. ? i created 1 java gui application. That has two text fields jtext1,jtext2. case: user entered value in first textfield(jtext1) and pressed the enter key . the cursor
Java GUI
Java GUI  1) Using Java GUI, create a rectangular box that changes color each time a user click a change color button. 2) Modify Question 1 to include a new button named insert image, that allow user to insert a bitmap image
Java GUI
Java GUI  difference between swing and applet
How can I write a GUI stack program by Java to push Image files instead of other data type items?
How can I write a GUI stack program by Java to push Image files instead of other data type items?   How can I write a GUI stack program by Java to push Image files instead of other data type items? for the push instruction I
Java GUI - Java Beginners
Java GUI  HOW TO ADD ICONS IN JAVA GUI PROGRAMMES
java gui-with jscroll pane
java gui-with jscroll pane  Dear friends.. I have a doubt in my gui... the window manually.....but i need this through my program...How can i show that text feilds through my program.... some one please help me.... Thanks in advance
java gui-with jscroll pane
java gui-with jscroll pane  Dear friends.. I have a doubt in my gui... the window manually.....but i need this through my program...How can i show that text feilds through my program.... some one please help me.... Thanks in advance
GUI problem - Java Beginners
GUI problem  how to write java program that use JTextField to input data and JTextField to display the output when user click Display Button??  Handle the actionPerformed event for JButton and try doing something like
Java GUI - Java3D
Java GUI  1) Using Java GUI, create a rectangular box that changes color each time a user click a change color button. 2) Modify Question 1 to include a new button named insert image, that allow user to insert a bitmap image
Java GUI code
Java GUI code  Write a GUI program to compute the amount of a certificate of deposit on maturity. The sample data follows: Amount deposited: 80000.00 Years: 15 Interest rate: 7.75 Total Amount: Hint** to solve this problem
Java: Basic GUI
Java NotesBasic GUI Next - Big Blob This first example just shows what... program 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 // structure/CalcV1.java // Fred Swartz - December 2004 // GUI
Java Gui - Java Beginners
Java Gui  HOW TO ADD LINK LABELS IN JAVA PROGRAMMES
GUI 2 - Java Beginners
GUI 2  How can I modify this code? Please give me a GUI...;GUI Example");pack();show();}public void actionPerformed(ActionEvent event... world and like it alot. I was wondering where can I go to learn more about java
GUI Interface - Java Beginners
GUI Interface  Respected sir, please send me the codimg of basic... and multiplication. But use classes javax swing java awt java awt.event no other... calculator program."); class CalcGUI extends JFrame { private final Font BIGGER
Java GUI - Java Beginners
Java GUI  How to use JTray in java programme?  Hi friend, JTrayIcon jtc= new JTrayIcon(image); // jPopupMenu is a javax.swing.JPopupMenu jtc.setRightClickTarget(jPopupMenu); jtc.show(); Thanks
Java scroll pane-java GUI
Java scroll pane-java GUI  Dear friends.. Very Good morning. I have a doubt in my gui application. Take ex:- My gui application has 1 Jscrollpane... my program.... Thanks dears in advance
Chat in Java wih GUI
Chat in Java wih GUI  Welcome all >> << how is everybody >< i wanna Chat program in java server & client thanks
java gui - Java Beginners
java gui  i have to create dynamically databse,table, and number of field..inside that field dynamically data can be entered with type of variable..after entering all the dat in different form field label,i should have a button
Java GUI - Applet
Java GUI  HELLO, i am working on java chat server, i add JFrame and make GUI structure by draging buttons and labels, now i want to insert... but not resolve my prob. dear friend, i add JFrame Form in java package and put
GUI
GUI  How to GUI in Net-beans ... ??   Please visit the following link: http://www.roseindia.net/java/java-tips/background/30java_tools/netbeans.shtml
Gui Interface - Java Beginners
Gui Interface  hi I have two seperate interfaces in the same projects . my question is how can I access this interface using a jbutton (i.e jbutton = next where next points to another interface addCourse.java) What would
GUI - Java Beginners
GUI testing  GUI testing in software testing  HiNow, use the code and get the answer.import javax.swing.*;public class DemoTryCatchDialog...;GUI Example");pack();show();}public void actionPerformed(ActionEvent event
java gui database - Java Beginners
java gui database  I have eight files. Each file has exactly same... the data on command line but I do not know how to display the same using java gui. Could anybody help me. Thanks. Shah
GUI - Java Beginners
links: http://www.roseindia.net/tutorial/java/swing/navigatedata.html http://www.roseindia.net/java/example/java/swing/add_edit_and_delete_employee_inf.shtml
Component gui - Java Beginners
Component gui  Can you give me an example of Dialog in java Graphical user interface?  Hi friend, import javax.swing.*; public...://www.roseindia.net/java/example/java/swing/ Thanks
Java GUI problem with linklists and administration - Java Beginners
Java GUI problem with linklists and administration  Hi, I'm having trouble making a GUI interface in java, where a list of names are displayed using a jList. The java program should be able to allow the user to add names, remove
Java GUI code- creating a circle
Java GUI code- creating a circle  My assignment is to write a program... is (x,y)(x2,y2). The program should then output the circle's radius, circumference...; //GUI components JLabel lClx, lCly, lCircumrx, lCircumry, lRadius
Java GUI IndexOf - Java Beginners
Java GUI IndexOf  Hello and thank you for having this great site. Here is my problem. Write a Java GUI application called Index.java that inputs several lines of text and a search character and uses String method indexOf
MultiClient-server tcp-ip with GUI in java
MultiClient-server tcp-ip with GUI in java  i wanna MultiClient-server tcp-ip with GUI in java
MultiClient-server tcp-ip with GUI in java
MultiClient-server tcp-ip with GUI in java  i wanna MultiClient-server tcp-ip with GUI in java
GUI testing/software testing - Java Beginners
GUI testing/software testing  how to create a GUI testing/software testing module in java
Rental Code GUI - Java Beginners
Rental Code GUI  dear sir... i would like to ask some code of java GUI form that ask the user will choose the menu to input Disk #: type: title: record company: price: director: no. of copies
How to convert this Java code into GUI?
How to convert this Java code into GUI?   import java.util.Scanner; public class StudentMarks { double totalMarks; String grade; public void setTotalMarks(double totalMarks) { this.totalMarks = totalMarks
Convert this code to GUI - Java Beginners
Convert this code to GUI  I have written this.i need to convert the following code to GUI:- import java.awt.*; import java.applet.*; import...); } }  hi friend, We have convert your code into GUI
turn the GUI(java class) into XML - XML
turn the GUI(java class) into XML   Hi im trying to turn the GUI(java class) into XML ,means in my gui one combobox is there if i select one... GUI that combobox contains different types of maps.If i select one map name
how to save a gui form in core java
how to save a gui form in core java  please help me i am java beginner how to save a jframe containing jtable and panels in java thank you
Accessing Ms access data in JAVA GUI Envi.
Accessing Ms access data in JAVA GUI Envi.  Q.How to insert data into ms access data in java using swing ? Q.How to slove (access denided ("java.lang.RuntimePermission" "accessClassInPackage.sun.jdbc.odbc")" these exception
Catching Exceptions in GUI Code - Java Tutorials
.style1 { text-align: center; } Catching uncaught exception in GUI In this section, we will discuss how to catch uncaught exceptions in GUI. Lets see... javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; public class Gui
java program
java program  Write a program that computes loan payments. The loan can be a car loan, a student loan, or a home mortgage loan. The program lets... the monthly and total payments. (using GUI input) use (import javax.swing.JOptionPane
Programming - Transform Name - GUI 0
Java: Programming - Transform Name - GUI 0 Write a GUI program to redisplay a name, possibly transformed. This Java program will reformat a user's name... be good extra credit for this program. You can easily use the Java functions
GUI Alternatives
, it isn't difficult to build a Graphical User Interface (GUI) in Java, but it is hard... to use the Java GUI libraries to build your GUI. There are alternatives... your interface be in Java? You can use existing GUI technologies like Flash
java program - Java Beginners
java program   1.java program to Develop a multi-threaded GUI application of your choice. 2.program to Develop a template for linked-list class along with its methods in Java
Login Form with Java GUI using Netbeans
Login Form with Java GUI using Netbeans  Hi there! I'm a beginner in Java. I've created 2 class files: 1) TestAssign.java 2) NewFrame.java How can I have different user to login? Now that I've only administrator who is able
Advertisements
 

 

 

DMCA.com