Hello
I'm trying to add JButton into JTextField like in the image below is it possible or not
and is it possible to do like that in JTable cell
thanks
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hello
I'm trying to add JButton into JTextField like in the image below is it possible or not
and is it possible to do like that in JTable cell
thanks
Last edited by serdar; August 27th, 2011 at 01:18 AM.
Since a textfield is for text I'm sure you cannot add a button to it. Why would you want to do that anyway? Why can't you place the button next to the textfield?
Improving the world one idiot at a time!
the image you're give is in your computer we can't see it.
after posting this thread I asked this question to my other friends and one of them told that it is possible by add() method
I tried it and it works
so I think this will helpful to you tooimport java.awt.*; import javax.swing.*; public class ButtonInTextField extends JFrame { JTextField tekst; JButton knopka; Container c; public ButtonInTextField() { c = getContentPane(); c.setLayout(new FlowLayout()); tekst = new JTextField (10); knopka = new JButton(""); //tekst.setHorizontalAlignment(15); //tekst.setLayout(new FlowLayout()); tekst.setLayout(new BorderLayout()); tekst.add(knopka,BorderLayout.EAST); c.add(tekst); setSize( 300, 200 ); setVisible( true ); } public static void main( String args[] ) { ButtonInTextField rustiX = new ButtonInTextField(); rustiX.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); } }
I wanted to do something like JComboBox
wow that is weirddddd but cool lol it does kinda look like a combobox