第18章 组合框-阿里云开发者社区

开发者社区> dongzhumao> 正文

第18章 组合框

简介: 第18章 组合框   由JComboBox类实现的组合框是由一个可编辑区(缺省时是一个文本区)和一个可选取项的下拉列表组成的。因此,我们采取把它与JList比较的方式来介绍JComboBox. 18.1 JComboBox与JList的比较   JList和ComboBox很相似,因为这两个组件都显示一个项列表。
+关注继续查看

18章 组合框

  由JComboBox类实现的组合框是由一个可编辑区(缺省时是一个文本区)和一个可选取项的下拉列表组成的。因此,我们采取把它与JList比较的方式来介绍JComboBox.

18.1 JComboBoxJList的比较

  JListComboBox很相似,因为这两个组件都显示一个项列表。因此,它们都有扩展ListModel接口的模型。而且,这两个组件都有绘制器,这些绘制器通过实现ListCellBenderer接口来绘制列表单元。
  但是,列表和组合框在施工方面还是有差别的。列表单是不可编辑的,但是组合框可以配备一个编辑器。JComboBox组件把编辑工作交给实现ComboBoxEdit接口的一个对象来处理。
  列表支持三个选取模式,并把选取工作实现ListSelectionModel接口的一个对象来处理。组合框在一个时刻只有一个可选取的项,而且选取工作由组合框模型来处理。另一方面,组合框支持键选取,即在某项上按下一下键就可以选取这个项,但列表不能这样做。

18.2 JComboBox组件

 

18-1 可编辑组合框和不可编辑组合框

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Test extends JApplet {
private JCheckBox checkBox = new JCheckBox("Editable");
private JComboBox comboBox = new JComboBox();

public void init() {
Container contentPane = getContentPane();

comboBox.addItem("Top");
comboBox.addItem("Center");
comboBox.addItem("Bottom");

checkBox.setSelected(comboBox.isEditable());

contentPane.setLayout(new FlowLayout());
contentPane.add(checkBox);
contentPane.add(comboBox);

checkBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
comboBox.setEditable(checkBox.isSelected());
}
});
comboBox.getEditor().addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("here" +
comboBox.getSelectedItem());
}
});
}
public static void main(String args[]) {
final JFrame f = new JFrame();
JApplet applet = new Test();

applet.init();

f.setContentPane(applet.getContentPane());
f.setBounds(100,100,308,199);
f.setTitle("An Application");
f.setVisible(true);

f.setDefaultCloseOperation(
WindowConstants.DISPOSE_ON_CLOSE);

f.addWindowListener(new WindowAdapter() {
public void windowClosed(WindowEvent e) {
System.exit(0);
}
});
}
}

18.3 组合框模型

 

18.3.1 JComboBoxModel

 

18.3.2 MutableComboBoxModel

 

18.3.3 DefaultComboBoxModel

 

18.4 组合框单绘制器

 

