Ok so im currenly having a problem implementing a JTextField onto a graphics windows/frame, some source code:
1 2
| JTextField port_textbox = new JTextField(15);
|
1 2 3 4 5 6
| public MenuManagement() { Main.f.add(port_textbox); port_textbox.setBounds(100,100,100,100); port_textbox.setVisible(false); }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| public void draw(Graphics2D g2d) { g2d.drawImage(getBgImg(), 0, 0, null); g2d.drawImage(getFog1(), fogX, fogY, null); g2d.setColor(Color.WHITE); g2d.drawString("IP: ", 100, 320); g2d.drawString("Port: ", 100, 350); g2d.drawString("Back", 100, 380); g2d.fillRect(0, 0, 500, 500); ip_textbox.setVisible(true); port_textbox.setVisible(true);
g2d.drawRect(90, 300, 250, 30); g2d.drawImage(getTitleImage(), 60, 0, null); } |
EDIT: forgot to say what the problem was, so what happens is...whenever i click a textbox to start typing information into it, the text box its starts a flickering effect. The text itself is being entered, i know this because when it flickers i can see the text for a short amount of time.