资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

java代码美观 java代码长什么样

java写一套漂亮的代码,哪些设计模式比较常用

策略模式,单例模式,装饰模式,简单工厂模式这几种模式个人感觉在实际开发过程中用的比较多,开发的多了对模式的概念反而会渐渐模糊

网站设计制作、网站制作介绍好的网站是理念、设计和技术的结合。成都创新互联拥有的网站设计理念、多方位的设计风格、经验丰富的设计团队。提供PC端+手机端网站建设,用营销思维进行网站设计、采用先进技术开源代码、注重用户体验与SEO基础,将技术与创意整合到网站之中,以契合客户的方式做到创意性的视觉化效果。

java,有没有方法调整全部代码缩进,使全体更美观点?

在这里面找到快捷键方式,Window-Preferences-General-Key。输入format找到绑定输入Ctrl+Shift+F。应用一下,应该就可以了,有的版本快捷方式不同而已。

Java写一套漂亮的代码,哪些设计模式比较常用

对于代码结构上,看起来漂亮起作用的模式,常用的策略模式,工厂模式,装饰模式和观察者模式吧。但也看情景,生搬硬套会显得不够简洁的

java全是代码,怎么会做出非常漂亮的画面

唉,给你看看小Case的,自己运行一下

import java.awt.AlphaComposite;

import java.awt.Color;

import java.awt.Graphics;

import java.awt.Graphics2D;

import java.awt.image.BufferedImage;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JPanel;

import javax.swing.SwingUtilities;

public class TranslucentButton extends JButton {

BufferedImage buttonImage = null;

/** Creates a new instance of TranslucentButton */

public TranslucentButton(String label) {

super(label);

setOpaque(false);

}

public void paint(Graphics g) {

// Create an image for the button graphics if necessary

if (buttonImage == null || buttonImage.getWidth() != getWidth() ||

buttonImage.getHeight() != getHeight()) {

buttonImage = getGraphicsConfiguration().

createCompatibleImage(getWidth(), getHeight());//返回一个数据布局和颜色模型与此 GraphicsConfiguration 兼容的 BufferedImage

}

Graphics gButton = buttonImage.getGraphics();

gButton.setClip(g.getClip());//设置获取的当前的剪贴区域

// Have the superclass render the button for us

super.paint(gButton);

// Make the graphics object sent to this paint() method translucent

Graphics2D g2d = (Graphics2D)g;

AlphaComposite newComposite =

AlphaComposite.getInstance(AlphaComposite.SRC_OVER, .5f);

g2d.setComposite(newComposite);

// Copy the button's image to the destination graphics, translucently

g2d.drawImage(buttonImage, 0, 0, null);

}

private static void createAndShowGUI() {

JFrame f = new JFrame();

f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

f.setSize(300, 300);

JPanel checkerboard = new Checkerboard();

checkerboard.add(new TranslucentButton("Translucent Button"));

f.add(checkerboard);

f.setVisible(true);

}

public static void main(String args[]) {

Runnable doCreateAndShowGUI = new Runnable() {

public void run() {

createAndShowGUI();

}

};

SwingUtilities.invokeLater(doCreateAndShowGUI);//swing线程

}

private static class Checkerboard extends JPanel {

static final int CHECKER_SIZE = 60;

public void paintComponent(Graphics g) {

g.setColor(Color.white);

g.fillRect(0, 0, getWidth(), getHeight());

g.setColor(Color.BLACK);

for (int stripeX = 0; stripeX getWidth(); stripeX += CHECKER_SIZE) {

for (int y = 0, row = 0; y getHeight(); y += CHECKER_SIZE/2, ++row) {

int x = (row % 2 == 0) ? stripeX : (stripeX + CHECKER_SIZE/2);

g.fillRect(x, y, CHECKER_SIZE/2, CHECKER_SIZE/2);

}

}

}

}

}


文章名称:java代码美观 java代码长什么样
标题路径:http://cdkjz.cn/article/ddcghgg.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220