Jump to content

How To Make This Work Together?


Recommended Posts

This is the code to download a file


   URL website = new URL("http://www.website.com/information.asp");
   ReadableByteChannel rbc = Channels.newChannel(website.openStream());
   FileOutputStream fos = new FileOutputStream("information.html");
   fos.getChannel().transferFrom(rbc, 0, 1 << 24);


and this my java page i want it to work in.


   package layout;

 * TabDemo.java

   import java.awt.*;
   import javax.swing.*;

   public class TabDemo {
   final static String HOMEBUTTONPANEL = "Home";
   final static String MAINBUTTONPANEL = "Main Plugins";
   final static String ECONOMYBUTTONPANEL = "Economy Plugins";
   final static String FUNBUTTONPANEL = "Fun Plugins";
   final static String PERMBUTTONPANEL = "Permissions Plugins";
   final static String WORLDMODBUTTONPANEL = "World Modifiers";
   final static int extraWindowWidth = 600;
   final static int extraWindowHeight = 600;

   public void addComponentToPane(Container pane) {
   JTabbedPane tabbedPane = new JTabbedPane();

   //Create the "cards".
   JPanel card1 = new JPanel() {
   //Make the panel wider than it really needs, so
   //the window's wide enough for the tabs to stay
   //in one row.
   public Dimension getPreferredSize() {
   Dimension size = super.getPreferredSize();
   size.width += extraWindowWidth;
   size.height += extraWindowHeight;
   return size;

   JPanel card2 = new JPanel();

   card2.add(new JButton("Chest Shop"));
   card2.add(new JButton("Essentials"));
   card2.add(new JButton("Factions"));
   card2.add(new JButton("GroupManager"));
   card2.add(new JButton("Iconomy"));
   card2.add(new JButton("Kingdoms"));
   card2.add(new JButton("PermissionsEx"));
   //Breakline here
   card2.add(new JButton("Towny"));
   card2.add(new JButton("World Border"));
   card2.add(new JButton("World Edit"));
   card2.add(new JButton("World Guard"));

   tabbedPane.addTab(HOMEBUTTONPANEL, card1);
   tabbedPane.addTab(MAINBUTTONPANEL, card2);

   pane.add(tabbedPane, BorderLayout.CENTER);

  * Create the GUI and show it. For thread safety,
  * this method should be invoked from the
  * event dispatch thread.
   private static void createAndShowGUI() {
   //Create and set up the window.
   JFrame frame = new JFrame("Minecraft Server Plugin Downloader");

   //Create and set up the content pane.
   TabDemo demo = new TabDemo();

   //Display the window.

   public static void main(String[] args) {
   /* Use an appropriate Look and Feel */
   try {
   } catch (UnsupportedLookAndFeelException ex) {
   } catch (IllegalAccessException ex) {
   } catch (InstantiationException ex) {
   } catch (ClassNotFoundException ex) {
   /* Turn off metal's use of bold fonts */
   UIManager.put("swing.boldMetal", Boolean.FALSE);

   //Schedule a job for the event dispatch thread:
   //creating and showing this application's GUI.
   javax.swing.SwingUtilities.invokeLater(new Runnable() {
   public void run() {


How can i make it work so, that when i click card2.add(new JButton("Chest Shop")); this button it downloads a certain file?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.