jcomponent

All parts of my Printable Swing component doesn't print

I'm trying to do a printable component (an invoice document). I use JComponent instead of JPanel because I don't want a background. The component has many subcomponents. The main component implements Printable and has a print-method that is calling printAll(g) so that all subcomponents should be printed. But my subcomponents doesn't pri...

How to keep the highlight border of a JComponent, when custom border is set

I have a JTextField, where I've set some custom properties: nameField.setPreferredSize(new Dimension(275,40)); nameField.setBackground(bgColor); nameField.setForeground(txtColor); nameField.setFont(new Font("HelveticaNeue",Font.PLAIN,22)); nameField.setBorder(BorderFactory.createLineBorder(Color.WHITE, 2)); When the component has focu...

Running JPanels in their own threads.

I'm having a bit of trouble with Swing components. In one JFrame, I have a GLCanvas and a JEditorPane separated by a JSplitPane. This configuration makes display response choppy in both panels. However, when I place the GLCanvas and JEditorPane each in their own JFrame, display response is great. I would assume this is because, in ...

Forcing a JComponent to be square when being resized

I have a JComponent that does custom drawing, and overrides the following methods: public Dimension getPreferredSize() { return new Dimension(imageWidth, imageHeight); } public Dimension getMinimumSize() { return new Dimension(imageWidth, imageHeight); } Where imageWidth and imageHeight are the actual size of the image. I ha...

Difference between JPanel, JFrame, JComponent, and JApplet

Hi, im making a physics simulator for fun and i was looking up graphics tutorials when i tried to figure out the difference between all these J's. could somebody elaborate on them or perhaps provide a link to a helpful source? ...

Displaying a JComponent inside a JPanel on a JFrame

I am failing to display a JComponent inside a JPanel on a JFrame. The following does not work. JComponent component = ... panel.add(component, BorderLayout.CENTER); frame.add(panel, BorderLayout.CENTER); But if I add the JComponent to the JFrame[like frame.add(component, BorderLayout.CENTER);], it displays the contents. Any ideas ...

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...

The contents of my JComponent only refresh after a manual resize

I am trying to figure out why my JComponent refreshes when I manually drag my window, but it doesn't refresh when I call repaint or revalidate. The data is ready to be displayed, but it just won't show until I manually resize. Can anybody give some suggestions about what I can do or does this sound like it isn't a Swing problem since I t...

Prevent Java from repainting the content of a JPanel while updating

I have a JPanel which contains a lot of child components. While updating\adding new components to the parent JPanel I'd like to prevent it from repainting, how can this achieved? ...