My friend, you absolutely need to be using MigLayout. It is a free download available at MigLayout.com. It is far more flexible, and far easier to use than any of the layout managers provided by Java( for example: what took me 135 lines of code with GroupLayout, took 31 with Mig). It takes maybe 15 to 20 minutes to learn to create amazing GUIs. There are lots of examples on the website also. Trust me, try it.
P.S. You can cast...
User Profile
Collapse
-
Well Jos, in the process of writing a small example for you I discovered the problem. For some reason setting more than one attribute at a time with SimpleAttribute Set causes the JTextPane to get confused and lose the text. So I modified the code to change only one attribute at a time, and voila. Thanks for the help
-HarleyLeave a comment:
-
I have tried that, with the same result. I combed the API and thought this would work, but it does the same thing - prints only the tags.
...Code:HTMLEditorKit kit = (HTMLEditorKit)textPane.getEditorKit(); HTMLDocument doc = (HTMLDocument)textPane.getDocument(); StringWriter writer = new StringWriter(); try{ kit.write( writer, doc, 0, doc.getLength() ); System.out.println( writer.toString()Leave a comment:
-
JTextPane trouble
I am an email client. I want to be able to send the emails in rich-text format, so the GUI uses a JTextPane as the Text Component in which the user's message is entered. The problem is that when I call textPane.getTex t() the returned string contains only HTML tags, no actual text. So my question is how do I get the HTML content from a JTextPane, including tags and text, to use in a JavaMail application? Here is the jist of what I have tried:... -
Trouble with animation
I am currently working on a GUI. The idea is that when the user clicks a given button, that portion of the interface will slide into view from the main JFrame. The code I have written and included constitutes an initial test at the basic mechanics of animation. Everything works alright with my code, but the animation seems choppy. Any tips or tricks regarding good Java animation are very much appreciated.
Here is my code:
... -
If I understand you right, you want to decrease the coke count every time you increase the token count. So try this.
...Code:public void insertToken (int number_tokens) { if (number_cans - number_tokens < 0) //not enough cokes left { System.out.println (/*some error message*/); } else { tokens -= number_tokens;Leave a comment:
-
OutOfMemoryError: Java Heap Space
I have a program that shows a thumbnail of an image. If the user clicks on the thumbnail a new JFrame is opened that shows the full size image. If the image is larger than the screen, it gets scaled to the the size of the screen.
Functionally, the program works well. However, when testing I found that after clicking the thumbnails of several images (and subsequently closing their viewing frames), I get an java.lang.OutOf MemoryError:... -
-
Nevermind Jos. I'm an idiot. In line 41 I typed value instead of newValue. Thanks for the help.Leave a comment:
-
Thanks for the tip Jos. Here is what I've come up with. I decided I would try to change a given pixel's alpha value based on it's distance from the center of the image, which should create a radial blending effect. I've used the getRGB/setRGB methods as you suggested, but when I run the code, the image doesn't blend. It looks just like the normal image. I've tried changing the AlphaComposite setting of the Graphics2D object with no effect. I've...Leave a comment:
-
Need help with Blending
I am creating a custom JPanel that displays an image in the background on top of a custom color. What I want to do is to have the edges of the top image blend into the background color. Only the outer 20 pixels or so. I have to do this at runtime due to the nature of the program, so using Photoshop or the like isn't an option. I've tried something like this:
...Code:int red = value; int green = value; int blue = value;
-
I found that using TextLayout and calling getBounds returns a fairly accurate bounding rectangle. Thank you for the help.Leave a comment:
-
Trouble returning text height
I am trying to create custom buttons for an application. I have created a class that extends JButton and overridden the paintComponent( ) method. My problem is that I cannot find a way to return the pixel height of the text that will be put on the button, and therefore I am not able to center the text vertically within the button. I have tried something like this:
...Code:GlyphVector gv = myFont.createGlyphVector (g2d.getFontRenderContext(),
-
Okay. I changed my code to allow the panel to be displayed before calling the getGraphics method. I added a method to the end of my DemoPane class to draw the image after the panel is shown. So now the panelImages.get Graphics call doesn't return null (according to my debugger), however I am still getting a NullPointerExec ption at g.drawImage (imageList[0], 0, 0, null). Thank you again for your help.
Here is my revised code:...Leave a comment:
-
Well I messed around with it some more and found that when I call the Graphics g = panelImages.get Graphics() , the g object that is returned is null. But I can't figure out why it's null. I know that the JPanels have a graphics context. And the Java API says the way to get that object is through the getGraphics method. So I'm really not sure what I'm doing wrong....Leave a comment:
-
This is the message my runtime I/O gives me.
Exception in thread "main" java.lang.NullP ointerException
at DemoPane.<init> (ItemPictureVie wer.java:90)
at ItemPictureView er.main(ItemPic tureViewer.java :20)
Through my feeble attempts at debugging, I found that if I comment-out the line
g.drawImage (imageList[1], 1, 1, panelImages) then the exception doesn't occur. But that actually...Leave a comment:
-
Can't draw graphics.
I am trying to write a simple program which will allow users to view pictures. I am loading an image as an icon, then assigning that ImageIcon to an Image object. Then i get the graphics context of my panel. Finally I am trying to use the drawImage method to draw the Image object to the panel. However I keep getting a nullpointerexce ption when I run the program. I think it has something to do with the drawImage statement I use but I don't know.... -
Well, I finally figured it out. I was missing an extends JPanel modifier. Thanks for the help.Leave a comment:
-
I removed the second class from the primary class as you suggested. But I still get the cannot find symbol error at pane.addTab("Co nvert", panel_1) . I can add the tab if I use a JComponent (e.g. JButton), but I cant add the panel_1 object. Any ideas?...Leave a comment:
-
The only problem with that solution is that the program is a lab project and must be submitted as one file. So I can't write a separate class file, I have to have them all nested....Leave a comment:
No activity results to display
Show More
Leave a comment: