public class FF {
成都創(chuàng)新互聯(lián)公司服務(wù)項(xiàng)目包括北碚網(wǎng)站建設(shè)、北碚網(wǎng)站制作、北碚網(wǎng)頁(yè)制作以及北碚網(wǎng)絡(luò)營(yíng)銷(xiāo)策劃等。多年來(lái),我們專(zhuān)注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢(shì)、行業(yè)經(jīng)驗(yàn)、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,北碚網(wǎng)站推廣取得了明顯的社會(huì)效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶(hù)以成都為中心已經(jīng)輻射到北碚省份的部分城市,未來(lái)相信會(huì)繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶(hù)的支持與信任!
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();
}
}
}
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();//跟蹤文本和圖片寫(xiě)到該區(qū)域的位置*************************************
scrollPane = new JScrollPane(text);
//注意下面對(duì)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 = { "無(wú)色", "灰色", "淡紅", "淡藍(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)建一個(gè)可以容納多個(gè)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("字號(hào)~~"),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("儲(chǔ)存記錄");
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的邊框線(xiàn)********************
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è)置輸入窗口邊框線(xiàn)*******************
text.setBorder(BorderFactory.createLineBorder(new Color(102,102,0),8));//設(shè)置輸入窗口邊框線(xiàn)*******************
JPanel audioPanel = new JPanel();//最上面的邊框************************************************************************
audioPanel.setBackground(new Color(255,153,255));
audioPanel.setLayout(new GridLayout(1,1));
music = new JButton("想聽(tīng)就聽(tīng)");
music.setPreferredSize(new Dimension(320,50));
music.setBorder(BorderFactory.createLineBorder(Color.BLACK,10));//設(shè)置輸入窗口邊框線(xiàn)*******************
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());//寫(xiě)完后接著換行************
} 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("無(wú)色")) {
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;
}
}
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、效果如圖
直線(xiàn) 是 Line2D
矩形是 Rectangle2D
弧 Arc2D
橢圓 Ellipse2D
圓角矩形是 RoundRectangle2D
上面的都在 java.awt.geom包里
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("");
}
}
}