Ok so im currenly having a problem implementing a JTextField onto a graphics windows/frame, some source code:
//intialise variable
JTextField port_textbox = new JTextField(15);
//adding in to my menu class:
public MenuManagement() {
Main.f.add(port_textbox);
port_textbox.setBounds(100,100,100,100);
port_textbox.setVisible(false);
}
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.