jcomponent

Change color of JComponent after paintComponent has finished

廉价感情. 提交于 2020-01-06 11:44:09
问题 I am testing one small widget class that extends JComponent the constructor for the widget contains one vector and sets PreferredSize of the component, then there is the paintComponent: public void paintComponent(Graphics g){ g.setColor(Color.RED); g.drawString("this is text one", 10, 10); //here I draw some shapes based on the //vector size and integers } } the component is drawn correctly and after that i call some other methods in main, when the methods finish their jobs i call widget

Custom JComponent size default to zero?

こ雲淡風輕ζ 提交于 2020-01-05 12:58:14
问题 I'm trying to add a custom scrollable JComponent to a JFrame. JScrollPane sp = new JScrollPane(hg); frame.getContentPane().add(sp, BorderLayout.CENTER); hg is my custom component. The problem is that my custom component is not displayed. However, if I do this: hg.setBounds(0, 0, 800, 600); Then it will be displayed. But of course I don't want to set size explicitly. I want it to fit in the center of the frame. In my custom JComponent class, I override getPreferredSize(): private Dimension

JFrame that has multiple layers

筅森魡賤 提交于 2020-01-03 21:18:05
问题 I have a window that has two layers: a static background and a foreground that contains moving objects. My idea is to draw the background just once (because it's not going to change), so I make the changing panel transparent and add it on top of the static background. Here is the code for this: public static void main(String[] args) { JPanel changingPanel = new JPanel() { @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.RED); g.fillRect(100, 100,

JFrame that has multiple layers

戏子无情 提交于 2020-01-03 21:16:39
问题 I have a window that has two layers: a static background and a foreground that contains moving objects. My idea is to draw the background just once (because it's not going to change), so I make the changing panel transparent and add it on top of the static background. Here is the code for this: public static void main(String[] args) { JPanel changingPanel = new JPanel() { @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.RED); g.fillRect(100, 100,

Netbeans swing not displaying components correctly

一个人想着一个人 提交于 2020-01-03 05:25:11
问题 Hello I have this weird problem with my laptop Windows 8 64 bit. Netbeans is not showing the swing components correctly. http://postimg.org/image/qdean40pb/ As you can see the text is not clear(HOST,connect button,disconnect button) and I can't find a reason for this. I thought maybe this is a problem with netbeans 8.0 so I tried installing 7.3 and I had the same problem even with the installer itself.(The next button and other text) http://postimg.org/image/3nf5u4hhr/ I am using netbeans 7.3

Netbeans swing not displaying components correctly

不想你离开。 提交于 2020-01-03 05:25:07
问题 Hello I have this weird problem with my laptop Windows 8 64 bit. Netbeans is not showing the swing components correctly. http://postimg.org/image/qdean40pb/ As you can see the text is not clear(HOST,connect button,disconnect button) and I can't find a reason for this. I thought maybe this is a problem with netbeans 8.0 so I tried installing 7.3 and I had the same problem even with the installer itself.(The next button and other text) http://postimg.org/image/3nf5u4hhr/ I am using netbeans 7.3

How do I get the image paint/paintComponent generates?

与世无争的帅哥 提交于 2020-01-01 05:56:26
问题 I have a quick question. How do I get the image generated by a JComponent.paint or paintComponent? I have a JComponent which I use as a 'workspace' and where I have overwritten the paintComponent method to my own. The thing is that my workspace JComponent also has children which has their own paintComponent methods. So when Swing renders my workspace component, it renders the workspace graphics and then its childrens'. However, I want to get the image my workspace component generates (which

How do I get the image paint/paintComponent generates?

六月ゝ 毕业季﹏ 提交于 2020-01-01 05:56:14
问题 I have a quick question. How do I get the image generated by a JComponent.paint or paintComponent? I have a JComponent which I use as a 'workspace' and where I have overwritten the paintComponent method to my own. The thing is that my workspace JComponent also has children which has their own paintComponent methods. So when Swing renders my workspace component, it renders the workspace graphics and then its childrens'. However, I want to get the image my workspace component generates (which

File browser component for Java swing

冷暖自知 提交于 2020-01-01 05:23:09
问题 Has anyone come across a fully customizable (compatible with all standard LnF), fast file browser component for Java Swing ? I should be able to place this component to Netbeans UI palette and drag and drop in to any JPanel while designing the UI. Also it should support directory, single file, multiple file selection along with file type filtering. There must be something because I have seen this in applications like jEdit etc. Note that I am not asking about a dialog box like JFileChooser

Painting multiple JComponent on JPanel not working

一曲冷凌霜 提交于 2019-12-25 14:14:52
问题 I just don't get this. I want to add Highlight extends JComponent objects to a PdfPage extends JPanel but the Highlight components are simple not painted. I can see that their paint() and paintComponent() methods are getting called in correct order but they do not show. The only thing that fixes my problem is to add: for(Component component : this.getComponents()) { component.paint(g); } into the PdfPanel.paint() method but this is not how I want to do that. I want PdfPage extends JPanel to