18-2 一个定制的列表单元绘制器

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class Test extends JApplet {
public void init() {
Container contentPane = getContentPane();
JComboBox combo = new JComboBox(new Object[] {
new Object[] { Color.gray, "gray" },
new Object[] { Color.orange, "orange" },
new Object[] { Color.red, "red" },
new Object[] { Color.blue, "blue" },
new Object[] { Color.yellow, "yellow" },
new Object[] { Color.magenta, "magenta" },
new Object[] { Color.black, "black" },
new Object[] { Color.green, "green" },
new Object[] { Color.lightGray, "lightGray"} });

combo.setRenderer(new ColorRenderer());

contentPane.setLayout(new FlowLayout());
contentPane.add(combo);
}
}
class ColorRenderer extends JLabel implements ListCellRenderer {
private static ColorIcon icon = new ColorIcon();

private Border
redBorder = BorderFactory.createLineBorder(Color.red,2),
emptyBorder = BorderFactory.createEmptyBorder(2,2,2,2);

public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
Object[] array = (Object[])value;

icon.setColor((Color)array[0]);
setIcon(icon);
setText((String)array[1]);

if(isSelected) setBorder(redBorder);
else setBorder(emptyBorder);

return this;
}
}
class ColorIcon implements Icon {
private Color color;
private int w, h;

public ColorIcon() {
this(Color.gray, 50, 15);
}
public ColorIcon(Color color, int w, int h) {
this.color = color;
this.w = w;
this.h = h;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(Color.black);
g.drawRect(x, y, w-1, h-1);
g.setColor(color);
g.fillRect(x+1, y+1, w-2, h-2);
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public int getIconWidth() {
return w;
}
public int getIconHeight() {
return h;
}
}

18.5 组合框键选取管理器

 

18.5.1 使用缺省键选取管理

 

18-3 使用缺省的键选取管理器

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class Test extends JApplet {
private JComboBox colorCombo = new JComboBox(new Object[] {
new Item(new Object[] { Color.gray, "gray" }),
new Item(new Object[] { Color.orange, "orange" }),
new Item(new Object[] { Color.red, "red" }),
new Item(new Object[] { Color.blue, "blue" }),
new Item(new Object[] { Color.yellow, "yellow" }),
new Item(new Object[] { Color.magenta, "magenta" }),
new Item(new Object[] { Color.black, "black" }),
new Item(new Object[] { Color.green, "green" }),
new Item(new Object[] { Color.lightGray, "lightGray"})
});

public void init() {
final Container contentPane = getContentPane();

colorCombo.setRenderer(new ColorRenderer());

contentPane.setLayout(new FlowLayout());
contentPane.add(colorCombo);

colorCombo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
Item item = (Item)colorCombo.getSelectedItem();
String first = item.toString().substring(0,1);

showStatus("'" + first + "'" + " is for " + item);
}
});
}
}
class Item {
private Color color;
private String string;

public Item(Object[] array) {
color = (Color)array[0];
string = (String)array[1];
}
public Color getColor() { return color; }
public String toString() { return string; }
}
class ColorRenderer extends JLabel implements ListCellRenderer {
private static ColorIcon icon = new ColorIcon();

private Border
redBorder = BorderFactory.createLineBorder(Color.red,2),
emptyBorder = BorderFactory.createEmptyBorder(2,2,2,2);

public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
Item item = (Item)value;

icon.setColor(item.getColor());

setIcon(icon);
setText(item.toString());

if(isSelected) setBorder(redBorder);
else setBorder(emptyBorder);

return this;
}
}
class ColorIcon implements Icon {
private Color color;
private int w, h;

public ColorIcon() {
this(Color.gray, 50, 15);
}
public ColorIcon(Color color, int w, int h) {
this.color = color;
this.w = w;
this.h = h;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(Color.black);
g.drawRect(x, y, w-1, h-1);
g.setColor(color);
g.fillRect(x+1, y+1, w-2, h-2);
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public int getIconWidth() {
return w;
}
public int getIconHeight() {
return h;
}
}

18.5.2 定制键选取管理器

 

18-4 实现一个定制的键选取管理器

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class Test extends JApplet {
private ColorKeySelectionManager ksm =
new ColorKeySelectionManager();

private JComboBox colorCombo = new JComboBox(new Object[] {
new Item(new Object[] { Color.gray, "gray" }),
new Item(new Object[] { Color.orange, "orange" }),
new Item(new Object[] { Color.red, "red" }),
new Item(new Object[] { Color.blue, "blue" }),
new Item(new Object[] { Color.yellow, "yellow" }),
new Item(new Object[] { Color.magenta, "magenta" }),
new Item(new Object[] { Color.black, "black" }),
new Item(new Object[] { Color.green, "green" }),
new Item(new Object[] { Color.lightGray, "lightGray"})
});
public void init() {
final Container contentPane = getContentPane();

colorCombo.setRenderer(new ColorRenderer());
colorCombo.setKeySelectionManager(ksm);

contentPane.setLayout(new FlowLayout());
contentPane.add(colorCombo);

colorCombo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
Item item = (Item)colorCombo.getSelectedItem();
String itemString = item.toString();

showStatus("'" + ksm.getSearchString() +
"'" + " is for " + itemString);
}
});
}
}
class Item {
private Color color;
private String string;

public Item(Object[] array) {
color = (Color)array[0];
string = (String)array[1];
}
public Color getColor() { return color; }
public String toString() { return string; }
}
class ColorRenderer extends JLabel implements ListCellRenderer {
private static ColorIcon icon = new ColorIcon();

private Border
redBorder = BorderFactory.createLineBorder(Color.red,2),
emptyBorder = BorderFactory.createEmptyBorder(2,2,2,2);

public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
Item item = (Item)value;

icon.setColor(item.getColor());
setIcon(icon);
setText(item.toString());

if(isSelected) setBorder(redBorder);
else setBorder(emptyBorder);

return this;
}
}
class ColorIcon implements Icon {
private Color color;
private int w, h;

public ColorIcon() {
this(Color.gray, 50, 15);
}
public ColorIcon(Color color, int w, int h) {
this.color = color;
this.w = w;
this.h = h;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(Color.black);
g.drawRect(x, y, w-1, h-1);
g.setColor(color);
g.fillRect(x+1, y+1, w-2, h-2);
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public int getIconWidth() {
return w;
}
public int getIconHeight() {
return h;
}
}
class ColorKeySelectionManager
implements JComboBox.KeySelectionManager {
private String searchString = new String();
private long lastTime;

public int selectionForKey(char key,ComboBoxModel model) {
updateSearchString(model, key);

int start = getIndexAfter(model,getSelectedString(model));
int selection = search(model, start);

if(selection == -1 && start != 0)
selection = search(model, 0);

return selection;
}
public String getSearchString() {
return searchString;
}
private int search(ComboBoxModel model, int start) {
for(int i=start; i < model.getSize(); ++i) {
String s = getString(model, i);
int searchLength = searchString.length();

if(s.regionMatches(0,searchString,0,searchLength))
return i;
}
return -1;
}
private int getIndexAfter(ComboBoxModel model, String find) {
int size = model.getSize();

if(find != null) {
for(int i=0; i < size; ++i) {
String s = getString(model, i);

if(s.compareToIgnoreCase(find) == 0) {
return (i == size-1) ? 0 : i + 1;
}
}
}
return 0;
}
private String getString(ComboBoxModel model, int index) {
Item item = (Item)model.getElementAt(index);
return item.toString();
}
private String getSelectedString(ComboBoxModel model) {
Item item = (Item)model.getSelectedItem();
return item.toString();
}
private void updateSearchString(
ComboBoxModel model, char key) {
long time = System.currentTimeMillis();

if(time - lastTime < 500) searchString += key;
else searchString = "" + key;

lastTime = time;
}
}

18.5.3 程序式的键选取

 

18-5 使用SwingUtilities.invokeLater()

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class Test extends JApplet {
private JComboBox charsCombo = new JComboBox(new Object[] {
new Character('g'), new Character('o'),
new Character('r'), new Character('b'),
new Character('y'), new Character('m'),
new Character('g'), new Character('l'),
});
private JComboBox colorCombo = new JComboBox(new Object[] {
new Item(new Object[] { Color.gray, "gray" }),
new Item(new Object[] { Color.orange, "orange" }),
new Item(new Object[] { Color.red, "red" }),
new Item(new Object[] { Color.blue, "blue" }),
new Item(new Object[] { Color.yellow, "yellow" }),
new Item(new Object[] { Color.magenta, "magenta" }),
new Item(new Object[] { Color.black, "black" }),
new Item(new Object[] { Color.green, "green" }),
new Item(new Object[] { Color.lightGray, "lightGray"})
});

public void init() {
final Container contentPane = getContentPane();

colorCombo.setRenderer(new ColorRenderer());

colorCombo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
Item item = (Item)colorCombo.getSelectedItem();
Character first = new Character(
item.toString().charAt(0));

showStatus("'" + first.toString() + "'" +
" is for " + item);
}
});
charsCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final Character c = (Character)
charsCombo.getSelectedItem();

