Here you can find the source of getScrollStroke(final JButton _jlbl_stroke)
Parameter | Description |
---|---|
_jlbl_stroke | the background carrying item. |
public static void getScrollStroke(final JButton _jlbl_stroke)
//package com.java2s; /*//from w w w . j ava 2s . c om * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.awt.Color; import java.awt.IllegalComponentStateException; import java.awt.image.BufferedImage; import javax.swing.ImageIcon; import javax.swing.JButton; public class Main { /** * Apply stroke on background. * @param _jlbl_stroke the background carrying item. */ public static void getScrollStroke(final JButton _jlbl_stroke) { final int strokeDistance = 10; if (_jlbl_stroke.getWidth() > 0 && _jlbl_stroke.getHeight() > 0) { BufferedImage bi_stroke = new BufferedImage(_jlbl_stroke.getWidth(), _jlbl_stroke.getHeight(), BufferedImage.TYPE_INT_ARGB); for (int x = 0; x < bi_stroke.getWidth(); x++) { for (int y = 0; y < bi_stroke.getHeight(); y++) { try { if ((x + _jlbl_stroke.getLocationOnScreen().x - y - _jlbl_stroke.getLocationOnScreen().y) % strokeDistance == 0 // || (x + jlbl_stroke.getLocationOnScreen().x // + y + jlbl_stroke.getLocationOnScreen().y) // % strokeDistance == 0 ) { bi_stroke.setRGB(x, y, Color.lightGray.getRGB()); } else { final int rb = 255; final int g = 250; bi_stroke.setRGB(x, y, new Color(rb, g, rb).getRGB()); } } catch (IllegalComponentStateException e) { x = bi_stroke.getWidth(); y = bi_stroke.getHeight(); } } } _jlbl_stroke.setIcon(new ImageIcon(bi_stroke)); } } }