Java SWT ScrolledForm Background Color - java

I am having an issue with a ScrolledForm. I am trying to change the background and foreground colour for a Label defined in the body of the ScrolledForm, however it doesn't seem to be working.
In my code snippet, I would like lblWhat to have a black background and white foreground.
Here is my code snippet:
ScrolledForm scrldfrmNewScrolledform = formToolkit.createScrolledForm(parent);
scrldfrmNewScrolledform.setLayoutData(gd);
scrldfrmNewScrolledform.setFont(SWTResourceManager.getFont("Segoe UI", 16, SWT.NORMAL));
scrldfrmNewScrolledform.setBackground(SWTResourceManager.getColor(SWT.COLOR_WIDGET_BACKGROUND));
scrldfrmNewScrolledform.getBody().setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
scrldfrmNewScrolledform.setImage(SWTResourceManager.getImage(EPRForm.class, "/icons/AFCCEPR.png"));
scrldfrmNewScrolledform.setBounds(10, 10, 430, 280);
formToolkit.paintBordersFor(scrldfrmNewScrolledform);
scrldfrmNewScrolledform.setText("ePR (electronic Purchase Request)");
Label lblName = new Label(scrldfrmNewScrolledform.getBody(), SWT.NONE);
lblName.setBounds(10, 21, 55, 15);
formToolkit.adapt(lblName, true, true);
lblName.setText("Name:");
text = new Text(scrldfrmNewScrolledform.getBody(), SWT.BORDER);
text.setBounds(71, 15, 269, 21);
formToolkit.adapt(text, true, true);
Label lblWhat = new Label(scrldfrmNewScrolledform.getBody(), SWT.None);
lblWhat.setBounds(10, 35, 100, 15);
lblWhat.setBackground(SWTResourceManager.getColor(SWT.COLOR_BLACK));
lblWhat.setForeground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
formToolkit.adapt(lblWhat, true, true);
lblWhat.setText("What do you want?");
Label lblItem = new Label(scrldfrmNewScrolledform.getBody(), SWT.None);
lblItem.setBounds(10, 55, 100, 15);
formToolkit.adapt(lblItem, true, true);
lblItem.setText("Items to be Ordered*");
txtItems = new Text(scrldfrmNewScrolledform.getBody(), SWT.BORDER | SWT.WRAP | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL);
txtItems.setBounds(10, 60, 338, 84);
formToolkit.adapt(txtItems, true, true);

You seem to be using FormToolkit. The FormToolkit.adapt method forces the control colors to the colors set for the form (normally white background and black text).
For a single control you could try calling setBackground and setForeground after the adapt call.
You can set the colors for the entire form with
FormColors colors = toolkit.getColors();
colors.setBackground(...);
colors.setForeground(...);

Related

Slick2d drawstring draws a box, no text

I've seen references to this error before but no solution.
Where I am drawing the text, there is only a solid box of the specified color being drawn.
The code is like this:
TrueTypeFont font;
Font awtFont = new Font("Arial Unicode MS", Font.BOLD, 12); //name, style (PLAIN, BOLD, or ITALIC), size
font = new TrueTypeFont(awtFont, true); //base Font, anti-aliasing true/false
while (!Display.isCloseRequested() ) {
render();
font.drawString(10, 10, "ABC123", Color.black); //x, y, string to draw, color
//ENABLE THESE:
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//RENDER LIKE THIS:
glPushMatrix();
bodyPosition = body.getPosition().mul(30);
glTranslatef(Position.x, Position.y, 0);
GL11.glDisable(GL11.GL_TEXTURE_2D);
glPopMatrix();

Java Titled Border

Is there any way to set font of the title of the titled border in java swing?
JPanel panelDOB = new JPanel();
panelDOB.setBorder(new TitledBorder(new LineBorder(new Color(171, 173, 179)), "DATE OF BIRTH", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(109, 109, 109)));
panelDOB.setBackground(Color.WHITE);
panelDOB.setFont(new Font("Tw Cen MT", Font.PLAIN, 12));
sl_panelFac.putConstraint(SpringLayout.NORTH, panelDOB, 6, SpringLayout.SOUTH, txtNationality);
sl_panelFac.putConstraint(SpringLayout.WEST, panelDOB, 10, SpringLayout.WEST, panelFac);
sl_panelFac.putConstraint(SpringLayout.SOUTH, panelDOB, 61, SpringLayout.SOUTH, txtNationality);
sl_panelFac.putConstraint(SpringLayout.EAST, panelDOB, 196, SpringLayout.WEST, panelFac);
panelFac.add(panelDOB);
panelDOB.setLayout(new SpringLayout());
This is answered by simply looking up TitledBorder in the Java API.
There you'll find two constructors (here's one),
public TitledBorder(Border border,
String title,
int titleJustification,
int titlePosition,
Font titleFont)
that take a font as well as a method for setting the font,
public void setTitleFont(Font titleFont)
Alternatively, there are two methods in the BorderFactory that creates a TitledBorder with your selected font, again available through the Java API.
public static TitledBorder createTitledBorder(Border border,
String title,
int titleJustification,
int titlePosition,
Font titleFont)
I'm frankly a little surprised that you didn't look into the API before coming here.

Java Graphics2D Path2D Simplify or call from separate class