colorCombo.selectWithKeyChar(c.charValue());

SwingUtilities.invokeLater(new Runnable() {
public void run() {
Item item = (Item)
colorCombo.getSelectedItem();

JOptionPane.showMessageDialog(contentPane,
"'" + c.toString() + "'" +
" is for " + item.toString());
}
});
}
});
contentPane.setLayout(
new FlowLayout(FlowLayout.CENTER, 10, 35));

contentPane.add(new JLabel("Select a Character:"));
contentPane.add(charsCombo);
contentPane.add(colorCombo);
}
}
class Item {
private Color color;
private String string;

public Item(Object[] array) {
color = (Color)array[0];
string = (String)array[1];
}
public Color getColor() { return color; }
public String toString() { return string; }
}

class ColorRenderer extends JLabel implements ListCellRenderer {
private static ColorIcon icon = new ColorIcon();

private Border
redBorder = BorderFactory.createLineBorder(Color.red,2),
emptyBorder = BorderFactory.createEmptyBorder(2,2,2,2);

public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
Item item = (Item)value;

icon.setColor(item.getColor());

setIcon(icon);
setText(item.toString());

if(isSelected) setBorder(redBorder);
else setBorder(emptyBorder);

return this;
}
}
class ColorIcon implements Icon {
private Color color;
private int w, h;

public ColorIcon() {
this(Color.gray, 50, 15);
}
public ColorIcon(Color color, int w, int h) {
this.color = color;
this.w = w;
this.h = h;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(Color.black);
g.drawRect(x, y, w-1, h-1);
g.setColor(color);
g.fillRect(x+1, y+1, w-2, h-2);
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public int getIconWidth() {
return w;
}
public int getIconHeight() {
return h;
}
}

18.6 组合框编辑器

 

18-6 实现一个定制的组合框编辑器

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;

public class Test extends JApplet {
private JComboBox comboBox =
new JComboBox(new Object[] {
new Item(new Object[] {Color.gray, "gray"}),
new Item(new Object[] {Color.orange, "orange"}),
new Item(new Object[] {Color.red, "red"}),
new Item(new Object[] {Color.blue, "blue"}),
new Item(new Object[] {Color.yellow, "yellow"}),
new Item(new Object[] {Color.magenta, "magenta"}),
new Item(new Object[] {Color.black, "black"}),
new Item(new Object[] {Color.green, "green"}),
new Item(new Object[] {Color.lightGray, "lightGray"}),
new Item(new Object[] {Color.white, "white"}),
});

public void init() {
Container contentPane = getContentPane();

comboBox.setRenderer(new ColorRendererer());
comboBox.setEditor(new ColorComboBoxEditor());
comboBox.setEditable(true);

contentPane.setLayout(new FlowLayout());
contentPane.add(comboBox);
}
}
class Item {
private Color color;
private String string;

public Item(Object[] array) {
color = (Color)array[0];
string = (String)array[1];
}
public Color getColor() { return color; }
public String toString() { return string; }
}
class ColorComboBoxEditor extends AbstractComboBoxEditor {
ColorIcon editorIcon = new ColorIcon();
JLabel editorLabel = new JLabel(editorIcon);

Item item;

JColorChooser colorChooser = new JColorChooser();
ActionListener okListener = new OKListener();
Dialog dialog = JColorChooser.createDialog(
null, // parentComponent
"Choose A Color",// title
true, // modal
colorChooser,
okListener,
null); // cancel listener

public ColorComboBoxEditor() {
editorLabel.setBorder(BorderFactory.createEtchedBorder());

editorLabel.addMouseListener(new MouseAdapter() {
public void mousePressed(MouseEvent e) {
dialog.setVisible(true);
}
});
}
class OKListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
item =
new Item(new Object[] {
colorChooser.getColor(), null});

fireActionPerformed(e);
}
}
public Component getEditorComponent() {
return editorLabel;
}
public Object getItem() {
return item;
}
public void setItem(Object itemToSet) {
item = (Item)itemToSet;

// cannot set the selected item in an editor's
// setItem method, or an infinite loop results

editorIcon.setColor(item.getColor());
editorLabel.setText(item.toString());
}
public void selectAll() {
// from ComboBoxModel interface: nothing to select
}
}
abstract class AbstractComboBoxEditor implements ComboBoxEditor {
EventListenerList listenerList = new EventListenerList();

public void addActionListener(ActionListener listener) {
listenerList.add(ActionListener.class, listener);
}
public void removeActionListener(ActionListener listener) {
listenerList.remove(ActionListener.class, listener);
}
protected void fireActionPerformed(ActionEvent e) {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();

// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length-2; i>=0; i-=2) {
if (listeners[i]==ActionListener.class) {
((ActionListener)
listeners[i+1]).actionPerformed(e);
}
}
}
}
class ColorRendererer extends JLabel implements ListCellRenderer {
private ColorIcon icon = new ColorIcon();

public ColorRendererer() {
setOpaque(true);
setIcon(icon);
}
public Component getListCellRendererComponent(
JList list,
Object value,
int index,
boolean isSelected,
boolean cellHasFocus) {
Item item = (Item)value;

icon.setColor(item.getColor());
setText(item.toString());

if(isSelected) {
setForeground(list.getSelectionForeground());
setBackground(list.getSelectionBackground());
}
else {
setForeground(list.getForeground());
setBackground(list.getBackground());
}
return this;
}
}
class ColorIcon implements Icon {
private Color color;
private int w, h;

public ColorIcon() {
this(Color.gray, 50, 15);
}
public ColorIcon(Color color, int w, int h) {
this.color = color;
this.w = w;
this.h = h;
}
public void paintIcon(Component c, Graphics g, int x, int y) {
g.setColor(Color.black);
g.drawRect(x, y, w-1, h-1);
g.setColor(color);
g.fillRect(x+1, y+1, w-2, h-2);
}
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public int getIconWidth() {
return w;
}
public int getIconHeight() {
return h;
}
}

