paintcomponent

Java Swing questions regarding GridLayout and paintComponent methods

Within this program, we need to create an 8x8 grid of "LifeCell" widgets. The instructor did not mention that the widgets had to be an object of Shape so I went ahead and used the GridLayout class. The GridLayout class works fine (as well as I know, since there is no visual aid to confirm.) The object of the program is to play the Game o...

JPanel: both implementing my own paintComponent() and rendering children doesn't work

I'm extending a JPanel to display a game board, and adding a JEditorPane at the bottom to hold some status text. Unfortunately, the game board renders just fine, but the JEditorPane is just a blank gray area until I highlight the text in it, when it will render whatever text is highlighted (but not the rest). If I'm understanding Swing...

Non-Working paintComponent method

Code : import javax.swing.*; import java.awt.*; public class firstGUI extends JPanel { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(500,500); frame.setVisible(true); } public void paintComponent(Gr...

drawing a graph in a JPanel in Net Beans

Hi Is there a possible way to override the paintComponent() method in the auto-generated GUI code in NetBeans? I managed to manually draw a graph without using the drag-and-drop components, and I need to make adjustments (e.g. adding radio button group) which I find really time consuming and tedious work. I created a GUI using the Net...

Custom JComponent with embedded Swing components not positioned in exported image.

I have a funny problem trying to export custom Java JPanels to a PNG file. The export process of the components I've been writing up until now have worked flawlessly. My JPanels include custom-written JComponents (e.g., override paintComponent(Graphics g) and write what I have to). The export process looks like the following (of the e...