Swing textfield
Hi,
I created a simple program in Swing that displays a textfield. In IE, the program displays fine and I can type values into the textfield by first clicking on the textfield. However, in Netscape (both 4.7 and 6.2), the program displays fine but I cannot type anything into the textfield even after clicking on the textfield. In other words, the textfield is never getting the focus. Does anyone know why? I am using the Java plug-in.
Here is the simple code:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TextDemo extends JApplet{
public void init() {
JPanel topPanel = new JPanel();
topPanel.setLayout( new FlowLayout());
getContentPane().add(topPanel);
JTextField textField = new JTextField(20);
topPanel.add(textField);
}
Hi time83,
Just a guess, but did you try setting the visibility and enabling topPanel?
topPanel.setVisible(true);
topPanel.setEnabled(true);
Other than that, I'd think it was the plugin.
Regards,
Nick G.
Similar Messages
-
Text rendering in Java swing textfield is incorrect but works fine in awt
Hi
I am having a specific problem regarding
Malayalam Language (An indian language) rendering in Java swing textfield rendering is incorrect for some specific malayalam chars
റ്റ ട്ട
But for awt text filed every thing looks fine
Any clue regarding this issue
Pl help
John IndiaThank you
I too think in the same way , but I am trying with very popular malayalam fonts and
Windows 7 is works fine with default malayalam font karthika in apps like note pad ,word , iexplorerer
I tried a set of other fonts also some problem or other is with swt but
awt it works very nice
Is there any tool available to check all glyphs are , available or not ,
regards
john
Edited by: user3656685 on Jul 20, 2012 9:53 AM -
SWING TextField not displaying correctly
System: Unix
Java: 1.4.1_05
Is there any known issues with using Swing with Unix?
I tried to create TextFields of various widths but they all come out the same size. One with column 4 and one with column 50 are the same exact size.It's not clear what you're really asking so allow me to answer more than one question...
If my code had been:
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true); 1. Method setLocationRelativeTo centres a top-level window; when passed null it centres it on the screen.
2. Method setVisible make a component visible.
But my code was in fact:
f.pack();
SwingUtilities.invokeLater(new Runnable(){
public void run() {
f.setLocationRelativeTo(null);
f.setVisible(true);
});3. SwingUtilities.invokeLater, according to the API:
Causes run() to be executed asynchronously on the AWT event dispatching thread.
... This method should be used when an application thread needs to update the GUI.
Indeed it is being invoked by an application thread (the main thread).
All programmers who code Swing need to be aware about thread issues:
http://java.sun.com/products/jfc/tsc/articles/threads/threads1.html
http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html
http://java.sun.com/products/jfc/tsc/articles/threads/threads3.html
In the first link the Single Thread Rule is stated:
Once a Swing component has been realized, all code that might affect or depend on the state of that component
should be executed in the event-dispatching thread.
and it is followed by this comment:
Realized means that the component's paint() method has been or might be called. A Swing component that's a top-level
window is realized by having one of these methods invoked on it: setVisible(true), show(), or
(this might surprise you) pack().
So after calling pack, if you are being careful, you can't directly call methods like setVisible or setLocationRelativeTo.
Now, I've never had code blow up when I didn't use invokeLater, but it's simple enough to do,
and in my real code, I have a utility method I invoke that takes care of all this, in an easy-to-reuse way. -
Swing jdk1.4 is a buggy release !!!
Hi Gurus !!!
I'm wondering if anyone in the forums could solve this problem:
I have a JDialog class with a swing textfield added with an ActionListener (JDK_1.4.2_04). When I press down the Enter Key, actionEvent is continuously being fired while the ENTER key is down !!!!. this BAD behaviour occurs also when the user clicks on a button repeadetely !!! . I've been working for 2 days trying to solve it with no luck. In jdk1.3.1 release the behaviour is what I expected but I connot switch back to solve it.
Has anybody in the forums solved this ?????????????
I noticed that if I register an action with keystroke KeyStroke.getKeyStroke(KeyEvent.VK_F1,0,true); released the behaviour is correct, But how can I replace the default swing actions ?
Here's the code to test: (I found it in another post in the forum but the solution did'nt appeared )
public class SimpleDialog extends JDialog implements java.awt.event.ActionListener
class MyAction extends AbstractAction {
public void actionPerformed(ActionEvent e) {
System.out.println("TECLA PRESSEED----");
//private JButton jButton1 = new JButton("button");
private JTextField jButton1 = new JTextField("prova") {
protected boolean processKeyBinding(KeyStroke ks,KeyEvent e,int condition,boolean pressed) {
InputMap map = getInputMap(condition);
ActionMap am = getActionMap();
if(map != null && am != null && isEnabled()) {
System.out.println(pressed);
Object binding = map.get(ks);
Action action = (binding == null) ? null : am.get(binding);
if (action != null) {
return SwingUtilities.notifyAction(action, ks, e, this,
e.getModifiers());
return false;
public SimpleDialog()
MyAction action = new MyAction();
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F1,0,true);
jButton1.getInputMap().put(ks, "ajuda");
jButton1.getActionMap().put("ajuda", action);
UIManager.getDefaults().put("Text.focusInputMap", new
UIDefaults.LazyInputMap(new Object[] {
"released HOME", JTextField.notifyAction
this.getContentPane().add(jButton1);
//this.getRootPane().setDefaultButton(jButton1);
jButton1.addActionListener(this);
this.pack();
public void actionPerformed(ActionEvent e)
if (e.getSource() == jButton1)
System.out.println("button pressed");
public static void main(String[] args)
new SimpleDialog().show();import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DialogTest extends JDialog implements ActionListener
private JTextField tf;
boolean okayToProcess;
public DialogTest()
super(new JFrame(), "tab and press enter");
tf = new JTextField("prova", 16);
okayToProcess = true;
tf.addActionListener(this);
tf.addFocusListener(new FieldListener());
JPanel p = new JPanel();
p.add(tf);
getContentPane().add(p, "North");
getContentPane().add(new JTextField(16), "South");
setSize(200,125);
setLocation(400,400);
public void actionPerformed(ActionEvent e)
if (e.getSource() == tf && okayToProcess)
System.out.println("text field action event");
okayToProcess = false;
private class FieldListener extends FocusAdapter
public void focusLost(FocusEvent e)
okayToProcess = true;
public static void main(String[] args)
new DialogTest().show();
} -
Hi All,
I am working on the crud operations of the swing textfields using javafx. when the user clicks on the Edit button, the fields should be enabled for updating and after edit is finished , the textfields should be updated with the new data. I also have a reset button to reset information in textfields . Could someone help me by providing some examples.
Regards,
SherlynMaybe the [JavaFX CRUD|http://www.learntechnology.net/content/javafx/javafx.jsp] article might interest you.
-
Problem with Non English Chars
OS : Mac OS
Java : 1.5.0_07
Hi,
i have an Swing application that reads data from a database and shows them in a swing GUI. The text returned by the database is in Arabic and saved in a TextField object.
But once printed, the arabic chars are screwed up.or actually they r not arabic chars at all!!
For debugging i also write the result of the query in the console and in a log4j log file.
There, it is printed in the right form.
here the code:
System.out.println("D3"+java.nio.charset.Charset.defaultCharset().name());
System.out.println("singular "+dit.getData().getSingular());
log4j,debug("singular "+dit.getData().getSingular());
Font font = Font.decode("Geeza Pro");
textl.setFont(font);
textl.setText(dit.getData().getSingular());
The output in the console is (and log4j) :
D3MacRoman
singular صوف
The output in the Swing Textfield is
������
If i configure log4j to use UTF8 ,then even into log4j log file the same screwed
chars are written.
Looks like i've to tell Swing to use MacRoman, which is the default of the OS and
the used by the console&log4j. but i don't know how to.
Any clue??
Thanks,
Chris.convert your strings to unicode:
example 1
import java.awt.*;
import java.awt.event.*;
public class ApplicationFrame
extends Frame {
public ApplicationFrame() { this("ApplicationFrame v1.0"); }
public ApplicationFrame(String title) {
super(title);
createUI();
protected void createUI() {
setSize(500, 400);
center();
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
public void center() {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = getSize();
int x = (screenSize.width - frameSize.width) / 2;
int y = (screenSize.height - frameSize.height) / 2;
setLocation(x, y);
import java.awt.*;
public class BidirectionalText {
public static void main(String[] args) {
Frame f = new ApplicationFrame("BidirectionalText v1.0") {
public void paint(Graphics g) {
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
Font font = new Font("Lucida Sans Regular", Font.PLAIN, 32);
g2.setFont(font);
g2.drawString("Please \u062e\u0644\u0639 slowly.", 40, 80);
f.setVisible(true);
example2
Java Internationalization
By Andy Deitsch, David Czarnecki
ISBN: 0-596-00019-7
O'Reilly
import java.awt.event.*;
import java.awt.*;
import java.text.*;
import javax.swing.*;
public class ArabicDigits extends JPanel {
static JFrame frame;
public ArabicDigits() {
NumberFormat nf = NumberFormat.getInstance();
if (nf instanceof DecimalFormat) {
DecimalFormat df = (DecimalFormat)nf;
DecimalFormatSymbols dfs = df.getDecimalFormatSymbols();
// set the beginning of the range to Arabic digits
dfs.setZeroDigit('\u0660');
df.setDecimalFormatSymbols(dfs);
// create a label with the formatted number
JLabel label = new JLabel(nf.format(1234567.89));
// set the font with a large enough size so we can easily
// read the numbers
label.setFont(new Font("Lucida Sans", Font.PLAIN, 22));
add(label);
public static void main(String [] argv) {
ArabicDigits panel = new ArabicDigits();
frame = new JFrame("Arabic Digits");
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}});
frame.getContentPane().add("Center", panel);
frame.pack();
frame.setVisible(true);
To avoid having to type all the \u... notation manually, use the native2ascii tool (included with the SDK).
http://java.sun.com/developer/technicalArticles/Intl/HTTPCharset/ -
JClient Refresh Question (Am I trying too hard?)
Environment: Windows 2000, JDeveloper (9.0.3.10.35)
I have a JClient with a bunch of JTextFields bound to my BC4J app. I perform all of my business logic calculations/validations in the entity objects. I have some entity calculated attributes and these are calculating just fine. However, I also do some more complex calculations and manually set these entity attributes (about 5 of them). These calculations are triggered whenever a user modifies a textfield...
My problem is that whenever I modify a textfield, the calculations are performed, the entity attributes updated, but they aren't shown/refreshed in the client. Hmmm... Here are some of the things I've been trying:
- Override sourceChanged() in my view implementation. Ok, I can see "attribute changed" events, but how do I update the Swing textfield?
- Got a handle to the iterator binding and forced a refresh from entity->view by calling "navigate(null)".
Calling navigate(null) worked, so I then thought I could add this logic to the sourceChanged() handler but I am not sure about the easiest way to get the iterator binding from the view implementation. Hmmm... I think I'm making this way too hard... Am I missing something totally basic here? Any suggestions would be great? Thank you.
BTW, the attributes are marked as updateable in both entity and view.I've done some more debugging, looking into the areas you referred me to... I think I have stumbled across the "eventing mechanism bug" between EO and VO when subclassing is involved (Re: package in all_objects shows invalid but compiles fine
). I failed to mention that I was using a polymorphic rowset because I didn't think it was relevant (shouldn't have assumed...)
Here's what I've verified:
When I set an attribute in the entity with no subclassing, notifyRowUpdated() is called in the view object. However, if the entity is a subclass, notifyRowUpdated() isn't called.
Your first question may be if I have correctly setup the polymorphic rowset behavior. I think so... I've read all the articles/how to's that I've found about polymorphic rowsets in this discussion group. My "abstract" view points to my abstract entity, and then imports all of the subclasses (defined when you click the "subtypes" button in view object properties window). The discriminator is working and BC4J is instantiating the correct subclass, however, the view isn't getting notified when an entity's attribute is modified (ie, notifyRowUpdated() isn't getting called).This info along with the other link gives us enough to reproduce the bug and as mentioned in the other link, it is targeted for fix in our next release.
The workaround to the "EO/VO eventing bug" was to call executeQuery() to refresh the detail. My problem seems to be in a slightly different context, so I'm not sure exactly what to do. As I had mentioned earlier, calling navigated(null) seemed to refresh the view. Should I pursue this or do you suggest something else? naviated(null) is a fine workaround. JClient bindings simply get the current row from 'the iterator' and displays that so that's effectively a refresh on the control-bindings.
Would you like a small repro case? Thank you. Let us know if you hit any issues with this workaround.
Thanks
Shailesh -
"Reset" declared variables to initialized state?
Hiya!
This might sound like a very stupid question, but I have not figured out a way to do this. I am working on a "personal information manager", where users can enter a date in a lovely swing textfield, it get's parsed to Integer and a GregorianCalendar is created with it. Once I created the Calendar, the TextFields are emptied again, but of course the Integer instance variables are still declared with the old values. This leads to the fact that a user could click "add date" again and a date is created without entering any number at all.
My question:
Is it possible to set declared variables back to the state they had when initialized? They should be "empty"...
I can`t set them null...
Thanks for your help, it's much appreciated!The only type of variable where "empty" has any meaning is for an empty string: "". Otherwise there is no empty. Objects are by default initialized to null, numeric primitives to zero, and I think chars to '' but I could be mistaken about that one - I never use chars. So if you're using Integers, they could either be null, or an Integer - nothing else.
-
TextField Validation in swings
Hello friends,
i got a problem. i am doing textfield validation using KeyListener.
i can able to detect the keys except Tab key.
When i am pression TAB key the KeyListener is not catching the event.
Actually validation should be in such a way that,
in account number field if i press anyotherkeys otherthan numeric ,del,backspace keys it should not allow to enter.
also it has to give error if user tries to move from that field without entering anydata by pressing TAB or Mouse.
Here exactly getting problem with focus.
Please give your advise
thanks in advance
regards
shashiTextField Validation in swingsOk, you know its a Swing question, so it should be posting in the Swing forum.
if i press anyotherkeys otherthan numeric ,del,backspace keys it should not allow to enter.You should be using a JFormattedTextField
it has to give error if user tries to move from that field without entering anydata You could try an InputVerifier. -
Moving a TextField in Swing.Possible?please help
Hi all,
I'm working on this application to create textfields in a page and resize and reposition them as necessary using the mouse(Just like dragging and dropping components in Visual Basic). Is it possible to provide such a functionality for a Textfield in java? If so how? If you do have some reference sites, please let me know. Any help will be appreciated. Thanks.Hi,
if you just need a simple framework:
I've created a customizer framework for such tasks: Move and resize components with the mouse and allow further customizations. "Snap-to-grid"-feature included! Maybe you find it useful as a base. (It's open source!)
I started to write a tutorial (still under construction!):
http://softsmithy.sourceforge.net/lib/docs/tutorial/swing/customizer/index.html
For adding components see:
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/CustomizerBar.html
To customize properties use:
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JCustomizerPropertyTable.html
Register it to the SelectionManager of the JCustomizerPane and set the CustomizableProperties-property of the JCustomizer objects.
Also have a look at the subclasses of JCustomizer.
E.g. there are
customizers for images & shapes:
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JXIconCustomizer.html
a label customizer with inline editing:
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLabelCustomizer.html
a line customizer:
http://softsmithy.sourceforge.net/lib/docs/api/org/softsmithy/lib/swing/JLine2DCustomizer.html
And there are many classes providing support for menu- and toolbar-actions. (Incuding support for some of the "Java Look and Feel Graphics Repository" actions.)
Look at the *.swing and the *.swing.action packages.
Just ask me if you don't find them.
Homepage:
http://www.softsmithy.org
Download:
http://sourceforge.net/project/showfiles.php?group_id=64833
Source:
http://sourceforge.net/svn/?group_id=64833
http://softsmithy.svn.sourceforge.net/viewvc/softsmithy/trunk/lib/src/org/softsmithy/lib/
API:
http://softsmithy.sourceforge.net/lib/docs/api/index.html
If you have questions just ask me!
-Puce -
Textfield autocomplete, How can i implement for each word in swing
I want to implement autocompletion using TextField ,
How can i do it ?user9251649 wrote:
I want to use conditional row templates in an interactive report (apex 4.1).
My data are hierarchical (tree). That means that each row in the result set of my query has a given level.
All rows with the level 1 should have a red background color, all rows with the level 2 the background color blue, ..
Thank for any effortSimple! if you search the forum or consult the documentation first you would have saved everyone's time
Here is how you do it
http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21679/build_app.htm#TDPAX7060 -
What difference between Jtextfield of Swing and Textfield of awt.
when we press enter key in a textfield for TextField an action is
occur than what method is called and tell me JtextField does not
support enter key action.??
Plz tell me about public boolean handleEvent(Event e){}.
Infact i want to display internationlized text in textfield.with
JTextfield after installing desired font and setting font i hv been succeeded to display in JTextfield what i want but since TextField is OS
dependent it is showing me ??.Tell me what should i do bcz JTextfield is not giving me action event and TextField of awt is not giving me internationlized text.I want that TextField of awt should display my internationalized text.Tell me what should i do.I hv tried to set console of command prompt by using chcp command.
thanxAdd an ActionListener to the JTextField:
http://java.sun.com/docs/books/tutorial/uiswing/components/simpletext.html#textfield -
Displaying the path of the file selected by a FileChooser in a TextField
I'm just getting started with Swing. I developed a simple dialog box that has two text fields and two buttons. The objective is to open two files using those two buttons. I used FileChooser to select the files. Now, I want to display the path of the selected files in their corresponding TextFields. I use the following code to do that.
final FileChooser fc1 = new FileChooser();
final FileChooser fc2 = new FileChooser();
final TextField tf1 = new TextField();
final TextField tf2 = new TextField();
private void button1ActionPerformed(ActionEvent evt)
int returnVal1 = fc1.showOpenDialog(labelPhpFile);
if (returnVal1 == JFileChooser.APPROVE_OPTION)
File file1 = fc1.getSelectedFile();
String fileName1 = file1.getName();
String filePath1 = file1.getPath();
tf1.setText(filePath1);
private void button2ActionPerformed(ActionEvent evt)
int returnVal2 = fc2.showOpenDialog(labelPhpFile);
if (returnVal2 == JFileChooser.APPROVE_OPTION)
File file2 = fc2.getSelectedFile();
String fileName2 = file2.getName();
String filePath2 = file2.getPath();
tf2.setText(filePath2);
}The above code works fine only for the first file. Mean the path of the file selected using fc1 is getting displayed in the tf1 TextField. But, the file selected using fc2 is not getting displayed tf2 TextField. Please help me.
Thank you :)h1. The Ubiquitous Newbie Tips
* DON'T SHOUT!!!
* Homework dumps will be flamed mercilessly.
* Have a quick scan through the [Forum FAQ's|http://wikis.sun.com/display/SunForums/Forums.sun.com+FAQ].
h5. Ask a good question
* Don't forget to actually ask a question. No, The subject line doesn't count.
* Ask once
- Don't Crosspost!
- Two people answering one question independantly is a waste of there time.
* Don't even talk to me until you've:
(a) [googled it|http://www.google.com.au/] and
(b) looked it up in [Sun's Java Tutorials|http://java.sun.com/docs/books/tutorial/] and
(c) read the relevant section of the [API Docs|http://java.sun.com/javase/6/docs/api/index-files/index-1.html] and maybe even
(d) referred to the JLS (for "advanced" questions).
* [Good questions|http://www.catb.org/~esr/faqs/smart-questions.html#intro] get better Answers. It's a fact. Trust me on this one.
- Lots of regulars on these forums simply don't read badly written questions. It's just too frustrating.
- FFS spare us the SMS and L33t speak! Pull your pants up, and get a hair cut!
- Often you discover your own mistake whilst forming a "Good question".
- Many of the regulars on these forums will bend over backwards to help with a "Good question",
especially to a nuggetty problem, because they're interested in the answer.
* Improve your chances of getting laid tonight by writing an SSCCE
- For you normal people, That's a: Short Self-Contained Compilable Example.
- Short is sweet: No-one wants to wade through 5000 lines to find your syntax errors!
- Often you discover your own mistake whilst writing an SSCCE.
- Solving your own problem yields a sense of accomplishment ;-)
h5. Formatting Matters
* Post your code between a pair of {code} tags
- That is: {code} ... your code goes here ... {code}
- This makes your code easier to read by preserving whitespace and highlighting java syntax.
- Copy&paste your source code directly from your editor. The forum editor basically sucks.
- The forums tabwidth is 8, as per [the java coding conventions|http://java.sun.com/docs/codeconv/].
- Indents will go jagged if your tabwidth!=8 and you've mixed tabs and spaces.
- Lines longer than 80 characters should be wrapped.
- Proper indentation illustrates program logic.
* Post your error messages between a pair of {code} tags:
- That is: {code} ... errors here ... {code}
- To make it easier for us to find, Mark the erroneous line(s) in your source-code. For example:
System.out.println("Your momma!); // <<<< ERROR 1
- Note that error messages are rendered basically useless if the code has been
modified AT ALL since the error message was produced.
- Here's [How to read a stacktrace|http://www.0xcafefeed.com/2004/06/of-thread-dumps-and-stack-traces/].
* The forum editor has a "Preview" pane. Use it.
- If you're new around here you'll probably find the "Rich Text" view is easier to use.
- WARNING: Swapping from "Plain Text" view to "Rich Text" scrambles the markup!
- To see how a posted "special effect" is done, click reply then click the quote button.
If you (the newbie) have covered these bases *you deserve, and can therefore expect, GOOD answers!*
h1. The pledge!
We the New To Java regulars do hereby pledge to refrain from flaming anybody, no matter how gumbyish the question, if the OP has demonstrably tried to cover these bases. The rest are fair game. -
How can I select a smaller font for all components of a Swing application?
The default size of font in Java Look and Feel is 12, how can I change it to 10 globally for my Swing application ?
Thanks for your help.
HelenIt is not very simple because all components don't use the same fonts and if you don't want to subclass the l&f you can do this :
after setting the l&f (in the main for example)
Font f = new Font("dialog", Font.PLAIN, 11);
UIManager.put("MenuItem.font", f);
UIManager.put("Menu.font", f);
UIManager.put("MenuItem.acceleratorFont", new Font("dialog", Font.PLAIN, 10));
UIManager.put("Label.font", f);
UIManager.put("Button.font", f);
UIManager.put("ToggleButton.font", f);
UIManager.put("ToolTip.font", f);
UIManager.put("List.font", f);
UIManager.put("Table.font", f);
UIManager.put("TextField.font", f);
UIManager.put("ComboBox.font", f);
UIManager.put("RadioButton.font", f);
UIManager.put("CheckBox.font", f);
UIManager.put("RadioButtonMenuItem.font", f);
UIManager.put("CheckBoxMenuItem.font", f);
UIManager.put("TableHeader.font", f);
UIManager.put("Spinner.font", f);
UIManager.put("Panel.font", f);etc...
Denis -
Please help me in creating a form using Swing.
(I m sorry if I've posted similar post in some other thread.I am new to this forum..:))
There are several problems which I am facing while coding a form.
1. In the form I have one JComboBox
of Country and other of State. Now I want it in such a way that when
I select a country from the Country JComboBox ,the corresponding states
automatically appears in the State JComboBox.
2. I need to add picture frame in the 6th tab so that the picture shows up when clicked browse and open.
3.I need to add tables in 1st and 5th tab which shows up the details through database when added through several textboxes and combo boxes.
so please help me!
Here's my code
==========================================================
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JCheckBox;
import javax.swing.border.*;
import javax.swing.table.*;
import javax.swing.Box;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Design extends JFrame
public Design()
super("Tenant Form");
setLayout(new BorderLayout());
JTabbedPane tabbedPane=new JTabbedPane(); //creating tabbed buttons
//<--------coding for first tab--------->
JPanel panel1=new JPanel();
tabbedPane.addTab("Detail of Landlord",null,panel1,"first tab"); //here panel1 is created for tab1
GridBagConstraints gbc=new GridBagConstraints();
gbc.insets=new Insets(2,2,2,2);
gbc.anchor=GridBagConstraints.WEST;
JPanel jp11 = new JPanel(); //1st panel in 1st tab for top labels and buttons
jp11.setLayout(new GridBagLayout());
JLabel l241 = new JLabel("Name Of LandLord");
jp11.add(l241,gbc);
JComboBox jc01=new JComboBox();
jc01.addItem("Select");
jc01.addItem("Mr.");
jc01.addItem("Mrs.");
gbc.gridx=1;
jp11.add(jc01,gbc);
JTextField f01=new JTextField(10);
gbc.gridx=2;
jp11.add(f01,gbc);
JLabel l251 = new JLabel("Sex");
gbc.gridx=5;
gbc.insets=new Insets(2,20,2,2);
jp11.add(l251,gbc);
JComboBox jc11=new JComboBox();
jc11.addItem("Select");
jc11.addItem("Male");
jc11.addItem("Female");
gbc.gridx=6;
gbc.insets=new Insets(2,2,2,2);
jp11.add(jc11,gbc);
JLabel l261 = new JLabel("Age(Yrs)");
gbc.gridx=8;
gbc.insets=new Insets(2,20,2,2);
jp11.add(l261,gbc);
JTextField f11=new JTextField(3);
gbc.gridx=9;
gbc.insets=new Insets(2,2,2,2);
jp11.add(f11,gbc);
JLabel l271 = new JLabel("Occupation");
gbc.gridx= 11;
gbc.insets=new Insets(2,20,2,2);
jp11.add(l271,gbc);
JComboBox jc21=new JComboBox();
jc21.addItem("Select");
jc21.addItem("Engineer");
jc21.addItem("Business");
gbc.gridx=12;
gbc.insets=new Insets(2,2,2,2);
jp11.add(jc21,gbc);
JButton ab1=new JButton("ADD");
gbc.gridx=14;
gbc.insets=new Insets(2,20,2,2);
jp11.add(ab1,gbc);
panel1.add(jp11);
//<--coding for adding table with scroll pane #yet to be coded#-->
JTable jtab1=new JTable();
//start of p21 panel. 1st of two titledborder panels in tab 1
JPanel jp21=new JPanel();
jp21.setBorder(new TitledBorder("Address Of Landlord Property"));
jp21.setLayout(new GridBagLayout());
JLabel l11=new JLabel("Property/House/Building Address");
gbc.gridx=0;
gbc.gridy=0;
jp21.add(l11,gbc);
JTextArea ta11=new JTextArea(3,15);
ta11.setLineWrap(true);
int v=ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED;
int h=ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER;
JScrollPane scroll11=new JScrollPane(ta11,v,h);
gbc.gridx=1;
jp21.add(scroll11);
jp21.add(ta11,gbc);
JLabel l21=new JLabel("Land Mark");
gbc.gridx=0;
gbc.gridy=1;
gbc.ipady=0;
gbc.gridheight=1;
jp21.add(l21,gbc);
JTextField tf21=new JTextField(15);
gbc.gridx=1;
gbc.gridy=1;
jp21.add(tf21,gbc);
JLabel l31=new JLabel("Country");
gbc.gridx=0;
gbc.gridy=2;
jp21.add(l31,gbc);
JComboBox c11=new JComboBox();
c11.addItem("India");
c11.addItem("US");
c11.addItem("Australia");
gbc.gridx=1;
gbc.gridy=2;
jp21.add(c11,gbc);
JLabel l41=new JLabel("State");
gbc.gridx=0;
gbc.gridy=3;
jp21.add(l41,gbc);
JComboBox c21=new JComboBox();
c21.addItem("Rajasthan");
c21.addItem("Delhi");
c21.addItem("Maharastra");
gbc.gridx=1;
gbc.gridy=3;
jp21.add(c21,gbc);
JLabel l51=new JLabel("District");
gbc.gridx=0;
gbc.gridy=4;
jp21.add(l51,gbc);
JComboBox c31=new JComboBox();
c31.addItem("jaipur");
c31.addItem("ajmer");
c31.addItem("alwar");
gbc.gridx=1;
gbc.gridy=4;
jp21.add(c31,gbc);
JLabel l61=new JLabel("City/Town");
gbc.gridx=0;
gbc.gridy=5;
jp21.add(l61,gbc);
JTextField tf31=new JTextField(15);
gbc.gridx=1;
gbc.gridy=5;
jp21.add(tf31,gbc);
JLabel l71=new JLabel("Police District");
gbc.gridx=0;
gbc.gridy=6;
jp21.add(l71,gbc);
JComboBox c41=new JComboBox();
c41.addItem("Jaipur");
c41.addItem("Alwar");
c41.addItem("Ajmer");
gbc.gridx=1;
gbc.gridy=6;
jp21.add(c41,gbc);
JLabel l81=new JLabel("Police Circle");
gbc.gridx=0;
gbc.gridy=7;
jp21.add(l81,gbc);
JComboBox c51=new JComboBox();
c51.addItem("India");
c51.addItem("US");
c51.addItem("Australia");
gbc.gridx=1;
gbc.gridy=7;
jp21.add(c51,gbc);
JLabel l91=new JLabel("Police station");
gbc.gridx=0;
gbc.gridy=8;
jp21.add(l91,gbc);
JComboBox c61=new JComboBox();
c61.addItem("Bani Park");
c61.addItem("Raja Park");
c61.addItem("Malviya Nagar");
gbc.gridx=1;
gbc.gridy=8;
jp21.add(c61,gbc);
JLabel l101=new JLabel("Pin No.");
gbc.gridx=0;
gbc.gridy=9;
jp21.add(l101,gbc);
JTextField tf41=new JTextField(15);
gbc.gridx=1;
gbc.gridy=9;
jp21.add(tf41,gbc);
JLabel l111=new JLabel("Phone No.(R)");
gbc.gridx=0;
gbc.gridy=10;
jp21.add(l111,gbc);
JTextField tf51=new JTextField(15);
gbc.gridx=1;
gbc.gridy=10;
jp21.add(tf51,gbc);
//start of p31.2nd of two titledborder panels in tab 1
JPanel jp31=new JPanel();
jp31.setBorder(new TitledBorder("Address Of Landlord Office"));
jp31.setLayout(new GridBagLayout());
JLabel l121=new JLabel("Office Address");
gbc.gridx=0;
gbc.gridy=0;
jp31.add(l121,gbc);
JTextArea ta61=new JTextArea(3,15);
ta61.setLineWrap(true);
JScrollPane scroll2=new JScrollPane(ta61);
gbc.gridx=1;
gbc.gridy=0;
jp31.add(ta61,gbc);
JLabel l131=new JLabel("Country");
gbc.gridx=0;
gbc.gridy=1;
gbc.gridheight=1;
jp31.add(l131,gbc);
JComboBox c12=new JComboBox();
c12.addItem("India");
c12.addItem("US");
c12.addItem("Australia");
gbc.gridx=1;
gbc.gridy=1;
jp31.add(c12,gbc);
JLabel l141=new JLabel("State");
gbc.gridx=0;
gbc.gridy=2;
jp31.add(l141,gbc);
JComboBox c22=new JComboBox();
c22.addItem("Rajasthan");
c22.addItem("Delhi");
c22.addItem("Maharastra");
gbc.gridx=1;
gbc.gridy=2;
jp31.add(c22,gbc);
JLabel l151=new JLabel("District");
gbc.gridx=0;
gbc.gridy=3;
jp31.add(l151,gbc);
JComboBox c32=new JComboBox();
c32.addItem("jaipur");
c32.addItem("ajmer");
c32.addItem("alwar");
gbc.gridx=1;
gbc.gridy=3;
jp31.add(c32,gbc);
JLabel l161=new JLabel("City/Town");
gbc.gridx=0;
gbc.gridy=4;
jp31.add(l161,gbc);
JTextField tf71=new JTextField(15);
gbc.gridx=1;
gbc.gridy=4;
jp31.add(tf71,gbc);
JLabel l171=new JLabel("Police District");
gbc.gridx=0;
gbc.gridy=5;
jp31.add(l171,gbc);
JComboBox c42=new JComboBox();
c42.addItem("Jaipur");
c42.addItem("Alwar");
c42.addItem("Ajmer");
gbc.gridx=1;
gbc.gridy=5;
jp31.add(c42,gbc);
JLabel l181=new JLabel("Police Circle");
gbc.gridx=0;
gbc.gridy=6;
jp31.add(l181,gbc);
JComboBox c52=new JComboBox();
c52.addItem("India");
c52.addItem("US");
c52.addItem("Australia");
gbc.gridx=1;
gbc.gridy=6;
jp31.add(c52,gbc);
JLabel l191=new JLabel("Police station");
gbc.gridx=0;
gbc.gridy=7;
jp31.add(l191,gbc);
JComboBox c62=new JComboBox();
c62.addItem("Bani Park");
c62.addItem("Raja Park");
c62.addItem("Malviya Nagar");
gbc.gridx=1;
gbc.gridy=7;
jp31.add(c62,gbc);
JLabel l201=new JLabel("Pin No.");
gbc.gridx=0;
gbc.gridy=8;
jp31.add(l201,gbc);
JTextField tf81=new JTextField(15);
gbc.gridx=1;
gbc.gridy=8;
jp31.add(tf81,gbc);
JLabel l211=new JLabel("Phone No.(O)");
gbc.gridx=0;
gbc.gridy=9;
jp31.add(l211,gbc);
JTextField tf91=new JTextField(15);
gbc.gridx=1;
gbc.gridy=9;
jp31.add(tf91,gbc);
JLabel l221=new JLabel("Phone No.(M)");
gbc.gridx=0;
gbc.gridy=10;
gbc.gridheight=1;
jp31.add(l221,gbc);
JTextField tf101=new JTextField(15);
gbc.gridx=1;
gbc.gridy=10;
jp31.add(tf101,gbc);
JLabel l231=new JLabel("E-mail");
gbc.gridx=0;
gbc.gridy=11;
gbc.gridheight=1;
jp31.add(l231,gbc);
JTextField tf111=new JTextField(15);
gbc.gridx=1;
gbc.gridy=11;
jp31.add(tf111,gbc);
JPanel jp41=new JPanel(); //adding above two panels p21 and p31 to p41 panel.
jp41.setLayout(new BoxLayout(jp41,BoxLayout.X_AXIS));
jp41.add(jp21);
jp41.add(Box.createHorizontalStrut(50));
jp41.add(jp31);
panel1.add(jp41); //adding p41 panel to panel1
//<--------coding for second tab--------->
JPanel panel2 = new JPanel();
tabbedPane.addTab("Id of Landlord",null,panel2,"second tab");
panel2.setLayout(new FlowLayout());
//adding radiobutton above TitledBorder panel
JPanel jp02=new JPanel();
JLabel l12=new JLabel("Identity Known");
JRadioButton jrb12=new JRadioButton("Yes");
JRadioButton jrb22=new JRadioButton("No");
ButtonGroup bg12=new ButtonGroup();
bg12.add(jrb12);
bg12.add(jrb22);
jp02.add(l12);
jp02.add(jrb12);
jp02.add(jrb22);
//adding TitledBorder panel
JPanel jp12=new JPanel();
jp12.setBorder(new TitledBorder("Identity Detail"));
jp12.setLayout(new GridBagLayout());
gbc.insets=new Insets(5,5,5,5);
JLabel l22=new JLabel("Identity Card");
gbc.gridx=0;
gbc.gridy=0;
jp12.add(l22,gbc);
JTextField jtf12=new JTextField(10);
gbc.gridx=1;
jp12.add(jtf12,gbc);
JLabel l32=new JLabel("Date of Issue");
gbc.gridx=0;
gbc.gridy=1;
jp12.add(l32,gbc);
JTextField jtf22=new JTextField(10);
gbc.insets=new Insets(5,5,5,25);
gbc.gridx=1;
jp12.add(jtf22,gbc);
JLabel l42=new JLabel("Identity Number");
gbc.insets=new Insets(5,5,5,5);
gbc.gridx=2;
jp12.add(l42,gbc);
JTextField jtf32=new JTextField(10);
gbc.gridx=3;
jp12.add(jtf32,gbc);
JLabel l52=new JLabel("Name Of Issuer");
gbc.gridx=0;
gbc.gridy=2;
jp12.add(l52,gbc);
JTextField jtf42=new JTextField(10);
gbc.insets=new Insets(5,5,5,25);
gbc.gridx=1;
jp12.add(jtf42,gbc);
JLabel l62= new JLabel("Place Of Issuer");
gbc.insets=new Insets(5,5,5,5);
gbc.gridx=2;
jp12.add(l62,gbc);
JTextField jtf52=new JTextField(10);
gbc.gridx=3;
jp12.add(jtf52,gbc);
gbc.gridx=0;
gbc.gridy=2;
Box b12 =Box.createVerticalBox(); //adding both panels to vertica box and adding it to panel2
b12.add(jp02);
b12.add(jp12);
panel2.add(b12);
//<--------coding for third tab--------->
JPanel panel3 = new JPanel();
tabbedPane.addTab("Detail of Tenant",null,panel3,"third tab");
//adding panel for top data
JPanel jp13=new JPanel(); //jp13 panel for details above 3 TitledBorder panels
jp13.setLayout(new GridBagLayout());
JLabel l13=new JLabel("Name");
gbc.insets=new Insets(2,2,2,2);
gbc.gridx=0;
gbc.gridy=0;
jp13.add(l13,gbc);
JComboBox c13=new JComboBox();
c13.addItem("Select");
c13.addItem("Mr.");
c13.addItem("Mrs.");
gbc.gridx=1;
jp13.add(c13,gbc);
JTextField jtf13=new JTextField(16);
gbc.gridx=2;
gbc.gridwidth=2;
jp13.add(jtf13,gbc);
JLabel l23=new JLabel("Sex");
gbc.insets=new Insets(2,20,2,2);
gbc.gridx=4;
gbc.gridwidth=1;
jp13.add(l23,gbc);
JComboBox c23=new JComboBox();
c23.addItem("Select");
c23.addItem("Male");
c23.addItem("Female");
gbc.insets=new Insets(2,2,2,2);
gbc.gridx=5;
jp13.add(c23,gbc);
JLabel l33=new JLabel("Father/Mother/Husband's Name");
gbc.gridy=1;
gbc.gridx=0;
jp13.add(l33,gbc);
JComboBox c33=new JComboBox();
c33.addItem("Select");
c33.addItem("Mr.");
c33.addItem("Mrs.");
gbc.gridx=1;
jp13.add(c33,gbc);
JComboBox c43=new JComboBox();
c43.addItem("Select");
c43.addItem("Mr.");
c43.addItem("Mrs.");
gbc.gridx=2;
jp13.add(c43,gbc);
JTextField jtf23=new JTextField(10);
gbc.gridx=3;
jp13.add(jtf23,gbc);
JLabel l43=new JLabel("Age(Yrs)");
gbc.insets=new Insets(2,20,2,2);
gbc.gridx=4;
jp13.add(l43,gbc);
JTextField jtf33=new JTextField(3);
gbc.insets=new Insets(2,2,2,2);
gbc.gridx=5;
jp13.add(jtf33,gbc);
JLabel l53=new JLabel("Citizenship");
gbc.gridy=2;
gbc.gridx=0;
jp13.add(l53,gbc);
JComboBox c53=new JComboBox();
c53.addItem("Select");
c53.addItem("Indian");
c53.addItem("Australian");
gbc.gridx=1;
gbc.gridwidth=2;
jp13.add(c53,gbc);
JLabel l63=new JLabel("Occupation");
gbc.insets=new Insets(2,20,2,2);
gbc.gridx=4;
gbc.gridwidth=1;
jp13.add(l63,gbc);
JComboBox c63=new JComboBox();
c63.addItem("Select");
c63.addItem("Engineer");
c63.addItem("Doctor");
gbc.insets=new Insets(2,2,2,2);
gbc.gridx=5;
jp13.add(c63,gbc);
panel3.add(jp13);
JPanel jp23=new JPanel(); //first of 3 TitledBorder panels
jp23.setBorder(new TitledBorder("Local Address"));
jp23.setLayout(new GridBagLayout());
JLabel l73=new JLabel("Local Address");
gbc.gridx=0;
gbc.gridy=0;
jp23.add(l73,gbc);
JTextArea ta43=new JTextArea(3,10);
ta43.setLineWrap(true);
JScrollPane scroll13=new JScrollPane(ta43);
gbc.gridx=1;
gbc.gridy=0;
jp23.add(ta43,gbc);
JLabel l83=new JLabel("Country");
gbc.gridx=0;
gbc.gridy=1;
gbc.gridheight=1;
jp23.add(l83,gbc);
JComboBox c73=new JComboBox();
c73.addItem("India");
c73.addItem("US");
c73.addItem("Australia");
gbc.gridx=1;
gbc.gridy=1;
jp23.add(c73,gbc);
JLabel l93=new JLabel("State");
gbc.gridx=0;
gbc.gridy=2;
jp23.add(l93,gbc);
JComboBox c83=new JComboBox();
c83.addItem("Rajasthan");
c83.addItem("Delhi");
c83.addItem("Maharastra");
gbc.gridx=1;
gbc.gridy=2;
jp23.add(c83,gbc);
JLabel l103=new JLabel("District");
gbc.gridx=0;
gbc.gridy=3;
jp23.add(l103,gbc);
JComboBox c93=new JComboBox();
c93.addItem("jaipur");
c93.addItem("ajmer");
c93.addItem("alwar");
gbc.gridx=1;
gbc.gridy=3;
jp23.add(c93,gbc);
JLabel l113=new JLabel("City/Town");
gbc.gridx=0;
gbc.gridy=4;
jp23.add(l113,gbc);
JTextField tf53=new JTextField(10);
gbc.gridx=1;
gbc.gridy=4;
jp23.add(tf53,gbc);
JLabel l123=new JLabel("Police District");
gbc.gridx=0;
gbc.gridy=5;
jp23.add(l123,gbc);
JComboBox c103=new JComboBox();
c103.addItem("Jaipur");
c103.addItem("Alwar");
c103.addItem("Ajmer");
gbc.gridx=1;
gbc.gridy=5;
jp23.add(c103,gbc);
JLabel l133=new JLabel("Police Circle");
gbc.gridx=0;
gbc.gridy=6;
jp23.add(l133,gbc);
JComboBox c113=new JComboBox();
c113.addItem("India");
c113.addItem("US");
c113.addItem("Australia");
gbc.gridx=1;
gbc.gridy=6;
jp23.add(c113,gbc);
JLabel l143=new JLabel("Police station");
gbc.gridx=0;
gbc.gridy=7;
jp23.add(l143,gbc);
JComboBox c123=new JComboBox();
c123.addItem("Bani Park");
c123.addItem("Raja Park");
c123.addItem("Malviya Nagar");
gbc.gridx=1;
gbc.gridy=7;
jp23.add(c123,gbc);
JLabel l153=new JLabel("Pin No.");
gbc.gridx=0;
gbc.gridy=8;
jp23.add(l153,gbc);
JTextField tf63=new JTextField(10);
gbc.gridx=1;
gbc.gridy=8;
jp23.add(tf63,gbc);
JLabel l163=new JLabel("Phone No.(R)");
gbc.gridx=0;
gbc.gridy=9;
jp23.add(l163,gbc);
JTextField tf73=new JTextField(10);
gbc.gridx=1;
gbc.gridy=9;
jp23.add(tf73,gbc);
JLabel l173=new JLabel("E-mail");
gbc.gridx=0;
gbc.gridy=10;
gbc.gridheight=1;
jp23.add(l173,gbc);
JTextField tf83=new JTextField(10);
gbc.gridx=1;
gbc.gridy=10;
jp23.add(tf83,gbc);
JPanel jp33=new JPanel(); //second of 3 TitledBorder panels
jp33.setBorder(new TitledBorder("Permanent Address"));
jp33.setLayout(new GridBagLayout());
JLabel l183=new JLabel("Perm. Address");
gbc.gridx=0;
gbc.gridy=0;
jp33.add(l183,gbc);
JTextArea ta93=new JTextArea(5,10);
JScrollPane scroll23=new JScrollPane(ta43);
ta93.setLineWrap(true);
gbc.gridx=1;
gbc.gridy=0;
jp33.add(ta43,gbc);
JLabel l193=new JLabel("Country");
gbc.gridx=0;
gbc.gridy=1;
gbc.gridheight=1;
jp33.add(l193,gbc);
JComboBox c133=new JComboBox();
c133.addItem("India");
c133.addItem("US");
c133.addItem("Australia");
gbc.gridx=1;
gbc.gridy=1;
jp33.add(c133,gbc);
JLabel l203=new JLabel("State");
gbc.gridx=0;
gbc.gridy=2;
jp33.add(l203,gbc);
JComboBox c143=new JComboBox();
c143.addItem("Rajasthan");
c143.addItem("Delhi");
c143.addItem("Maharastra");
gbc.gridx=1;
gbc.gridy=2;
jp33.add(c143,gbc);
JLabel l213=new JLabel("District");
gbc.gridx=0;
gbc.gridy=3;
jp33.add(l213,gbc);
JComboBox c153=new JComboBox();
c153.addItem("jaipur");
c153.addItem("ajmer");
c153.addItem("alwar");
gbc.gridx=1;
gbc.gridy=3;
jp33.add(c153,gbc);
JLabel l223=new JLabel("City/Town");
gbc.gridx=0;
gbc.gridy=4;
jp33.add(l223,gbc);
JTextField tf103=new JTextField(10);
gbc.gridx=1;
gbc.gridy=4;
jp33.add(tf103,gbc);
JLabel l233=new JLabel("Police District");
gbc.gridx=0;
gbc.gridy=5;
jp33.add(l233,gbc);
JComboBox c163=new JComboBox();
c163.addItem("Jaipur");
c163.addItem("Alwar");
c163.addItem("Ajmer");
gbc.gridx=1;
gbc.gridy=5;
jp33.add(c163,gbc);
JLabel l243=new JLabel("Police Circle");
gbc.gridx=0;
gbc.gridy=6;
jp33.add(l243,gbc);
JComboBox c173=new JComboBox();
c173.addItem("India");
c173.addItem("US");
c173.addItem("Australia");
gbc.gridx=1;
gbc.gridy=6;
jp33.add(c173,gbc);
JLabel l253=new JLabel("Police station");
gbc.gridx=0;
gbc.gridy=7;
jp33.add(l253,gbc);
JComboBox c183=new JComboBox();
c183.addItem("Bani Park");
c183.addItem("Raja Park");
c183.addItem("Malviya Nagar");
gbc.gridx=1;
gbc.gridy=7;
jp33.add(c183,gbc);
JLabel l263=new JLabel("Pin No.");
gbc.gridx=0;
gbc.gridy=8;
jp33.add(l263,gbc);
JTextField tf113=new JTextField(10);
gbc.gridx=1;
gbc.gridy=8;
jp33.add(tf113,gbc);
JLabel l273=new JLabel("Phone No.(R)");
gbc.gridx=0;
gbc.gridy=9;
jp33.add(l273,gbc);
JTextField tf123=new JTextField(10);
gbc.gridx=1;
gbc.gridy=9;
jp33.add(tf123,gbc);
JLabel l283=new JLabel("phone No.(M)");
gbc.gridx=0;
gbc.gridy=10;
gbc.gridheight=1;
jp33.add(l283,gbc);
JTextField tf133=new JTextField(10);
gbc.gridx=1;
gbc.gridy=10;
jp33.add(tf133,gbc);
JPanel jp43=new JPanel(); //third of 3 TitledBorder panels
jp43.setBorder(new TitledBorder("Ex-Home Address"));
jp43.setLayout(new GridBagLayout());
JLabel l293=new JLabel("Address");
gbc.gridx=0;
gbc.gridy=0;
jp43.add(l293,gbc);
JTextArea ta143=new JTextArea(3,10);
ta143.setLineWrap(true);
JScrollPane scroll33=new JScrollPane(ta143);
gbc.gridx=1;
gbc.gridy=0;
jp43.add(ta143,gbc);
JLabel l303=new JLabel("Country");
gbc.gridx=0;
gbc.gridy=1;
gbc.gridheight=1;
jp43.add(l303,gbc);
JComboBox c193=new JComboBox();
c193.addItem("India");
c193.addItem("US");
c193.addItem("Australia");
gbc.gridx=1;
gbc.gridy=1;
jp43.add(c193,gbc);
JLabel l313=new JLabel("State");
gbc.gridx=0;
gbc.gridy=2;
jp43.add(l313,gbc);
JComboBox c203=new JComboBox();
c203.addItem("Rajasthan");
c203.addItem("Delhi");
c203.addItem("Maharastra");
gbc.gridx=1;
gbc.gridy=2;
jp43.add(c203,gbc);
JLabel l323=new JLabel("District");
gbc.gridx=0;
gbc.gridy=3;
jp43.add(l323,gbc);
JComboBox c213=new JComboBox();
c213.addItem("jaipur");
c213.addItem("ajmer");
c213.addItem("alwar");
gbc.gridx=1;
gbc.gridy=3;
jp43.add(c213,gbc);
JLabel l333=new JLabel("City/Town");
gbc.gridx=0;
gbc.gridy=4;
jp43.add(l333,gbc);
JTextField tf153=new JTextField(10);
gbc.gridx=1;
gbc.gridy=4;
jp43.add(tf153,gbc);
JLabel l343=new JLabel("Police District");
gbc.gridx=0;
gbc.gridy=5;
jp43.add(l343,gbc);
JComboBox c223=new JComboBox();
c223.addItem("Jaipur");
c223.addItem("Alwar");
c223.addItem("Ajmer");
gbc.gridx=1;
gbc.gridy=5;
jp43.add(c223,gbc);
JLabel l353=new JLabel("Police Circle");
gbc.gridx=0;
gbc.gridy=6;
jp43.add(l353,gbc);
JComboBox c233=new JComboBox();
c233.addItem("India");
c233.addItem("US");
c233.addItem("Australia");
gbc.gridx=1;
gbc.gridy=6;
jp43.add(c233,gbc);
JLabel l363=new JLabel("Police station");
gbc.gridx=0;
gbc.gridy=7;
jp43.add(l363,gbc);
JComboBox c243=new JComboBox();
c243.addItem("Bani Park");
c243.addItem("Raja Park");
c243.addItem("Malviya Nagar");
gbc.gridx=1;
gbc.gridy=7;
jp43.add(c123,gbc);
JLabel l373=new JLabel("Pin No.");
gbc.gridx=0;
gbc.gridy=8;
jp43.add(l373,gbc);
JTextField tf163=new JTextField(10);
gbc.gridx=1;
gbc.gridy=8;
jp43.add(tf163,gbc);
JLabel l383=new JLabel("Phone");
gbc.gridx=0;
gbc.gridy=9;
jp43.add(l383,gbc);
JTextField tf173=new JTextField(10);
gbc.gridx=1;
gbc.gridy=9;
jp43.add(tf173,gbc);
JLabel l393=new JLabel("Leaving Date");
gbc.gridx=0;
gbc.gridy=10;
gbc.gridheight=1;
jp43.add(l393,gbc);
JTextField tf183=new JTextField(10);
gbc.gridx=1;
gbc.gridy=10;
jp43.add(tf183,gbc);
/*JCheckBox cb13=new JCheckBox("Approx");
gbc.gridx=2;
gbc.gridy=10;
jp43.add(cb13);*/
JPanel jp53=new JPanel(); //panel for addin all 3 TitledBorder panels
jp53.setLayout(new BoxLayout(jp53,BoxLayout.X_AXIS));
jp53.add(jp23);
jp53.add(Box.createHorizontalStrut(30)); //giving space between each TitledBorder panel
jp53.add(jp33);
jp53.add(Box.createHorizontalStrut(30));
jp53.add(jp43);
panel3.add(jp53); //adding panel which contains all 3 TitledBorder panels to panel3
JPanel jp63=new JPanel(); //jp63 panel for bottom data
jp63.setBorder(new TitledBorder("Tennancy Start/End"));
JLabel l403=new JLabel("From Date");
jp63.add(l403);
JTextField jtf193=new JTextField(12);
jp63.add(jtf193);
JCheckBox jcb23=new JCheckBox("Approx");
jp63.add(jcb23);
JLabel l413=new JLabel("To Date");
jp63.add(l413);
JTextField jtf203=new JTextField(12);
jp63.add(jtf203);
JCheckBox jcb33=new JCheckBox("Approx");
jp63.add(jcb33);
panel3.add(jp63); //adding bottom details panel jp63 to panel3
//<--------coding for fourth tab--------->
JPanel panel4 = new JPanel();
tabbedPane.addTab("Id of Tenant",null,panel4,"fourth tab");
panel4.setLayout(new FlowLayout());
//adding radiobutton above TitledBorder panel jp14
JPanel jp04=new JPanel();
JLabel l14=new JLabel("Identity Known");
JRadioButton jrb14=new JRadioButton("Yes");
JRadioButton jrb24=new JRadioButton("No");
ButtonGroup bg14=new ButtonGroup();
bg14.add(jrb14);
bg14.add(jrb24);
jp04.add(l14);
jp04.add(jrb14);
jp04.add(jrb24);
//adding TitledBorder panel jp14
JPanel jp14=new JPanel();
jp14.setBorder(new TitledBorder("Identity Detail"));
jp14.setLayout(new GridBagLayout());
gbc.insets=new Insets(5,5,5,5);
JLabel l24=new JLabel("Identity Card");
gbc.gridx=0;
gbc.gridy=0;
jp14.add(l24,gbc);
JTextField jtf14=new JTextField(10);
gbc.gridx=1;
jp14.add(jtf14,gbc);
JLabel l34=new JLabel("Date of Issue");
gbc.gridx=0;
gbc.gridy=1;
jp14.add(l34,gbc);
JTextField jtf24=new JTextField(10);
gbc.insets=new Insets(5,5,5,25);
gbc.gridx=1;
jp14.add(jtf24,gbc);
JLabel l44=new JLabel("Identity Number");
gbc.insets=new Insets(5,5,5,5);
gbc.gridx=2;
jp14.add(l44,gbc);
JTextField jtf34=new JTextField(10);
gbc.gridx=3;
jp14.add(jtf34,gbc);
JLabel l54=new JLabel("Name Of Issuer");
gbc.gridx=0;
gbc.gridy=2;
jp14.add(l54,gbc);
JTextField jtf44=new JTextField(10);
gbc.insets=new Insets(5,5,5,25);
gbc.gridx=1;
jp14.add(jtf44,gbc);
JLabel l64=new JLabel("Place Of Issuer");
gbc.insets=new Insets(5,5,5,5);
gbc.gridx=2;
jp14.add(l64,gbc);
JTextField jtf54=new JTextField(10);
gbc.gridx=3;
jp14.add(jtf54,gbc);
gbc.gridx=0;
gbc.gridy=2;
Box b14=Box.createVerticalBox(); //adding both panels to panel4 in vertical box
b14.add(jp04);
b14.add(jp14);
panel4.add(b14);
//<--------coding for fifth tab--------->
JPanel panel5 = new JPanel();
tabbedPane.addTab("Info Of Other Members",null,panel5,"fifth tab");
JPanel jp15=new JPanel(); //top panel jp15 for details above add delete buttons
jp15.setLayout(new GridBagLayout());
JLabel l15=new JLabel("Name");
gbc.gridx=0;
gbc.gridy=0;
gbc.insets=new Insets(10,10,10,10);
jp15.add(l15,gbc);
JTextField jtf15=new JTextField(10);
gbc.gridx=1;
jp15.add(jtf15,gbc);
JLabel l25=new JLabel("Sex");
gbc.gridx=2;
gbc.insets=new Insets(10,80,10,10);
jp15.add(l25,gbc);
JComboBox jcb15=new JComboBox();
jcb15.addItem("Male");
jcb15.addItem("Female");
gbc.gridx=3;
gbc.insets=new Insets(10,10,10,10);
jp15.add(jcb15,gbc);
JLabel l35=new JLabel("Relation");
gbc.gridx=0;
gbc.gridy=1;
gbc.insets=new Insets(10,10,40,10);
jp15.add(l35,gbc);
JTextField jtf25=new JTextField(10);
gbc.gridx=1;
jp15.add(jtf25,gbc);
JLabel l45=new JLabel("Age");
gbc.gridx=2;
gbc.insets=new Insets(10,80,40,10);
jp15.add(l45,gbc);
JTextField jtf35 =new JTextField(10);
gbc.gridx=3;
gbc.insets=new Insets(10,10,40,10);
jp15.add(jtf35,gbc);
JPanel jp25=new JPanel(); //middle panel jp25 for adding "add" and "delete" buttons
JButton jb15=new JButton("Add");
JButton jb25=new JButton("Delete");
jp25.add(jb15);
jp25.add(jb25);
//adding table #yet to be coded#
Box b15=Box.createVerticalBox();
b15.add(jp15);
b15.add(jp25);
panel5.add(b15); //adding jp15 and jp25 to panel5 in vertical box
//<--------coding for sixth tab--------->
JPanel panel6 = new JPanel();
tabbedPane.addTab("Related To Office",null,panel6,"sixth tab");
panel6.setLayout(new GridBagLayout());
//adding 4 labels and textfields vertically
JLabel l16=new JLabel("Investigation Officer");
gbc.gridx=0;
gbc.gridy=0;
gbc.insets=new Insets(40,40,20,10);
panel6.add(l16,gbc);
JTextField jtf16 =new JTextField(10);
gbc.gridx=1;
gbc.insets=new Insets(40,20,20,40);
panel6.add(jtf16,gbc);
JLabel l26=new JLabel("S.No.");
gbc.gridx=0;
gbc.gridy=1;
gbc.insets=new Insets(10,40,20,10);
panel6.add(l26,gbc);
JTextField jtf26 =new JTextField(10);
gbc.gridx=1;
gbc.insets=new Insets(10,20,20,40);
panel6.add(jtf26,gbc);
JLabel l36=new JLabel("Page No.");
gbc.gridx=0;
gbc.gridy=2;
gbc.insets=new Insets(10,40,20,10);
panel6.add(l36,gbc);
JTextField jtf36 =new JTextField(10);
gbc.gridx=1;
gbc.insets=new Insets(10,20,20,40);
panel6.add(jtf36,gbc);
JLabel l46=new JLabel("Date");
gbc.gridx=0;
gbc.gridy=3;
gbc.insets=new Insets(10,40,20,10);
panel6.add(l46,gbc);
JTextField jtf46=new JTextField(10);
gbc.gridx=1;
gbc.insets=new Insets(10,20,20,40);
panel6.add(jtf46,gbc);
/* Canvas c16=new Canvas(); //creating a rectangle frame for adding image
Image i16=c.createImage(200,100);
gbc.gridx=2;
gbc.gridy=0;
gbc.insets=new Insets(40,20,20,40);
gbc.gridheight=3;
panel6.add(i16,gbc);*/
JButton jb16=new JButton("Browse"); //adding "browse" and "save" buttons
gbc.insets=new Insets(10,20,20,40);
gbc.gridy=3;
panel6.add(jb16,gbc);
JButton jb26=new JButton("Save");
gbc.insets=new Insets(50,20,20,40);
gbc.gridy=4;
panel6.add(jb26,gbc);
//<-------end of sixth tab------->
add(tabbedPane);
//lower panel for cancel button
JPanel jp1=new JPanel();
jp1.setLayout(new FlowLayout(FlowLayout.RIGHT));
JButton can=new JButton("Cancel"); //initialising cancel button
jp1.add(can);
add(jp1,BorderLayout.SOUTH);
class Blistener implements ActionListener // class for action listener
public void actionPerformed(ActionEvent ae)
Object obj=ae.getSource();
try{
if(obj == can) //condition for cancel button
System.exit(0);
}catch(Exception e)
{System.out.println(e);
public class Project
public static void main(String args[]) //main method for the program
Design tabbedwin= new Design();
tabbedwin.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
tabbedwin.setSize(900,700);
tabFirst things first. Next time please use the code formating tags when posting your code.
Secondly, we cant help you do your entire project or more specifically we cant do it for you. We can probably help you with one section at a time.
Thirdly, do not post your entire code. Create a Short, Self Contained, Compilable Example (SSCCE) that demonstrates the problem section, and that is independent of any third party libraries and can compiled instantly and tested.
Now, lets see if we can answer one problem here.
Ques 1. In the form I have one JComboBox of Country and other of State. Now I want it in such a way that whenI select a country from the Country JComboBox ,the corresponding states automatically appears in the State JComboBox.
Ans 1: Use an ItemListener or an ActionListener (javax.swing.event) for this. Once an item is selected, the event will be fired and then you populate your ComboBox with the requried data.
Ques 2. I need to add picture frame in the 6th tab so that the picture shows up when clicked browse and open.
Ans 2: You haven't created the JButton for the browse action, nor have you created the JLabel to show the picture in. Create the JButton, then the JLabel, attach an ActionListener to the button to listen for the button click, open a JFileChooser, select the image file, create an ImageIcon and pass the File object returned to it. Then call the JLabel.setIcon( the ImageIcon) to display the picture. You'll have to store the picture File information some where so can reference it when saving.
Ques 3.I need to add tables in 1st and 5th tab which shows up the details through database when added through several textboxes and combo boxes.
You need to do some reading. The Swing Tutorial has everything you need, from How to use Tables to How to connect to databases. There are also some examples in your JDK installation folder, ie, jdk/demos/jfc/tableExample. Here is the link to the swing tutorial on how to use Tables: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html. You find other useful links there.
ICE
Maybe you are looking for
-
Lenovo 3000 n200 0769 keyboard problem
hey all recently i tackled in a strange problem in my keyboard my left-alt, escape key, ad the combination of right-alt+shift to switch languages doesn't work the combination works only once, and only to change from english to other language but not
-
Dunning Letter XML not displaying XML version of Dunning Letter
I have changed the Output Format for "Dunning Letter Print from Dunning Letter Generate" to XML. When I run the Dunning Letter Generate process, though, the XML output in the Dunning Letter Print from Dunning Letter Generate does not display the XML
-
Hi All This is my first time posting here. I just purchased an Apple TV and have tried to connect it up to the Pioneer Plasma (PDP50). I have a pioneer set top box, pioneer DVD player and recorder and pioneer Receiver. I can see an HDMI plug on the r
-
Help! I am developing a web interface with JSP and Access database. In my database there is an id field which is autonumber field. In jsp page this is the code I use to convert my id: String empId = request.getParameter("id"); int id = Integer.parseI
-
Trasnfer function error usgin ULx library for running a DC motor
HI, I am trying to run a DC motor using Labview's control kit. I want to add a transfer function to the system but once in the loop it gives me an error. The function has an added zero to see changes in the system. It is given by : H(s)= (1/5s +1) /