18.6.1 JComboBox属性

 

 

18.6.2 JComboBox事件

 

18-7 处理选取事件

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Test extends JApplet {
private JComboBox comboBox = new JComboBox();

public void init() {
Container contentPane = getContentPane();

comboBox.addItem("Top");
comboBox.addItem("Center");
comboBox.addItem("Bottom");

contentPane.setLayout(new FlowLayout());
contentPane.add(comboBox);

comboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent event) {
int state = event.getStateChange();
String item = (String)event.getItem(), s;

if(event.getStateChange() == ItemEvent.SELECTED)
s = " selected";
else
s = " deselected";

JOptionPane.showMessageDialog(
comboBox, // parent component
item + s, // message
"JComboBox Selection", // title
JOptionPane.INFORMATION_MESSAGE); // type
}
});
}
}

18-8 处理编辑事件

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Test extends JApplet {
private JComboBox comboBox = new JComboBox();
private ComboBoxEditor editor = comboBox.getEditor();

public void init() {
Container contentPane = getContentPane();

comboBox.setEditable(true);

comboBox.addItem("Top");
comboBox.addItem("Center");
comboBox.addItem("Bottom");

contentPane.setLayout(new FlowLayout());
contentPane.add(comboBox);

editor.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String s = (String)editor.getItem();
showStatus("Item Edited: " + s);
}
});
}
}

 

