java代碼美觀 java代碼長(zhǎng)什么樣

java寫(xiě)一套漂亮的代碼,哪些設(shè)計(jì)模式比較常用

策略模式,單例模式,裝飾模式,簡(jiǎn)單工廠模式這幾種模式個(gè)人感覺(jué)在實(shí)際開(kāi)發(fā)過(guò)程中用的比較多,開(kāi)發(fā)的多了對(duì)模式的概念反而會(huì)漸漸模糊

網(wǎng)站設(shè)計(jì)制作、網(wǎng)站制作介紹好的網(wǎng)站是理念、設(shè)計(jì)和技術(shù)的結(jié)合。成都創(chuàng)新互聯(lián)擁有的網(wǎng)站設(shè)計(jì)理念、多方位的設(shè)計(jì)風(fēng)格、經(jīng)驗(yàn)豐富的設(shè)計(jì)團(tuán)隊(duì)。提供PC端+手機(jī)端網(wǎng)站建設(shè),用營(yíng)銷(xiāo)思維進(jìn)行網(wǎng)站設(shè)計(jì)、采用先進(jìn)技術(shù)開(kāi)源代碼、注重用戶(hù)體驗(yàn)與SEO基礎(chǔ),將技術(shù)與創(chuàng)意整合到網(wǎng)站之中,以契合客戶(hù)的方式做到創(chuàng)意性的視覺(jué)化效果。

java,有沒(méi)有方法調(diào)整全部代碼縮進(jìn),使全體更美觀點(diǎn)?

在這里面找到快捷鍵方式,Window-Preferences-General-Key。輸入format找到綁定輸入Ctrl+Shift+F。應(yīng)用一下,應(yīng)該就可以了,有的版本快捷方式不同而已。

Java寫(xiě)一套漂亮的代碼,哪些設(shè)計(jì)模式比較常用

對(duì)于代碼結(jié)構(gòu)上,看起來(lái)漂亮起作用的模式,常用的策略模式,工廠模式,裝飾模式和觀察者模式吧。但也看情景,生搬硬套會(huì)顯得不夠簡(jiǎn)潔的

java全是代碼,怎么會(huì)做出非常漂亮的畫(huà)面

唉,給你看看小Case的,自己運(yùn)行一下

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());//返回一個(gè)數(shù)據(jù)布局和顏色模型與此 GraphicsConfiguration 兼容的 BufferedImage

}

Graphics gButton = buttonImage.getGraphics();

gButton.setClip(g.getClip());//設(shè)置獲取的當(dāng)前的剪貼區(qū)域

// 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線(xiàn)程

}

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代碼長(zhǎng)什么樣
本文鏈接:http://muchs.cn/article16/ddcghgg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、建站公司、網(wǎng)站收錄、標(biāo)簽優(yōu)化、企業(yè)建站網(wǎng)頁(yè)設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營(yíng)