JTextField in swing out of bounds

I was trying to create form using swing, but the created input field is out of bounds.

My code

package lista_designer_1; import javax.swing.JFrame; import javax.swing.JTextField; public class lista_designer_2 extends JFrame { JTextField text1; public static void main(String[] args) { lista_designer_2 frame1 = new lista_designer_2(); frame1.setSize(450, 300); frame1.setVisible(true); } public lista_designer_2() { super("Hello World"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); text1 = new JTextField(); text1.setBounds(10, 10, 76, 21); add(text1); setVisible(true); } }

After running this code it looks like this:

JTextField in swing out of bounds

How can i fix it?

-------------Problems Reply------------

You can use layout managment see A Visual Guide to Layout Managers
For examples see Swing Layout Examples.

Example to use FlowLayout layout:

getContentPane().setLayout(new FlowLayout ());

Try setLayout(null); This will remove the LayoutManager from your JFrame which causes the textfield to appear linke this.

Category:java Views:1 Time:2018-02-12

Related post

  • Java- String index out of bounds exception " String index out of Range" 2010-10-24

    I am new to java, and going to bite the bullet by asking what is I am sure, a dumb question. I created some methods, and simply wanted to call them in main. I am getting an error for the while loop in the main method. The compiler is saying " Excepti

  • Why do compilers not warn about out-of-bounds static array indices? 2008-12-20

    A colleague of mine recently got bitten badly by writing out of bounds to a static array on the stack (he added an element to it without increasing the array size). Shouldn't the compiler catch this kind of error? The following code compiles cleanly

  • Array index out of bound in C 2009-03-22

    Why does C differentiates in case of array index out of bound #include <stdio.h> int main() { int a[10]; a[3]=4; a[11]=3;//does not give segmentation fault a[25]=4;//does not give segmentation fault a[20000]=3; //gives segmentation fault return

  • How can I find the location of a "List index out of bounds" error in Delphi 2009-07-28

    In Delphi 2009, my program now produces a "List index out of bounds" error. It generates a popup box: I'm using the "Debug" Build Configuration that has all the Runtime error checking turned on. But this does not capture the error before it happens.

  • C++ Accesses an Array out of bounds gives no error, why? 2009-08-06

    I am assigning values in a C++ program out of the bounds like this: #include <iostream> using namespace std; int main() { int array[2]; array[0] = 1; array[1] = 2; array[3] = 3; array[4] = 4; cout << array[3] << endl; cout <<

  • AppController error: Index out of bounds 2009-08-19

    I overrode the following target in my TFS build file to run various tasks that set up databases, import data, etc., etc. in Visual Studio 2008 - the aim was to stop only the website associated with an application pool on the server instead of stoppin

  • Nagios (Return code of 255 is out of bounds) 2009-09-22

    I am getting the error (Return code of 255 is out of bounds) on the http://localhost/nagios But whe I run the command from #bash.. It runs fine any suggestions Regards --------------Solutions------------- If you're using NRPE and receiving a 'NRPE: U

  • Index out of bounds of array error when parsing font string? 2009-10-05

    i keep getting an "Index is out of bounds of array" error on line # 574 which is: label.Font = new Font(fontNameFields[0], Single.Parse(fontNameFields[1])); ... The following text file i am parsing contains this exact information: Label "hi tyler" 23

  • Index was out of bounds. For Loops and Arrays 2009-11-23

    I'm trying to create two arrays filled with a set of strings from two tables in a database and then compare them. For example: array1[0]="1101" and array2[0]="0110" If both respective characters equals 1 then perform an action. But when I run this co

  • WaveChannel32 gives me an exception: Offset and length were out of bounds 2010-01-03

    With the NAudio library I'm trying to mix some audio using a WaveMixerStream32 so I'm using WaveChannel32 to feed it the streams in the proper format. I've got an exception with the following message: Offset and length were out of bounds for the arra

  • extending AS3's Array access operators to 'wrap' out-of-bound index values 2010-01-17

    I'd really like to be able to make Flash's array access syntax 'wrap' over the array's bounds. Lengthy explanation - var array:Array = ['a','b','c','d','e','f']; To keep things simple, the first index is 0, and its value is the first letter, 'a'. To

  • ELF shared library: relocation offset out of bounds 2010-02-02

    There is a software package elfutils which includes a program called eu-elflint for checking ELF binaries (just as lint for C - hence the name). Just for curiosity I have checked our own shared libraries with this tool and it found a lot of issues, e

  • Actionscript VerifyError: The ABC data is corrupt, attempt to read out of bounds 2010-03-03

    Getting a VerifyError using the TweenMax lib when calling TweenMax.to. This error doesn't seem to be specific to TweenMax (we've found other people having errors with unrelated code). Perhaps someone has some insight into what this error means and wh

  • Java: Preventing array going out of bounds 2010-03-12

    I'm working on a game of checkers, if you want to read more about you can view it here; http://minnie.tuhs.org/I2P/Assessment/assig2.html When I am doing my test to see if the player is able to get to a certain square on the grid (i.e. +1 +1, +1 -1 .

  • Out of bounds exception 2010-05-04

    public override Models.CalculationNode Parse(string expression) { var calNode = new Models.CalculationNode(); int i = expression.Length; char[] x = expression.ToCharArray(); string temp = ""; //Backwards assembly of the tree //Right Node while (!IsOp

  • Error #2006: The supplied index is out of bounds,in flex 2010-05-20

    Hi I have created a component for alert box and I am using it in main application,` <mx:Style> .myButton { overSkin:Embed("folder/over.png"); upSkin:Embed(source="folder/up.png"); downSkin:Embed(source="folder/down.png"); } </mx:Style>

  • Are vectors more rigorous at checking out of bounds than heap arrays? 2010-06-16

    How rigorous is the bounds checking on vectors compared to heap arrays? How exactly is it checking bounds and how does that compare with how a heap array is checked? --------------Solutions------------- A vector will do bounds checking if you use the

  • Android SQLite Cursor out of bounds exception on SELECT count(*) FROM table 2010-06-22

    The following function is giving me an out of bounds exception... public void count(){ SQLiteDatabase db = table.getWritableDatabase(); String count = "SELECT count(*) FROM table"; Cursor mcursor = db.rawQuery(count, null); int icount = mcursor.getIn

  • UITableView in Popover scrolls out of bounds when keyboard is opened 2010-06-25

    I have a popover that contains a UITableView. This UITableView has a cell with a text field in it: When the popover opens near the bottom of the screen, and I tap the text field to edit it, the keyboard comes up, and the popover moves up to avoid bei

  • Java Array Index out of Bounds 2010-07-11

    OK so I seem to be getting an Array Index out of Bounds error in a part of my code. Specifically in lines 85-102... My code: http://www.sosos.pastebin.com/f0JQBWui I just want it to check for blocked tiles AHEAD of time that way my sprite doesn't mov

  • When trying to select a column of type BLOB, SQLStatement throws a RangeError #2006: The supplied index is out of bounds 2010-08-30

    var imageData:ByteArray = new ByteArray(); var headshotStatement:SQLStatement = new SQLStatement(); headshotStatement.sqlConnection = dbConnection; var headshotStr:String = "SELECT headshot FROM ac_images WHERE id = " + idx; headshotStatement.text =

  • How to iterate initialized enumerated types with Delphi 6 and avoid the "out of bounds" error? 2010-09-28

    I am using Delphi 6 Professional. I am interfacing with a DLL libraty that declares an enumberated type as follows: TExtDllEnum = (ENUM1 = $0, ENUM2 = $1, ENUM3 = $2, ENUM4 = $4, ENUM5 = $8, ENUM6 = $10); As you can see the initialized values are not

  • Java: Array Index Out of Bounds Exception 2010-10-16

    System.out.print("Enter an integer: "); Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int lArray = x - 2; int[] newArray = new int[lArray]; System.out.println("Let's display all possible integers..."); for (int i = 0; i <= newArray.le

  • Java recursive binary search throwing out of bounds exception? 2010-10-25

    Hey, I have been asked to write a recursive binary search for my data structure class in university, but i'm having a slight problem. When i search for a number that is out of bounds (over 10 in this case) it throws an out of bounds exception. I unde

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.197 (s). 11 q(s)