Giter Club home page Giter Club logo

jcopybutton's Introduction

JCopyButton is a Java Swing component designed to copy the contents of a JTextComponent to the system clipboard when clicked. It can be used with JTextComponent and all of its subclasses:

Table of Contents

Installation

JCopyButton is hosted on the JitPack package repository which supports Gradle, Maven, and sbt.

Gradle Gradle

Add JitPack to your build.gradle at the end of repositories.

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}

Add JCopyButton as a dependency.

dependencies {
	implementation 'com.github.Valkryst:JCopyButton:2024.1.7'
}

Maven Maven

Add JitPack as a repository.

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

Add JCopyButton as a dependency.

<dependency>
    <groupId>com.github.Valkryst</groupId>
    <artifactId>JCopyButton</artifactId>
    <version>2024.1.7</version>
</dependency>

Scala SBT Scala SBT

Add JitPack as a resolver.

resolvers += "jitpack" at "https://jitpack.io"

Add JCopyButton as a dependency.

libraryDependencies += "com.github.Valkryst" % "JCopyButton" % "2024.1.7"

Example

This creates a new JCopyButton and displays it in a JFrame, along with a JTextArea that contains some text for the button to copy.

public class Driver {
  public static void main(final String[] args) {
    SwingUtilities.invokeLater(() -> {
      final JTextArea textArea = new JTextArea();
      textArea.setLineWrap(true);
      textArea.setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
      textArea.setWrapStyleWord(true);

      final JFrame frame = new JFrame("JCopyButton Example");
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setPreferredSize(new Dimension(500, 500));

      final Container contentPane = frame.getContentPane();
      contentPane.setLayout(new BorderLayout());
      contentPane.add(new JScrollPane(textArea), BorderLayout.CENTER);
      contentPane.add(new JCopyButton(textArea), BorderLayout.SOUTH);

      frame.setVisible(true);
      frame.pack();
      frame.setLocationRelativeTo(null);
    });
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.