java各種圖案代碼 java顯示圖案java

java代碼編圖案 1 1 2 1 1 2 4 2 1 1 2 4 8 4 2 1 1 2 4 8 16 8 4 2 1

public class FF {

成都創(chuàng)新互聯(lián)公司服務(wù)項目包括北碚網(wǎng)站建設(shè)、北碚網(wǎng)站制作、北碚網(wǎng)頁制作以及北碚網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,北碚網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到北碚省份的部分城市,未來相信會繼續(xù)擴大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!

public static void main(String[] args) {

for(int i=0;i5;i++){

for(int k=0;k5-2*i+3;k++){

System.out.print(" ");

}

for(int j=0;ji+1;j++){

System.out.print(" "+(int)Math.pow(2,j));

}

for(int j=i-1;j=0;j--){

System.out.print(" "+(int)Math.pow(2,j));

}

System.out.println();

}

}

}

JAVA的圖形用戶界面代碼

package hao;

import java.awt.BorderLayout;

import java.awt.Color;

import java.awt.Dimension;

import java.awt.GridLayout;

import java.io.File;

import javax.swing.BorderFactory;

import javax.swing.Box;

import javax.swing.ImageIcon;

import javax.swing.JButton;

import javax.swing.JComboBox;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JScrollPane;

import javax.swing.JTextArea;

import javax.swing.JTextPane;

import javax.swing.text.BadLocationException;

import javax.swing.text.SimpleAttributeSet;

import javax.swing.text.StyleConstants;

import javax.swing.text.StyledDocument;

public class ChatPanel extends JPanel {

private static final long serialVersionUID = 1L;

JButton send,record,saveRecord,image;

JTextArea inputArea;

JTextPane text;//注意用法****************************************************************************

JComboBox fontName = null, fontSize = null, fontStyle = null, fontColor = null,fontBackColor = null;

public StyledDocument doc = null; JScrollPane scrollPane;JPanel textChat;

JButton music;

public ChatPanel() {

setLayout(new BorderLayout());

text = new JTextPane();

text.setEditable(false);

doc = text.getStyledDocument();//跟蹤文本和圖片寫到該區(qū)域的位置*************************************

scrollPane = new JScrollPane(text);

//注意下面對JComboBox的巧用***********************************************************************

String[] str_name = { "宋體", "黑體", "Dialog", "Gulim" };

String[] str_Size = { "12", "14", "18", "22", "30", "40" };

String[] str_Style = { "常規(guī)", "斜體", "粗體", "粗斜體" };

String[] str_Color = { "黑色", "紅色", "藍(lán)色", "黃色", "綠色" };

String[] str_BackColor = { "無色", "灰色", "淡紅", "淡藍(lán)", "淡黃", "淡綠" };

fontName = new JComboBox(str_name);

fontSize = new JComboBox(str_Size);

fontStyle = new JComboBox(str_Style);

fontColor = new JComboBox(str_Color);

fontBackColor = new JComboBox(str_BackColor);

fontName.setBackground(new Color(255,153,255));

fontSize.setBackground(new Color(255,153,255));

fontStyle.setBackground(new Color(255,153,255));

fontColor.setBackground(new Color(255,153,255));

fontBackColor.setBackground(new Color(255,153,255));

Box box = Box.createVerticalBox();//創(chuàng)建一個可以容納多個Box組件的Box*******************************

Box box_1 = Box.createHorizontalBox();

Box box_2 = Box.createHorizontalBox();

Box box_4 = Box.createHorizontalBox();

box.add(box_1);

box.add(box_2);

box.add(box_4);

JLabel b1= new JLabel("字體~~"), b2 = new JLabel("樣式~~"),b3 = new JLabel("字號~~"),b4 = new JLabel("顏色~~"),b5 = new JLabel("背景~~");

b1.setBackground(new Color(255,153,255));

b2.setBackground(new Color(255,153,255));

b3.setBackground(new Color(255,153,255));

b4.setBackground(new Color(255,153,255));

b5.setBackground(new Color(255,153,255));

box_1.add(b1);

box_1.add(fontName);

box_1.add(Box.createHorizontalStrut(8));

box_1.add(b2);

box_1.add(fontStyle);

box_1.add(Box.createHorizontalStrut(8));

box_1.add(b3);

box_1.add(fontSize);

box_2.add(Box.createHorizontalStrut(8));

box_2.add(b4);

box_2.add(fontColor);

box_2.add(Box.createHorizontalStrut(8));

box_4.add(b5);

box_4.add(fontBackColor);

textChat = new JPanel();

textChat.setLayout(new BorderLayout());

textChat.setBackground(new Color(255,153,255));

inputArea = new JTextArea(3, 20);

inputArea.setLineWrap(true); //設(shè)置文本區(qū)的換行策略。88888*********************************

send = new JButton("發(fā)送");

record=new JButton("顯示記錄");

saveRecord=new JButton("儲存記錄");

image=new JButton("表情");

send.setBackground(new Color(255,153,255));

record.setBackground(new Color(255,153,255));

saveRecord.setBackground(new Color(255,153,255));

image.setBackground(new Color(255,153,255));

Box box_3 = Box.createHorizontalBox();

box_3.add(send); box_3.add(Box.createHorizontalStrut(8));//設(shè)置按鈕間距*************************888

box_3.add(record); box_3.add(Box.createHorizontalStrut(8)); //設(shè)置按鈕間距*************************888

box_3.add(saveRecord); box_3.add(Box.createHorizontalStrut(8));//設(shè)置按鈕間距*************************888

box_3.add(image);

box.setBorder(BorderFactory.createLineBorder(new Color(102,102,0),5));//設(shè)置Box的邊框線********************

box_3.setBorder(BorderFactory.createLineBorder(new Color(102,102,0),5));

textChat.add(box,BorderLayout.NORTH);

textChat.add(inputArea,BorderLayout.CENTER);

textChat.add(box_3, BorderLayout.SOUTH);

inputArea.requestFocus(true);

inputArea.setBorder(BorderFactory.createLineBorder(new Color(102,102,0),5));//設(shè)置輸入窗口邊框線*******************

text.setBorder(BorderFactory.createLineBorder(new Color(102,102,0),8));//設(shè)置輸入窗口邊框線*******************

JPanel audioPanel = new JPanel();//最上面的邊框************************************************************************

audioPanel.setBackground(new Color(255,153,255));

audioPanel.setLayout(new GridLayout(1,1));

music = new JButton("想聽就聽");

music.setPreferredSize(new Dimension(320,50));

music.setBorder(BorderFactory.createLineBorder(Color.BLACK,10));//設(shè)置輸入窗口邊框線*******************

audioPanel.add(music);

add(audioPanel, BorderLayout.NORTH);

add(scrollPane,BorderLayout.CENTER);

add(textChat, BorderLayout.SOUTH);

}

void insertIcon(ImageIcon image) {

text.setCaretPosition(doc.getLength());

text.insertIcon(image);

insert(new MessageStyle());//?????????????????????????????????????????????????????????????????????????????/

}

public void insert(MessageStyle attrib) {

try {

doc.insertString(doc.getLength(), attrib.getText() + "\n", attrib.getAttrSet());//寫完后接著換行************

} catch (BadLocationException e) {

e.printStackTrace();

}

}

public MessageStyle getMessageStyle(String line) {

MessageStyle att = new MessageStyle();

att.setText(line);

att.setName((String) fontName.getSelectedItem());

att.setSize(Integer.parseInt((String) fontSize.getSelectedItem()));

String temp_style = (String) fontStyle.getSelectedItem();

if (temp_style.equals("常規(guī)")) {

att.setStyle(MessageStyle.GENERAL);

}

else if (temp_style.equals("粗體")) {

att.setStyle(MessageStyle.BOLD);

}

else if (temp_style.equals("斜體")) {

att.setStyle(MessageStyle.ITALIC);

}

else if (temp_style.equals("粗斜體")) {

att.setStyle(MessageStyle.BOLD_ITALIC);

}

String temp_color = (String) fontColor.getSelectedItem();

if (temp_color.equals("黑色")) {

att.setColor(new Color(0, 0, 0));

}

else if (temp_color.equals("紅色")) {

att.setColor(new Color(255, 0, 0));

}

else if (temp_color.equals("藍(lán)色")) {

att.setColor(new Color(0, 0, 255));

}

else if (temp_color.equals("黃色")) {

att.setColor(new Color(255, 255, 0));

}

else if (temp_color.equals("綠色")) {

att.setColor(new Color(0, 255, 0));

}

String temp_backColor = (String) fontBackColor.getSelectedItem();

if (!temp_backColor.equals("無色")) {

if (temp_backColor.equals("灰色")) {

att.setBackColor(new Color(200, 200, 200));

}

else if (temp_backColor.equals("淡紅")) {

att.setBackColor(new Color(255, 200, 200));

}

else if (temp_backColor.equals("淡藍(lán)")) {

att.setBackColor(new Color(200, 200, 255));

}

else if (temp_backColor.equals("淡黃")) {

att.setBackColor(new Color(255, 255, 200));

}

else if (temp_backColor.equals("淡綠")) {

att.setBackColor(new Color(200, 255, 200));

}

}

return att;

}

}

