Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

setting of Border on JFrame or JWindow ..: Confusion on Ghraphic  RSS feed

 
sandhiya sindhi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Programmers
Hi to All!
actrually i'm new in programming field, so i'm bothering u again & again.
Now i got problem that how can i set Border on JWindow and on JFrame..
i tried it by using:
Component.setBorder(anyBorder);
but it generates error, where as it is working on JPanel.

2. PRoblem:
i'm trying to make a button of any other type(fancy Button) not like default shape of java's buttons.for such purpose i use paint(). when i made an oval shape in it, it hide all my other components and only this show on Fram
So how can i do such that i make a shap and use that as a Button.and on proper panel because i'm usning multiple JPanels in my Application.
3.Problem:
During try of making fancy buttons i got idea to use JLabel as Button
such as add icon on Label and add listener on it. but it generates error. so is it possible to add listener on JLabels???
Kindly help me.
 
Joe Ess
Bartender
Posts: 9425
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, maybe you should check out the Java Tutorial and the Swing Tutorial. Get the basics down and then try to expand on that knowledge.
 
sandhiya sindhi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have found that some one post reply of my question but this is not shown oat my side whyy???
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the border problem, add the border to the content pane instead of the frame directly. You'll probably have to explicitly cast the content pane to a JComponent to do this.

As for the Oval button, you can do this yourself, and there are probably lots of code examples on the web showing lots of different ways to do this... One thing to check out would be SkinLF... They've already built a framework that lets you change pretty much anything you want about the visuals of Swing GUIs.

JLabels can be used as buttons. However, you have to subclass them, add the addActionListener() and removeActionListener() methods and enable action events in the constructor of the class. There are probably lots of examples of doing this out there on the web, too, but hopefully the above link to SkinLF helps you out on this.
 
sandhiya sindhi
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now here is i have make an Simple Aplication just for code.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.BorderFactory.*;
public class JustToCheck extends JWindow implements ActionListener
{
JLabel buttonIcon;
JTextField checkText;
Border raisedBorder;
public void JustToCheck()
{
buttonIcon = new JLabel("snap2.gif");
checkText= new JTextField(20);
raisedBorder = BorderFactory.createRaisedBevelBorder();

Container cont= getContentPane();
cont.setBorder(raisedBorder);
cont.setLayout(new FlowLayout());
cont.add(checkText);
cont.add(buttonIcon);
buttonIcon.addActionListener(this);

pack();
show();


}
public void actionPerformed(ActionEvent e)
{

}
public static void main(String[] s)
{
new JustToCheck();
}
}

For skins i'm still in learning section.. that how can i do and compile by the guide of Mr Joe.
And i have apply setBorder on container but it generates error.
and also i have add ActionListener on JLabel but it generating error also
Please Help Me Sir
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One way to do this is -

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!