18.6.3 JComboBox类总结

 

18-9 手工显示一个组件框的弹出式菜单

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Test extends JApplet {
public void init() {
Container contentPane = getContentPane();
JButton button = new JButton("show popup");
final JComboBox combo = new JComboBox();

combo.addItem("first item");
combo.addItem("second item");
combo.addItem("third item");
combo.addItem("fourth item");
combo.addItem("fifth item");

button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
combo.showPopup();
}
});
contentPane.setLayout(new FlowLayout());
contentPane.add(button);
contentPane.add(combo);
}
}

18.6.4 AWT兼容

 

18.7 本章回顾

 

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
使用OpenApi弹性释放和设置云服务器ECS释放
云服务器ECS的一个重要特性就是按需创建资源。您可以在业务高峰期按需弹性的自定义规则进行资源创建,在完成业务计算的时候释放资源。本篇将提供几个Tips帮助您更加容易和自动化的完成云服务器的释放和弹性设置。
7748 0
阿里云服务器安全组设置内网互通的方法
虽然0.0.0.0/0使用非常方便,但是发现很多同学使用它来做内网互通,这是有安全风险的,实例有可能会在经典网络被内网IP访问到。下面介绍一下四种安全的内网互联设置方法。 购买前请先:领取阿里云幸运券,有很多优惠,可到下文中领取。
9423 0
windows server 2008阿里云ECS服务器安全设置
最近我们Sinesafe安全公司在为客户使用阿里云ecs服务器做安全的过程中,发现服务器基础安全性都没有做。为了为站长们提供更加有效的安全基础解决方案,我们Sinesafe将对阿里云服务器win2008 系统进行基础安全部署实战过程! 比较重要的几部分 1.
5454 0
腾讯云服务器 设置ngxin + fastdfs +tomcat 开机自启动
在tomcat中新建一个可以启动的 .sh 脚本文件 /usr/local/tomcat7/bin/ export JAVA_HOME=/usr/local/java/jdk7 export PATH=$JAVA_HOME/bin/:$PATH export CLASSPATH=.
2135 0
如何设置阿里云服务器安全组?阿里云安全组规则详细解说
阿里云安全组设置详细图文教程(收藏起来) 阿里云服务器安全组设置规则分享,阿里云服务器安全组如何放行端口设置教程。阿里云会要求客户设置安全组,如果不设置,阿里云会指定默认的安全组。那么,这个安全组是什么呢?顾名思义,就是为了服务器安全设置的。安全组其实就是一个虚拟的防火墙,可以让用户从端口、IP的维度来筛选对应服务器的访问者,从而形成一个云上的安全域。
3828 0
阿里云服务器如何登录?阿里云服务器的三种登录方法
购买阿里云ECS云服务器后如何登录?场景不同,云吞铺子总结大概有三种登录方式: 登录到ECS云服务器控制台 在ECS云服务器控制台用户可以更改密码、更换系统盘、创建快照、配置安全组等操作如何登录ECS云服务器控制台? 1、先登录到阿里云ECS服务器控制台 2、点击顶部的“控制台” 3、通过左侧栏,切换到“云服务器ECS”即可,如下图所示 通过ECS控制台的远程连接来登录到云服务器 阿里云ECS云服务器自带远程连接功能,使用该功能可以登录到云服务器,简单且方便,如下图:点击“远程连接”,第一次连接会自动生成6位数字密码,输入密码即可登录到云服务器上。
16805 0
阿里云服务器ECS登录用户名是什么?系统不同默认账号也不同
阿里云服务器Windows系统默认用户名administrator,Linux镜像服务器用户名root
1129 0
+关注
dongzhumao
专注JAVA语言,对大数据、BI有深入研究,擅长制作解决方案。 10年工作经验,致力于软件开发,深入互联网教育行业。
163
文章
1
问答
文章排行榜
最热
最新
相关电子书
更多
文娱运维技术
立即下载
《SaaS模式云原生数据仓库应用场景实践》
立即下载
《看见新力量:二》电子书
立即下载