I'm wondering if I can clean up my code somehow using a list or call it from another class because I have a lot of exact Path2D coordinates just cluttering my paintComponent.
public void paintComponent(Graphics g)
{ Graphics2D g2=(Graphics2D)g;
super.paintComponent(g2);
//Background
Rectangle background = new Rectangle(0,0,getWidth(),getHeight());
Color skyBlue = new Color(135,206,235);
g2.setColor(skyBlue);
g2.fill (background);
Path2D bunny = new Path2D.Float();
bunny.moveTo(486.63,530.25);
bunny.lineTo(483.13,532.25);
bunny.lineTo(483.13,532.25);
bunny.lineTo(483.13,532.25);
bunny.lineTo(477.38,534.38);
bunny.lineTo(477.38,534.38);
bunny.lineTo(477.38,534.38);
bunny.lineTo(469.88,535.50);
bunny.lineTo(469.88,535.50);
bunny.lineTo(469.88,535.50);
bunny.lineTo(453.50,536.38);
bunny.lineTo(453.50,536.38);
bunny.lineTo(453.50,536.38);
bunny.lineTo(437.63,537.75);
bunny.lineTo(437.63,537.75);
bunny.lineTo(437.63,537.75);
bunny.lineTo(418.75,539.25);
bunny.lineTo(418.75,539.25);
bunny.lineTo(418.75,539.25);
bunny.lineTo(405.00,539.88);
bunny.lineTo(405.00,539.88);
bunny.lineTo(405.00,539.88);
bunny.lineTo(392.25,539.63);
bunny.lineTo(392.25,539.63);
bunny.lineTo(392.25,539.63);
bunny.lineTo(385.50,539.13);
bunny.lineTo(385.50,539.13);
bunny.lineTo(385.50,539.13);
bunny.lineTo(381.00,538.63);
bunny.lineTo(381.00,538.63);
bunny.lineTo(381.00,538.63);
bunny.lineTo(375.50,537.88);
bunny.lineTo(375.50,537.88);
bunny.lineTo(375.50,537.88);
bunny.lineTo(370.13,537.75);
bunny.lineTo(370.13,537.75);
bunny.lineTo(370.13,537.75);
bunny.lineTo(364.88,537.13);
bunny.lineTo(364.88,537.13);
bunny.lineTo(364.88,537.13);
bunny.lineTo(357.75,536.63);
bunny.lineTo(357.75,536.63);
bunny.lineTo(357.75,536.63);
bunny.lineTo(353.50,536.25);
bunny.lineTo(353.50,536.25);
bunny.lineTo(353.50,536.25);
bunny.lineTo(347.88,535.75);
bunny.lineTo(347.88,535.75);
bunny.lineTo(347.88,535.75);
bunny.lineTo(341.75,535.38);
bunny.lineTo(341.75,535.38);
bunny.lineTo(341.75,535.38);
bunny.lineTo(336.25,534.38);
bunny.lineTo(336.25,534.38);
bunny.lineTo(336.25,534.38);
bunny.lineTo(328.25,532.88);
bunny.lineTo(328.25,532.88);
bunny.lineTo(328.25,532.88);
bunny.lineTo(323.00,530.63);
bunny.lineTo(323.00,530.63);
bunny.lineTo(323.00,530.63);
bunny.lineTo(318.50,528.13);
bunny.lineTo(318.50,528.13);
bunny.lineTo(318.50,528.13);
bunny.lineTo(313.50,524.63);
bunny.lineTo(313.50,524.63);
bunny.lineTo(313.50,524.63);
bunny.lineTo(311.63,521.25);
bunny.lineTo(311.63,521.25);
bunny.lineTo(311.63,521.25);
bunny.lineTo(310.38,516.25);
bunny.lineTo(310.38,516.25);
bunny.lineTo(310.38,516.25);
bunny.lineTo(309.88,513.00);
bunny.lineTo(309.88,513.00);
bunny.lineTo(309.88,513.00);
bunny.lineTo(311.13,508.38);
bunny.lineTo(311.13,508.38);
bunny.lineTo(311.13,508.38);
bunny.lineTo(312.25,505.38);
bunny.lineTo(312.25,505.38);
bunny.lineTo(312.25,505.38);
bunny.lineTo(313.00,502.63);
bunny.lineTo(313.00,502.63);
bunny.lineTo(313.00,502.63);
bunny.lineTo(314.75,500.00);
bunny.lineTo(314.75,500.00);
bunny.lineTo(314.75,500.00);
bunny.lineTo(316.38,497.63);
bunny.lineTo(316.38,497.63);
bunny.lineTo(316.38,497.63);
bunny.lineTo(316.25,494.00);
bunny.lineTo(316.25,494.00);
bunny.lineTo(316.25,494.00);
bunny.lineTo(314.88,491.00);
bunny.lineTo(314.88,491.00);
bunny.lineTo(314.88,491.00);
bunny.lineTo(312.88,486.38);
bunny.lineTo(312.88,486.38);
bunny.lineTo(312.88,486.38);
bunny.lineTo(310.13,480.00);
bunny.lineTo(310.13,480.00);
bunny.lineTo(310.13,480.00);
bunny.lineTo(308.50,474.75);
bunny.lineTo(308.50,474.75);
bunny.lineTo(308.50,474.75);
bunny.lineTo(306.63,468.75);
bunny.lineTo(306.63,468.75);
bunny.lineTo(306.63,468.75);
bunny.lineTo(305.25,462.75);
bunny.lineTo(305.25,462.75);
bunny.lineTo(305.25,462.75);
bunny.lineTo(304.88,456.63);
bunny.lineTo(304.88,456.63);
bunny.lineTo(304.88,456.63);
bunny.lineTo(304.88,449.88);
bunny.lineTo(304.88,449.88);
bunny.lineTo(304.88,449.88);
bunny.lineTo(305.00,446.38);
bunny.lineTo(305.00,446.38);
bunny.lineTo(305.00,446.38);
bunny.lineTo(305.88,442.75);
bunny.lineTo(305.88,442.75);
bunny.lineTo(305.88,442.75);
bunny.lineTo(307.63,437.88);
bunny.lineTo(307.63,437.88);
bunny.lineTo(307.63,437.88);
bunny.lineTo(309.25,434.50);
bunny.lineTo(309.25,434.50);
bunny.lineTo(309.25,434.50);
bunny.lineTo(310.50,432.25);
bunny.lineTo(310.50,432.25);
bunny.lineTo(310.50,432.25);
bunny.lineTo(311.63,430.25);
bunny.lineTo(311.63,430.25);
bunny.lineTo(311.63,430.25);
bunny.lineTo(312.50,427.25);
bunny.lineTo(312.50,427.25);
bunny.lineTo(312.50,427.25);
bunny.lineTo(312.63,424.00);
bunny.lineTo(312.63,424.00);
bunny.lineTo(312.63,424.00);
bunny.lineTo(311.75,421.25);
bunny.lineTo(311.75,421.25);
bunny.lineTo(311.75,421.25);
bunny.lineTo(309.38,417.88);
bunny.lineTo(309.38,417.88);
bunny.lineTo(309.38,417.88);
bunny.lineTo(307.00,415.00);
bunny.lineTo(307.00,415.00);
bunny.lineTo(307.00,415.00);
bunny.lineTo(304.50,412.25);
bunny.lineTo(304.50,412.25);
bunny.lineTo(304.50,412.25);
bunny.lineTo(302.63,409.38);
bunny.lineTo(302.63,409.38);
bunny.lineTo(302.63,409.38);
bunny.lineTo(300.13,406.63);
bunny.lineTo(300.13,406.63);
bunny.lineTo(300.13,406.63);
bunny.lineTo(298.00,402.88);
bunny.lineTo(298.00,402.88);
bunny.lineTo(298.00,402.88);
bunny.lineTo(296.63,400.50);
bunny.lineTo(296.63,400.50);
bunny.lineTo(296.63,400.50);
bunny.lineTo(295.38,397.88);
bunny.lineTo(295.38,397.88);
bunny.lineTo(295.38,397.88);
bunny.lineTo(294.50,395.63);
bunny.lineTo(294.50,395.63);
bunny.lineTo(294.50,395.63);
bunny.lineTo(294.13,392.88);
bunny.lineTo(294.13,392.88);
bunny.lineTo(294.13,392.88);
bunny.lineTo(293.13,389.88);
bunny.lineTo(293.13,389.88);
bunny.lineTo(293.13,389.88);
bunny.lineTo(292.38,385.75);
bunny.lineTo(292.38,385.75);
bunny.lineTo(292.38,385.75);
bunny.lineTo(291.75,381.13);
bunny.lineTo(291.75,381.13);
bunny.lineTo(291.75,381.13);
bunny.lineTo(290.88,371.75);
bunny.lineTo(290.88,371.75);
bunny.lineTo(290.88,371.75);
bunny.lineTo(291.13,366.88);
bunny.lineTo(291.13,366.88);
bunny.lineTo(291.13,366.88);
bunny.lineTo(293.25,362.50);
bunny.lineTo(293.25,362.50);
bunny.lineTo(293.25,362.50);
bunny.lineTo(295.38,358.88);
bunny.lineTo(295.38,358.88);
bunny.lineTo(295.38,358.88);
bunny.lineTo(296.75,356.38);
bunny.lineTo(296.75,356.38);
bunny.lineTo(296.75,356.38);
bunny.lineTo(300.00,350.00);
bunny.lineTo(300.00,350.00);
bunny.lineTo(300.00,350.00);
bunny.lineTo(305.63,342.75);
bunny.lineTo(305.63,342.75);
bunny.lineTo(305.63,342.75);
bunny.lineTo(309.88,337.00);
bunny.lineTo(309.88,337.00);
bunny.lineTo(309.88,337.00);
bunny.lineTo(313.50,333.13);
bunny.lineTo(313.50,333.13);
bunny.lineTo(313.50,333.13);
bunny.lineTo(319.25,327.63);
bunny.lineTo(319.25,327.63);
bunny.lineTo(319.25,327.63);
bunny.lineTo(323.38,324.00);
bunny.lineTo(323.38,324.00);
bunny.lineTo(323.38,324.00);
bunny.lineTo(328.38,321.25);
bunny.lineTo(328.38,321.25);
bunny.lineTo(328.38,321.25);
bunny.lineTo(333.75,318.88);
bunny.lineTo(333.75,318.88);
bunny.lineTo(333.75,318.88);
bunny.lineTo(338.50,316.38);
bunny.lineTo(338.50,316.38);
bunny.lineTo(338.50,316.38);
bunny.lineTo(341.63,315.50);
bunny.lineTo(341.63,315.50);
bunny.lineTo(341.63,315.50);
bunny.lineTo(348.50,313.25);
bunny.lineTo(348.50,313.25);
bunny.lineTo(348.50,313.25);
bunny.lineTo(355.25,312.00);
bunny.lineTo(355.25,312.00);
bunny.lineTo(355.25,312.00);
bunny.lineTo(361.00,310.88);
bunny.lineTo(361.00,310.88);
bunny.lineTo(361.00,310.88);
bunny.lineTo(364.50,309.75);
bunny.lineTo(364.50,309.75);
bunny.lineTo(364.50,309.75);
bunny.lineTo(367.75,307.50);
bunny.lineTo(367.75,307.50);
bunny.lineTo(367.75,307.50);
bunny.lineTo(373.25,302.50);
bunny.lineTo(373.25,302.50);
bunny.lineTo(373.25,302.50);
bunny.lineTo(379.13,296.13);
bunny.lineTo(379.13,296.13);
bunny.lineTo(379.13,296.13);
bunny.lineTo(384.25,290.13);
bunny.lineTo(384.25,290.13);
bunny.lineTo(384.25,290.13);
bunny.lineTo(389.25,283.88);
bunny.lineTo(389.25,283.88);
bunny.lineTo(389.25,283.88);
bunny.lineTo(393.25,279.50);
bunny.lineTo(393.25,279.50);
bunny.lineTo(393.25,279.50);
bunny.lineTo(396.63,275.50);
bunny.lineTo(396.63,275.50);
bunny.lineTo(396.63,275.50);
bunny.lineTo(400.50,271.38);
bunny.lineTo(400.50,271.38);
bunny.lineTo(400.50,271.38);
bunny.lineTo(406.25,266.75);
bunny.lineTo(406.25,266.75);
bunny.lineTo(406.25,266.75);
bunny.lineTo(411.50,262.13);
bunny.lineTo(411.50,262.13);
bunny.lineTo(411.50,262.13);
bunny.lineTo(414.88,259.75);
bunny.lineTo(414.88,259.75);
bunny.lineTo(414.88,259.75);
bunny.lineTo(420.25,256.63);
bunny.lineTo(420.25,256.63);
bunny.lineTo(420.25,256.63);
bunny.lineTo(424.63,253.88);
bunny.lineTo(424.63,253.88);
bunny.lineTo(424.63,253.88);
bunny.lineTo(427.50,252.88);
bunny.lineTo(427.50,252.88);
bunny.lineTo(427.50,252.88);
bunny.lineTo(431.13,251.50);
bunny.lineTo(431.13,251.50);
bunny.lineTo(431.13,251.50);
bunny.lineTo(434.25,251.13);
bunny.lineTo(434.25,251.13);
bunny.lineTo(434.25,251.13);
bunny.lineTo(437.63,251.00);
bunny.lineTo(437.63,251.00);
bunny.lineTo(437.63,251.00);
bunny.lineTo(442.50,252.25);
bunny.lineTo(442.50,252.25);
bunny.lineTo(442.50,252.25);
bunny.lineTo(445.50,253.75);
bunny.lineTo(445.50,253.75);
bunny.lineTo(445.50,253.75);
bunny.lineTo(447.88,255.25);
bunny.lineTo(447.88,255.25);
bunny.lineTo(447.88,255.25);
bunny.lineTo(450.50,258.25);
bunny.lineTo(450.50,258.25);
bunny.lineTo(450.50,258.25);
bunny.lineTo(451.88,260.75);
bunny.lineTo(451.88,260.75);
bunny.lineTo(451.88,260.75);
bunny.lineTo(453.38,264.13);
bunny.lineTo(453.38,264.13);
bunny.lineTo(453.38,264.13);
bunny.lineTo(454.25,266.88);
bunny.lineTo(454.25,266.88);
bunny.lineTo(454.25,266.88);
bunny.lineTo(455.50,271.13);
bunny.lineTo(455.50,271.13);
bunny.lineTo(455.50,271.13);
bunny.lineTo(455.63,274.75);
bunny.lineTo(455.63,274.75);
bunny.lineTo(455.63,274.75);
bunny.lineTo(456.75,276.50);
bunny.lineTo(456.75,276.50);
bunny.lineTo(456.75,276.50);
bunny.lineTo(458.63,278.00);
bunny.lineTo(458.63,278.00);
bunny.lineTo(458.63,278.00);
bunny.lineTo(460.00,278.88);
bunny.lineTo(460.00,278.88);
bunny.lineTo(460.00,278.88);
bunny.lineTo(461.00,280.75);
bunny.lineTo(461.00,280.75);
bunny.lineTo(461.00,280.75);
bunny.lineTo(462.75,281.00);
bunny.lineTo(462.75,281.00);
bunny.lineTo(462.75,281.00);
bunny.lineTo(464.88,281.88);
bunny.lineTo(464.88,281.88);
bunny.lineTo(464.88,281.88);
bunny.lineTo(467.38,283.00);
bunny.lineTo(467.38,283.00);
bunny.lineTo(467.38,283.00);
bunny.lineTo(470.13,284.50);
bunny.lineTo(470.13,284.50);
bunny.lineTo(470.13,284.50);
bunny.lineTo(472.00,286.13);
bunny.lineTo(472.00,286.13);
bunny.lineTo(473.63,287.50);
bunny.lineTo(477.13,290.13);
bunny.lineTo(477.13,290.13);
bunny.lineTo(477.13,290.13);
bunny.lineTo(479.50,292.25);
bunny.lineTo(479.50,292.25);
bunny.lineTo(479.50,292.25);
bunny.lineTo(481.50,295.00);
bunny.lineTo(481.50,295.00);
bunny.lineTo(481.50,295.00);
bunny.lineTo(483.38,299.13);
bunny.lineTo(483.38,299.13);
bunny.lineTo(483.38,299.13);
bunny.lineTo(483.38,303.63);
bunny.lineTo(483.38,303.63);
bunny.lineTo(483.38,303.63);
bunny.lineTo(482.63,308.00);
bunny.lineTo(482.63,308.00);
bunny.lineTo(482.63,308.00);
bunny.lineTo(480.75,311.75);
bunny.lineTo(480.75,311.75);
bunny.lineTo(480.75,311.75);
bunny.lineTo(469.25,325.00);
bunny.lineTo(469.25,325.00);
bunny.lineTo(469.25,325.00);
bunny.lineTo(464.00,330.63);
bunny.lineTo(464.00,330.63);
bunny.lineTo(464.00,330.63);
bunny.lineTo(458.50,337.13);
bunny.lineTo(458.50,337.13);
bunny.lineTo(458.50,337.13);
bunny.lineTo(451.75,345.13);
bunny.lineTo(451.75,345.13);
bunny.lineTo(451.75,345.13);
bunny.lineTo(448.38,349.63);
bunny.lineTo(448.38,349.63);
bunny.lineTo(448.38,349.63);
bunny.lineTo(446.00,353.13);
bunny.lineTo(446.00,353.13);
bunny.lineTo(446.00,353.13);
bunny.lineTo(443.38,357.75);
bunny.lineTo(443.38,357.75);
bunny.lineTo(443.38,357.75);
bunny.lineTo(442.13,361.13);
bunny.lineTo(442.13,361.13);
bunny.lineTo(442.13,361.13);
bunny.lineTo(441.88,367.38);
bunny.lineTo(441.88,367.38);
bunny.lineTo(441.88,367.38);
bunny.lineTo(441.75,371.75);
bunny.lineTo(441.75,371.75);
bunny.lineTo(441.75,371.75);
bunny.lineTo(442.13,375.63);
bunny.lineTo(442.13,375.63);
bunny.lineTo(442.13,375.63);
bunny.lineTo(443.00,381.88);
bunny.lineTo(443.00,381.88);
bunny.lineTo(443.00,381.88);
bunny.lineTo(444.38,385.75);
bunny.lineTo(444.38,385.75);
bunny.lineTo(444.38,385.75);
bunny.lineTo(446.50,390.75);
bunny.lineTo(446.50,390.75);
bunny.lineTo(446.50,390.75);
bunny.lineTo(450.00,396.38);
bunny.lineTo(450.00,396.38);
bunny.lineTo(450.00,396.38);
bunny.lineTo(452.88,399.50);
bunny.lineTo(452.88,399.50);
bunny.lineTo(452.88,399.50);
bunny.lineTo(457.25,404.25);
bunny.lineTo(457.25,404.25);
bunny.lineTo(457.25,404.25);
bunny.lineTo(462.38,409.50);
bunny.lineTo(462.38,409.50);
bunny.lineTo(462.38,409.50);
bunny.lineTo(467.25,414.50);
bunny.lineTo(467.25,414.50);
bunny.lineTo(467.25,414.50);
bunny.lineTo(471.25,418.63);
bunny.lineTo(471.25,418.63);
bunny.lineTo(471.25,418.63);
bunny.lineTo(473.25,421.38);
bunny.lineTo(473.25,421.38);
bunny.lineTo(473.25,421.38);
bunny.lineTo(476.63,426.13);
bunny.lineTo(476.63,426.13);
bunny.lineTo(476.63,426.13);
bunny.lineTo(480.75,431.13);
bunny.lineTo(480.75,431.13);
bunny.lineTo(480.75,431.13);
bunny.lineTo(483.50,435.13);
bunny.lineTo(483.50,435.13);
bunny.lineTo(483.50,435.13);
bunny.lineTo(485.25,439.63);
bunny.lineTo(485.25,439.63);
bunny.lineTo(485.25,439.63);
bunny.lineTo(487.50,444.75);
bunny.lineTo(487.50,444.75);
bunny.lineTo(487.50,444.75);
bunny.lineTo(489.13,448.88);
bunny.lineTo(489.13,448.88);
bunny.lineTo(489.13,448.88);
bunny.lineTo(489.75,453.88);
bunny.lineTo(489.75,453.88);
bunny.lineTo(489.75,453.88);
bunny.lineTo(490.63,459.38);
bunny.lineTo(490.63,459.38);
bunny.lineTo(490.63,459.38);
bunny.lineTo(492.38,466.25);
bunny.lineTo(492.38,466.25);
bunny.lineTo(492.38,466.25);
bunny.lineTo(493.38,472.88);
bunny.lineTo(493.38,472.88);
bunny.lineTo(493.38,472.88);
bunny.lineTo(493.88,477.13);
bunny.lineTo(493.88,477.13);
bunny.lineTo(493.88,477.13);
bunny.lineTo(494.38,480.63);
bunny.lineTo(494.38,480.63);
bunny.lineTo(494.38,480.63);
bunny.lineTo(495.50,483.38);
bunny.lineTo(495.50,483.38);
bunny.lineTo(495.50,483.38);
bunny.lineTo(498.00,485.25);
bunny.lineTo(498.00,485.25);
bunny.lineTo(498.00,485.25);
bunny.lineTo(499.50,488.00);
bunny.lineTo(499.50,488.00);
bunny.lineTo(499.50,488.00);
bunny.lineTo(500.63,491.50);
bunny.lineTo(500.63,491.50);
bunny.lineTo(500.63,491.50);
bunny.lineTo(501.25,497.13);
bunny.lineTo(501.25,497.13);
bunny.lineTo(501.25,497.13);
bunny.lineTo(500.13,501.13);
bunny.lineTo(500.13,501.13);
bunny.lineTo(500.13,501.13);
bunny.lineTo(499.13,505.63);
bunny.lineTo(499.13,505.63);
bunny.lineTo(499.13,505.63);
bunny.lineTo(497.88,507.88);
bunny.lineTo(497.88,507.88);
bunny.lineTo(497.88,507.88);
bunny.lineTo(495.88,512.25);
bunny.lineTo(495.88,512.25);
bunny.lineTo(495.88,512.25);
bunny.lineTo(494.38,516.25);
bunny.lineTo(494.38,516.25);
bunny.lineTo(494.38,516.25);
bunny.lineTo(493.25,518.63);
bunny.lineTo(493.25,518.63);
bunny.lineTo(493.25,518.63);
bunny.lineTo(491.88,521.88);
bunny.lineTo(491.88,521.88);
bunny.lineTo(491.88,521.88);
bunny.lineTo(489.38,524.00);
bunny.lineTo(489.38,524.00);
bunny.lineTo(489.38,524.00);
bunny.lineTo(489.13,526.63);
bunny.lineTo(489.13,526.63);
bunny.lineTo(489.13,526.63);
bunny.lineTo(488.13,528.75);
bunny.lineTo(488.13,528.75);
bunny.closePath();
g2.draw(bunny);
Color gold = new Color(255,215,0);
g2.setColor(gold);
g2.fill(bunny);
Path2D chocoears = new Path2D.Float();
chocoears.moveTo(473.63, 287.50);
chocoears.lineTo(473.63,287.50);
chocoears.lineTo(477.13,290.13);
chocoears.lineTo(477.13,290.13);
chocoears.lineTo(477.13,290.13);
chocoears.lineTo(479.50,292.25);
chocoears.lineTo(479.50,292.25);
chocoears.lineTo(479.50,292.25);
chocoears.lineTo(481.50,295.00);
chocoears.lineTo(481.50,295.00);
chocoears.lineTo(481.50,295.00);
chocoears.lineTo(483.38,299.13);
chocoears.lineTo(483.38,299.13);
chocoears.lineTo(483.38,299.13);
chocoears.lineTo(483.38,303.63);
chocoears.lineTo(483.38,303.63);
chocoears.lineTo(483.38,303.63);
chocoears.lineTo(482.63,308.00);
chocoears.lineTo(482.63,308.00);
chocoears.lineTo(482.63,308.00);
chocoears.lineTo(480.75,311.75);
chocoears.lineTo(480.75,311.75);
chocoears.lineTo(480.75,311.75);
chocoears.lineTo(469.25,325.00);
chocoears.lineTo(469.25,325.00);
chocoears.lineTo(469.25,325.00);
chocoears.lineTo(464.00,330.63);
chocoears.lineTo(464.00,330.63);
chocoears.lineTo(464.00,330.63);
chocoears.lineTo(458.50,337.13);
chocoears.lineTo(458.50,337.13);
chocoears.lineTo(458.50,337.13);
chocoears.lineTo(451.75,345.13);
chocoears.lineTo(451.75,345.13);
chocoears.lineTo(451.75,345.13);
chocoears.lineTo(442.33,351.00);
chocoears.lineTo(442.33,351.00);
chocoears.lineTo(442.33,351.00);
chocoears.lineTo(435.33,351.00);
chocoears.lineTo(435.33,351.00);
chocoears.lineTo(435.33,351.00);
chocoears.lineTo(432.00,349.00);
chocoears.lineTo(432.00,349.00);
chocoears.lineTo(432.00,349.00);
chocoears.lineTo(427.00,348.67);
chocoears.lineTo(427.00,348.67);
chocoears.lineTo(427.00,348.67);
chocoears.lineTo(420.00,342.67);
chocoears.lineTo(420.00,342.67);
chocoears.lineTo(420.00,342.67);
chocoears.lineTo(415.33,339.33);
chocoears.lineTo(415.33,339.33);
chocoears.lineTo(415.33,339.33);
chocoears.lineTo(412.00,341.00);
chocoears.lineTo(412.00,341.00);
chocoears.lineTo(412.00,341.00);
chocoears.lineTo(408.33,337.00);
chocoears.lineTo(408.33,337.00);
chocoears.lineTo(408.33,337.00);
chocoears.lineTo(407.33,333.33);
chocoears.lineTo(407.33,333.33);
chocoears.lineTo(407.33,333.33);
chocoears.lineTo(403.67,329.67);
chocoears.lineTo(403.67,329.67);
chocoears.lineTo(403.67,329.67);
chocoears.lineTo(399.00,331.67);
chocoears.lineTo(399.00,331.67);
chocoears.lineTo(399.00,331.67);
chocoears.lineTo(396.33,329.33);
chocoears.lineTo(396.33,329.33);
chocoears.lineTo(396.33,329.33);
chocoears.lineTo(394.33,326.67);
chocoears.lineTo(394.33,326.67);
chocoears.lineTo(394.33,326.67);
chocoears.lineTo(386.67,326.33);
chocoears.lineTo(386.67,326.33);
chocoears.lineTo(386.67,326.33);
chocoears.lineTo(382.33,320.67);
chocoears.lineTo(382.33,320.67);
chocoears.lineTo(382.33,320.67);
chocoears.lineTo(378.00,322.00);
chocoears.lineTo(378.00,322.00);
chocoears.lineTo(378.00,322.00);
chocoears.lineTo(372.00,320.00);
chocoears.lineTo(372.00,320.00);
chocoears.lineTo(372.00,320.00);
chocoears.lineTo(373.33,318.00);
chocoears.lineTo(373.33,318.00);
chocoears.lineTo(373.33,318.00);
chocoears.lineTo(371.33,315.67);
chocoears.lineTo(371.33,315.67);
chocoears.lineTo(371.33,315.67);
chocoears.lineTo(365.33,316.00);
chocoears.lineTo(365.33,316.00);
chocoears.lineTo(365.33,316.00);
chocoears.lineTo(355.25,312.00);
chocoears.lineTo(355.25,312.00);
chocoears.lineTo(355.25,312.00);
chocoears.lineTo(361.00,310.88);
chocoears.lineTo(361.00,310.88);
chocoears.lineTo(361.00,310.88);
chocoears.lineTo(364.50,309.75);
chocoears.lineTo(364.50,309.75);
chocoears.lineTo(364.50,309.75);
chocoears.lineTo(367.75,307.50);
chocoears.lineTo(367.75,307.50);
chocoears.lineTo(367.75,307.50);
chocoears.lineTo(373.25,302.50);
chocoears.lineTo(373.25,302.50);
chocoears.lineTo(373.25,302.50);
chocoears.lineTo(379.13,296.13);
chocoears.lineTo(379.13,296.13);
chocoears.lineTo(379.13,296.13);
chocoears.lineTo(384.25,290.13);
chocoears.lineTo(384.25,290.13);
chocoears.lineTo(384.25,290.13);
chocoears.lineTo(389.25,283.88);
chocoears.lineTo(389.25,283.88);
chocoears.lineTo(389.25,283.88);
chocoears.lineTo(393.25,279.50);
chocoears.lineTo(393.25,279.50);
chocoears.lineTo(393.25,279.50);
chocoears.lineTo(396.63,275.50);
chocoears.lineTo(396.63,275.50);
chocoears.lineTo(396.63,275.50);
chocoears.lineTo(400.50,271.38);
chocoears.lineTo(400.50,271.38);
chocoears.lineTo(400.50,271.38);
chocoears.lineTo(406.25,266.75);
chocoears.lineTo(406.25,266.75);
chocoears.lineTo(406.25,266.75);
chocoears.lineTo(411.50,262.13);
chocoears.lineTo(411.50,262.13);
chocoears.lineTo(411.50,262.13);
chocoears.lineTo(414.88,259.75);
chocoears.lineTo(414.88,259.75);
chocoears.lineTo(414.88,259.75);
chocoears.lineTo(420.25,256.63);
chocoears.lineTo(420.25,256.63);
chocoears.lineTo(420.25,256.63);
chocoears.lineTo(424.63,253.88);
chocoears.lineTo(424.63,253.88);
chocoears.lineTo(424.63,253.88);
chocoears.lineTo(427.50,252.88);
chocoears.lineTo(427.50,252.88);
chocoears.lineTo(427.50,252.88);
chocoears.lineTo(431.13,251.50);
chocoears.lineTo(431.13,251.50);
chocoears.lineTo(431.13,251.50);
chocoears.lineTo(434.25,251.13);
chocoears.lineTo(434.25,251.13);
chocoears.lineTo(434.25,251.13);
chocoears.lineTo(437.63,251.00);
chocoears.lineTo(437.63,251.00);
chocoears.lineTo(437.63,251.00);
chocoears.lineTo(442.50,252.25);
chocoears.lineTo(442.50,252.25);
chocoears.lineTo(442.50,252.25);
chocoears.lineTo(445.50,253.75);
chocoears.lineTo(445.50,253.75);
chocoears.lineTo(445.50,253.75);
chocoears.lineTo(447.88,255.25);
chocoears.lineTo(447.88,255.25);
chocoears.lineTo(447.88,255.25);
chocoears.lineTo(450.50,258.25);
chocoears.lineTo(450.50,258.25);
chocoears.lineTo(450.50,258.25);
chocoears.lineTo(451.88,260.75);
chocoears.lineTo(451.88,260.75);
chocoears.lineTo(451.88,260.75);
chocoears.lineTo(453.38,264.13);
chocoears.lineTo(453.38,264.13);
chocoears.lineTo(453.38,264.13);
chocoears.lineTo(454.25,266.88);
chocoears.lineTo(454.25,266.88);
chocoears.lineTo(454.25,266.88);
chocoears.lineTo(455.50,271.13);
chocoears.lineTo(455.50,271.13);
chocoears.lineTo(455.50,271.13);
chocoears.lineTo(455.63,274.75);
chocoears.lineTo(455.63,274.75);
chocoears.lineTo(455.63,274.75);
chocoears.lineTo(456.75,276.50);
chocoears.lineTo(456.75,276.50);
chocoears.lineTo(456.75,276.50);
chocoears.lineTo(458.63,278.00);
chocoears.lineTo(458.63,278.00);
chocoears.lineTo(458.63,278.00);
chocoears.lineTo(460.00,278.88);
chocoears.lineTo(460.00,278.88);
chocoears.lineTo(460.00,278.88);
chocoears.lineTo(461.00,280.75);
chocoears.lineTo(461.00,280.75);
chocoears.lineTo(461.00,280.75);
chocoears.lineTo(462.75,281.00);
chocoears.lineTo(462.75,281.00);
chocoears.lineTo(462.75,281.00);
chocoears.lineTo(464.88,281.88);
chocoears.lineTo(464.88,281.88);
chocoears.lineTo(464.88,281.88);
chocoears.lineTo(467.38,283.00);
chocoears.lineTo(467.38,283.00);
chocoears.lineTo(467.38,283.00);
chocoears.lineTo(470.13,284.50);
chocoears.lineTo(470.13,284.50);
chocoears.lineTo(470.13,284.50);
chocoears.lineTo(472.00,286.13);
chocoears.lineTo(472.00,286.13);
chocoears.closePath();
g2.draw(chocoears);
Color milkChocolate = new Color(111,68,51);
g2.setColor(milkChocolate);
g2.fill(chocoears);
//Grass
Rectangle grass = new Rectangle(0,525,getWidth(),100);
Color lawnGreen = new Color(124,252,0);
g2.setColor(lawnGreen);
g2.fill(grass);
List<Arc2D> blades = new ArrayList<Arc2D>();
for (int x = 0; x < getWidth(); x += 10) {
blades.add(new Arc2D.Double(x, 500, 10, 35, 105, 180, Arc2D.OPEN));
blades.add(new Arc2D.Double(x - 5, 510, 10, 35, 105, 180, Arc2D.OPEN));
blades.add(new Arc2D.Double(x, 520, 10, 35, 105, 180, Arc2D.OPEN));
}
Color yellowGreen = new Color(107, 142, 35);
g2.setColor(yellowGreen);
for (Shape blade : blades) {
g2.draw(blade);
}
Ellipse2D.Double circle = new Ellipse2D.Double(60,100,25,25);
g2.setColor(Color.RED);
g2.fill(circle);
Rectangle box = new Rectangle(150,100,20,80);
g2.setColor(Color.YELLOW);
g2.fill(box);
}
}
Whatever you do I would
create the Path2D objects outside of the paintComponent() method.
add each Path2D object to an ArrayList
in the paintComponent() method you can iterate through the ArrayList to paint each Path2D
Or another approach is to just have a method that:
creates each Path2D object when the class is created
then you paint the Path2D object to a BufferedImage
now that you have a BufferedImage you can create an ImageIcon and Just use a JLabel in you app and you don't need the custom panel.
Heres 2 options I would consider for cleaning up the pathing.
Use SVG, one library I know is Batik found at: http://xmlgraphics.apache.org/batik/
Once I did a project where the paths I needed would be created in photoshop then exported to Illustrator. The file format was each action was line delineated, each line was space delineated and consisted of a set of points with the last entry the command name. Here was a sample input.
10 10 m
15 15 l
10 10 12 12 v
As you can see you just read the file, create your path and do an if test for the last letter on the line and use the appropriate command with for the points. Of course you can make up your own format or procedures but it sure was nice using photoshop for me :)

