Labels
ionic
(40)
Google Apps Script
(28)
Construct2
(6)
Google API
(5)
Google Cloud
(5)
Java
(5)
presentation
(5)
jasper
(4)
plunker
(4)
Notepad++
(2)
liferay
(2)
ms access
(2)
mysql
(2)
PHP
(1)
SQLite
(1)
android
(1)
blogspot
(1)
html5
(1)
ionic-creator
(1)
javascript
(1)
mobile
(1)
plainjs
(1)
utilties
(1)
Learn the powerful enterprise adaptable database:
Getting Started With ADABAS & Natural
Tuesday, May 14, 2013
Sunday, May 12, 2013
Java Swing tutorial
-----
-----
http://zetcode.com/tutorials/javaswingtutorial/
Java Swing tutorial
This is a Java Swing tutorial. The Java Swing tutorial is suited for beginners and intermediate Swing developers. After reading this tutorial, you will be able to develop non-trivial Java Swing applications.
Table of contents
- Introduction
- First Programs
- Menus and Toolbars
- Swing Layout Management
- Swing Events
- Swing Dialogs
- Basic Swing Components
- Basic Swing Components II
- Swing models
- Drag and Drop
- Painting
- Resizable component
- Puzzle
- Tetris
Swing
Swing is a principal GUI toolkit for the Java programming language. It is a part of the JFC (Java Foundation Classes), which is an API for providing a graphical user interface for Java programs. It is completely written in Java.
-----
http://zetcode.com/tutorials/javaswingtutorial/
Java SE Basic Input Form Save To Text File
-----
-----
from: http://www.java-forums.org/awt-swing/28591-create-form-input-some-data-save-file.html
import java.awt.GridLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.BufferedWriter;import java.io.FileWriter;import java.io.FileNotFoundException;import java.io.IOException;import java.io.File;import javax.swing.JLabel;import javax.swing.JDialog;import javax.swing.JFrame;import javax.swing.JPanel;import javax.swing.JButton;import javax.swing.JTextField;import javax.swing.SwingUtilities;public class OpenningForm { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { BasicForm frame = new BasicForm("Basic Frame"); frame.createGUI(); } }); }}class BasicForm extends JFrame { public BasicForm(String name) { setTitle(name); BasicPanel panel = new BasicPanel(); add(panel); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(300,300); } public void createGUI() { setVisible(true); }}class BasicPanel extends JPanel { public BasicPanel() { JButton button = new JButton("New..."); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { InputDialog inputForm = new InputDialog(); inputForm.setVisible(true); } }); add(button); }}class InputDialog extends JDialog { public InputDialog() { InputPanel panel = new InputPanel(); setTitle("Input Dialog"); add(panel); setSize(200,150); setLocationRelativeTo(null); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setVisible(false); }}class InputPanel extends JPanel { JTextField firstNameField; JTextField secondNameField; JTextField phoneNumber; public InputPanel() { GridLayout gridLayout = new GridLayout(4,2); setLayout(gridLayout); firstNameField = new JTextField(20); secondNameField = new JTextField(20); phoneNumber = new JTextField(15); JLabel firstNameLabel = new JLabel("First name: "); JLabel secondNameLabel = new JLabel("Second name: "); JLabel phoneNumberLabel = new JLabel("Phone number: "); JButton saveToFileButton = new JButton("Save to file"); saveToFileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { BufferedWriter writer; try { //File file = new File("contacts.txt"); writer = new BufferedWriter(new FileWriter("contacts.txt",true)); writer.write(firstNameField.getText() + "\t" + secondNameField.getText() + "\t" + phoneNumber.getText()); writer.newLine(); writer.close(); } catch(FileNotFoundException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } } }); add(firstNameLabel); add(firstNameField); add(secondNameLabel); add(secondNameField); add(phoneNumberLabel); add(phoneNumber); add(saveToFileButton); } }-----
from: http://www.java-forums.org/awt-swing/28591-create-form-input-some-data-save-file.html
Subscribe to:
Comments (Atom)