LINKBUTTON

i want to create a one link button if i click that button it has to go another page. USING SWINGS(JAVA)

can u give me a simple program......plz..

becoz i have seen all ur posted questions and answers but it is not there . If it is available can u give me link itself....
View Answers

July 14, 2010 at 3:53 PM

Hi Friend,

Try the following code:

import java.awt.*;
import java.net.*;
import javax.swing.*;
import java.awt.event.*;
public class LinkButton {
public static void main(String[] args) throws Exception {
final URI uri = new URI("http://www.roseindia.net";);
JFrame frame = new JFrame("Links");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,100);
Container container = frame.getContentPane();
container.setLayout(new GridBagLayout());

JButton button = new JButton();
button.setText("<HTML><FONT color='blue'><U>www.roseindia.net</U></FONT></HTML>");
button.setHorizontalAlignment(SwingConstants.LEFT);
button.setBorderPainted(false);
button.setOpaque(false);
button.setBackground(Color.lightGray);
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (Desktop.isDesktopSupported()) {
Desktop desktop = Desktop.getDesktop();
try {
desktop.browse(uri);
} catch (Exception ex) {}
} else {}
}
});
container.add(button);
frame.setVisible(true);
}
}

Thanks

July 15, 2010 at 8:44 PM

when iam executing this program im getting the two errors how can i rectify these errors........


the error is

D:\>javac LinkButton.java
LinkButton.java:9: ')' expected
final URI uri = new URI("http://www.roseindia.net";;);
^
LinkButton.java:9: illegal start of expression
final URI uri = new URI("http://www.roseindia.net";;);









Related Tutorials/Questions & Answers:
LinkButton in Flex4
LinkButton in Flex4: The LinkButton is a MX component. It has no Spark component. The LinkButton in Flex is much like the hyperlink option of HTML... with it. You can use NavigateToURL() method to open the URL. The Tag of LinkButton
LinkButton in Flex
LinkButton in Adobe Flex: The LinkButton in Flex is much like the hyperlink... of the button changes. Following examples will help you to learn LinkButton in details: ADS_TO_REPLACE_1 Flex LinkButton Example: <?xml version="1.0"
Advertisements
LINKBUTTON - Swing AWT
javax.swing.*; import java.awt.event.*; public class LinkButton { public
Java Swing Create LinkButton
Java Swing Create LinkButton You all are aware of JButtons, JRadioButtons, JToggleButtons and you have used these components in your applications. Here we... javax.swing.*; import java.awt.event.*; public class LinkButton { public static
Flex Behavior
; horizontalAlign="center">ADS_TO_REPLACE_4 <mx:LinkButton...;/> <mx:LinkButton id="LinkButton2" label="Click Me...; fontWeight="bold"/> <mx:LinkButton id="LinkButton3
Canvas Layout Container
; backgroundColor="white">ADS_TO_REPLACE_3 <mx:LinkButton...:LinkButton label="Button 2" x="100" y="30"/> <mx:LinkButton label="Button 3" x="10" y="100"/>
Style through namespace in Flex4
: green; } mx|LinkButton { ADS_TO_REPLACE_5 fontSize: 12...;ADS_TO_REPLACE_7 <mx:LinkButton label="My Link Button"
DividedBox layout container
:LinkButton label="Introducing Flex" click="articleText.text='Flex is developed on adobe technology.'"/> <mx:LinkButton
Flex Simple ToolTip
; <mx:LinkButton id="linkbutton1" label="My Link Button... how to create tooltip for Image, Button, and LinkButton. ADS_TO_REPLACE_4...;mx:LinkButton id="linkbutton1" label="My Link Button"
Flex Skin index
:Style> LinkButton {ADS_TO_REPLACE_3 upSkin: Embed("assets/button.jpeg... <mx:LinkButton id="linkbutton" label="Link Button Skin"
Canvas Layout Container in Flex4
;>ADS_TO_REPLACE_4 <mx:LinkButton label="JAVA" x...;))"/> <mx:LinkButton label="iPHONE" ADS...://www.roseindia.net/iphone'))"/> <mx:LinkButton label="
Flex Style Property
;/> <mx:LinkButton label="This is my Link Button" styleName
Flex Style Manager
;ADS_TO_REPLACE_6 <mx:LinkButton id="myLinkButton" label="
Action Script custom components
Flex Custom Components using Action Script:- You can create custom components by define Action Script class. User can create two type of custom components. First is visual custom components like Button, LinkButton, CheckBox, ComboBox
LinkBar in Flex
_TO_REPLACE_1 A LinkBar control creates LinkButton controls which are based
View states in Flex4
; <mx:LinkButton id="registerlinkButton"ADS
View State in custom component in Flex4
:Spacer width="100%"/> <mx:LinkButton id="
Java Swing Tutorial - Learning Java Swing programming step by step
Swing Create LinkButton Java Pagination Java Image
Java Swing Tutorial - Learning Java Swing programming step by step
Swing Create LinkButton Java Pagination Java Image
Java Swing Tutorial - Learning Java Swing programming step by step
values in JComboBox Java Swing Create LinkButton Java
Flex Example
? Image ? Label ? LinkButton ? List