Java Swing - Dynamic JPanel GroupLayout Resizing Issue

These images show a chat box that needs to be resized with the application frame. I'm using GroupLayout to do so. The hierarchy of the frame goes something like this
chatDiv(JPanel, GroupLayout)->chatTabbedPane(JTabbedPane, GroupLayout)
->chatPanel(extended JPanel, GroupLayout)
But, these individual chat_tabs(chatPanel) are added to the chatTabbedPane dynamically during application runtime.
Problem is: These chatPanel(s) are expanding with the expansion of application
frame but they are not shrinking with the shrink in width of application frame.
initialized frame
and when I expand and again shrink the application frame this happens (size of chatPanel doesn't shrink leading to invisible overflown region)..
expanded and again shrinked frame
Here is the class chatPanel that extends JPanel:
class chatPanel extends JPanel{
private static final long serialVersionUID = 1L;
GroupLayout gl_panel;
JTextArea textArea;
JTextField textField;
JButton sendTextButton;
JButton closeChatButton;
int replyRef;
public chatPanel(int ref){
//this.setLayout(null);
closeChatButton = new JButton("");
sendTextButton = new JButton("SEND");
textField = new JTextField();
textArea = new JTextArea();
replyRef = ref;
textArea.setWrapStyleWord(true);
textArea.setEditable(false);
textArea.setLineWrap(true);
//textArea.setBounds(0, 0, 370, 99);
this.add(textArea);
//textField.setBounds(0, 101, 290, 20);
//textField.setColumns(10);
this.add(textField);
sendTextButton.setFont(new Font("Tahoma", Font.PLAIN, 10));
//sendTextButton.setBounds(290, 101, 60, 19);
this.add(sendTextButton);
closeChatButton.setIcon(new ImageIcon("files/close.png"));
closeChatButton.setSelectedIcon(null);
closeChatButton.setToolTipText("CLOSE");
closeChatButton.setFont(new Font("Tahoma", Font.PLAIN, 5));
//closeChatButton.setBounds(350, 101, 20, 19);
this.add(closeChatButton);
gl_panel = new GroupLayout(this);
gl_panel.setHorizontalGroup(
gl_panel.createParallelGroup(Alignment.TRAILING)
.addGroup(gl_panel.createSequentialGroup()
.addGap(1)
.addComponent(textField, GroupLayout.DEFAULT_SIZE, 286, Short.MAX_VALUE)
.addGap(1)
.addComponent(sendTextButton, GroupLayout.PREFERRED_SIZE, 60, GroupLayout.PREFERRED_SIZE)
.addGap(1)
.addComponent(closeChatButton, GroupLayout.PREFERRED_SIZE, 20, GroupLayout.PREFERRED_SIZE)
.addGap(1))
.addComponent(textArea, GroupLayout.DEFAULT_SIZE, 370, Short.MAX_VALUE)
);
gl_panel.setVerticalGroup(
gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addComponent(textArea, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
.addGroup(gl_panel.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel.createSequentialGroup()
.addGap(1)
.addGroup(gl_panel.createParallelGroup(Alignment.TRAILING, false)
.addGroup(gl_panel.createSequentialGroup()
.addComponent(sendTextButton, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED))
.addGroup(gl_panel.createSequentialGroup()
.addComponent(closeChatButton, GroupLayout.PREFERRED_SIZE, 19, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.RELATED)))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(gl_panel.createSequentialGroup()
.addGap(1)
.addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(1))))
);
this.setLayout(gl_panel);
}
}
and this is how I add these chatPanel(s) to chatTabbedPane
chatPanel newChat = new chatPanel(chatRef);
chatTabbedPane.addTab("title", null, newChat, null);
I want to shrink the size of chatPanel with shrink in size of application frame.
I've just run into this issue as well, and an answer like "just use another layout manager" isn't an answer I'm willing to accept.
To answer your question, the line wrap is messing things up.
textArea.setLineWrap(true);
Comment that line out and test again to see it will resize down with the window/frame like expected.
However, the side effect is obviously no line wraps. What's not so obvious is when your text length becomes greater than the textarea's width, when you resize the window the textarea's width will lock to the text's length. I still haven't found a fix for this new problem yet.

Embed java swing in html

I have following code for my java swing application which is executing fine in eclipse IDE but when I am embedding it in HTML then not executing in browser,just showing blank box.
Java swing code:
import javax.swing.*;
import java.applet.*;
import java.awt.*;
public class Form extends JApplet{
public void init()
{
JFrame frame = new JFrame("Form");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
JPanel panel = new JPanel();
JLabel label1 = new JLabel("");
JTextField field = new JTextField(20);
//JButton button1 = new JButton("OK");
//JButton button2 = new JButton("Cancel");
Container c;
c=frame.getContentPane();
c.setLayout(null);
JLabel name=new JLabel("Name :");
JLabel compcode=new JLabel("Company Code :");
JLabel cardno=new JLabel("Card Number: ");
JLabel cardtype=new JLabel("Card Type :");
JLabel pin=new JLabel("Pin :");
JLabel bldgrp=new JLabel("Blood Group :");
JLabel empcode=new JLabel("Employee Code :");
JLabel dob=new JLabel("DOB :");
JLabel valupto=new JLabel("Valid Upto :");
JLabel jdate=new JLabel("Joining Date :");
JLabel dept=new JLabel("Department :");
JLabel uid=new JLabel("UID :");
JTextField nametxt=new JTextField(10);
JComboBox compcodetxt=new JComboBox();
JTextField cardnumtxt=new JTextField(10);
JTextField cardtypetxt=new JTextField(10);
JTextField pintxt=new JTextField(10);
JComboBox bldgrptxt=new JComboBox();
JTextField empcodetxt=new JTextField(10);
JTextField dobtxt=new JTextField(10);
JTextField valuptotxt=new JTextField(10);
JTextField jdatetxt=new JTextField(10);
JTextField depttxt=new JTextField(10);
JTextField uidtxt=new JTextField(10);
name.setBounds(10, 10, 100, 25);
nametxt.setBounds(110, 10, 100, 25);
compcode.setBounds(10, 40, 100, 25);
compcodetxt.setBounds(110, 40, 100, 25);
cardno.setBounds(10, 70, 100, 25);
cardnumtxt.setBounds(110, 70, 100, 25);
pin.setBounds(10, 110, 100, 25);
pintxt.setBounds(110, 110, 100, 25);
bldgrp.setBounds(10, 140, 100, 25);
bldgrptxt.setBounds(110, 140, 100, 25);
empcode.setBounds(10, 170, 100, 25);
empcodetxt.setBounds(110, 170, 100, 25);
dob.setBounds(10, 200, 100, 25);
dobtxt.setBounds(110, 200, 100, 25);
valupto.setBounds(10, 230, 100, 25);
valuptotxt.setBounds(110, 230, 100, 25);
jdate.setBounds(10, 260, 100, 25);
jdatetxt.setBounds(110, 260, 100, 25);
dept.setBounds(10, 290, 100, 25);
depttxt.setBounds(110, 290, 100, 25);
uid.setBounds(10, 320, 100, 25);
uidtxt.setBounds(110, 320, 100, 25);
//button1.setBounds(10, 50, 75, 25);
//button2.setBounds(10, 70, 75, 25);
c.add(name); c.add(nametxt);
c.add(compcode); c.add(compcodetxt);
c.add(cardno); c.add(cardnumtxt);
c.add(pin); c.add(pintxt);
c.add(bldgrp); c.add(bldgrptxt);
c.add(empcode); c.add(empcodetxt);
c.add(dob); c.add(dobtxt);
c.add(valupto); c.add(valuptotxt);
c.add(jdate); c.add(jdatetxt);
c.add(dept); c.add(depttxt);
c.add(uid); c.add(uidtxt);
//panel.add(button1);
//panel.add(button2);
//frame.add(panel);
frame.setSize(350,400);
//frame.pack();
frame.setVisible(true);
}
}
HTML code for embedding it in is as follows:
<html>
<head>
<title>Test Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<applet Archive ="Form.jar" Code="com.vms.util.Form" WIDTH="250" HEIGHT="300" >
</applet>
</html>
I generated JAR for my swing class Form.jar with package com.vms.util
I kept it in my D: drive form directory and put all html and jar in form directory.
I am able to run my swing application in HTML, how do I run it?
When I am running above code using appletviewer I am getting following error
D:\form>appletviewer Form2.html
java.security.AccessControlException: access denied (java.lang.RuntimePermission
exitVM.0)
at java.security.AccessControlContext.checkPermission(AccessControlConte
xt.java:374)
at java.security.AccessController.checkPermission(AccessController.java:
546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkExit(SecurityManager.java:744)
at javax.swing.JFrame.setDefaultCloseOperation(JFrame.java:372)
at Form.init(Form.java:10)
at sun.applet.AppletPanel.run(AppletPanel.java:424)
at java.lang.Thread.run(Thread.java:662)
comment following line
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Applets are not allowed (except by modifying directly the Java Security Policy on the client machine) to perform some critical calls. Even if using signed applets.
In your case, at javax.swing.JFrame.setDefaultCloseOperation is triggering the exception
it seems to be a small mistake, just enable java console and run the application.
it will help you to know what is the issue
PS: to enable java console on windows
go to control panel
select java
go to advance tab
Select applet lifecycle exception under Debugging section
Select Show console under Java Console Section.
Hope this will help you

Categories

Resources