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
http://www.javaprogrammingforums.com...1&d=1314425082
thanks
Printable View
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
http://www.javaprogrammingforums.com...1&d=1314425082
thanks
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?
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 tooCode java:import 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 :D lol it does kinda look like a combobox