請問 用java語句輸出如圖片圖案應(yīng)該怎么做?

1、代碼如下:

public class Main

{

public static void main(String[] args) {

System.out.println("Hello World!");

//主循環(huán)

? for(int i =10;i0;i--){

? ? ? //輸出空格

? ? ? for(int k=i;k0;k--){System.out.print(" ");}

//輸出數(shù)字

? ? ? for(int j=i;j=10;j++){

? ? ? ? ? System.out.print(j+" ");? ? ? ? ? ? ?

? ? ? }System.out.println(" ");

? }

}

}

2、效果如圖

求java繪圖程序源代碼(加注釋),在如下圖的基礎(chǔ)上,在圖案種類上添加圓角矩形,求代碼

直線 是 Line2D

矩形是 Rectangle2D

弧 Arc2D

橢圓 Ellipse2D

圓角矩形是 RoundRectangle2D

上面的都在 java.awt.geom包里

怎樣編寫如下圖案的java代碼123456 12345 1234 123 12 1從上到下

public class TestArray {

public static void main(String[] args){

int array[] = {1,2,3,4,5,6};

for(int i = array.length-1;i = 0;i--)

{

for(int j =0;j=i;j++)

{

System.out.print(array[j]);

}

System.out.println("");

}

}

}

本文名稱:java各種圖案代碼 java顯示圖案java
分享鏈接:http://muchs.cn/article8/hhegip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、網(wǎng)站內(nèi)鏈、網(wǎng)站制作域名注冊、網(wǎng)站導(dǎo)航、網(wǎng)站改版

廣告

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

成都app開發(fā)公司