/**
* When server changes, get message
* @param changedValue
*/
@Override
public void flagChanged(IUnrealServer server) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
removeAll();
handleServerName();
if (serverDef.getServerFlag().getFlag() == null) {
add(new Label("Server not available ...", Label.CENTER), java.awt.BorderLayout.CENTER);
} else {
setUpMapPanel();
}
revalidate();
repaint();
}
}); /*
String msg = "Map changed to " + changedValue.getName() + " " + changedValue.getName();
JOptionPane.showMessageDialog(this, msg);
*/
}
java类java.awt.Label的实例源码
PureMapTopComponent.java 文件源码
项目:Pogamut3
阅读 19
收藏 0
点赞 0
评论 0
WPrinterJob.java 文件源码
项目:OpenJSharp
阅读 22
收藏 0
点赞 0
评论 0
private void init(Component parent, String title, String message,
String buttonText) {
Panel p = new Panel();
add("Center", new Label(message));
Button btn = new Button(buttonText);
btn.addActionListener(this);
p.add(btn);
add("South", p);
pack();
Dimension dDim = getSize();
if (parent != null) {
Rectangle fRect = parent.getBounds();
setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
fRect.y + ((fRect.height - dDim.height) / 2));
}
}
CalculatorGUI.java 文件源码
项目:apfloat
阅读 24
收藏 0
点赞 0
评论 0
/**
* Default constructor.
*/
protected CalculatorGUI()
{
super("Calculator");
setSize(720, 540);
addWindowListener(new WindowAdapter()
{
@Override
public void windowClosing(WindowEvent windowEvent)
{
setVisible(false);
dispose();
System.exit(0);
}
});
setLayout(new BorderLayout());
add(new CalculatorAWT(), BorderLayout.NORTH);
add(new Label(), BorderLayout.SOUTH);
setVisible(true);
}
WPrinterJob.java 文件源码
项目:jdk8u-jdk
阅读 23
收藏 0
点赞 0
评论 0
private void init(Component parent, String title, String message,
String buttonText) {
Panel p = new Panel();
add("Center", new Label(message));
Button btn = new Button(buttonText);
btn.addActionListener(this);
p.add(btn);
add("South", p);
pack();
Dimension dDim = getSize();
if (parent != null) {
Rectangle fRect = parent.getBounds();
setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
fRect.y + ((fRect.height - dDim.height) / 2));
}
}
MultiResolutionCursorTest.java 文件源码
项目:jdk8u-jdk
阅读 25
收藏 0
点赞 0
评论 0
public void start() {
//Get things going. Request focus, set size, et cetera
setSize(200, 200);
setVisible(true);
validate();
final Image image = new MultiResolutionCursor();
int center = sizes[0] / 2;
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
image, new Point(center, center), "multi-resolution cursor");
Frame frame = new Frame("Test Frame");
frame.setSize(300, 300);
frame.setLocation(300, 50);
frame.add(new Label("Move cursor here"));
frame.setCursor(cursor);
frame.setVisible(true);
}
WPrinterJob.java 文件源码
项目:openjdk-jdk10
阅读 28
收藏 0
点赞 0
评论 0
private void init(Component parent, String title, String message,
String buttonText) {
Panel p = new Panel();
add("Center", new Label(message));
Button btn = new Button(buttonText);
btn.addActionListener(this);
p.add(btn);
add("South", p);
pack();
Dimension dDim = getSize();
if (parent != null) {
Rectangle fRect = parent.getBounds();
setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
fRect.y + ((fRect.height - dDim.height) / 2));
}
}
ChildWindowProperties.java 文件源码
项目:openjdk-jdk10
阅读 24
收藏 0
点赞 0
评论 0
public void testChildPropertiesWithDialogAsParent() {
parentDialog = new Dialog((Dialog) null, "parent Dialog");
parentDialog.setSize(WIDTH, HEIGHT);
parentDialog.setLocation(100, 100);
parentDialog.setBackground(Color.RED);
parentLabel = new Label("ParentForegroundAndFont");
parentFont = new Font("Courier New", Font.ITALIC, 15);
parentDialog.setForeground(Color.BLUE);
parentDialog.setFont(parentFont);
parentDialog.add(parentLabel);
parentDialog.setVisible(true);
windowChild = new Window(parentDialog);
windowChild.setSize(WIDTH, HEIGHT);
windowChild.setLocation(WIDTH + 200, 100);
childLabel = new Label("ChildForegroundAndFont");
windowChild.add(childLabel);
windowChild.setVisible(true);
if (parentDialog.getBackground() == windowChild.getBackground()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Dialog's Background Color");
}
if (parentDialog.getForeground() == windowChild.getForeground()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Dialog's Foreground Color");
}
if (parentDialog.getFont() == windowChild.getFont()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Dialog's Font Color");
}
}
ChildWindowProperties.java 文件源码
项目:openjdk-jdk10
阅读 21
收藏 0
点赞 0
评论 0
public void testChildPropertiesWithFrameAsParent() {
parentFrame = new Frame("parent Frame");
parentFrame.setSize(WIDTH, HEIGHT);
parentFrame.setLocation(100, 400);
parentFrame.setBackground(Color.BLUE);
parentLabel = new Label("ParentForegroundAndFont");
parentFont = new Font("Courier New", Font.ITALIC, 15);
parentFrame.setForeground(Color.RED);
parentFrame.setFont(parentFont);
parentFrame.add(parentLabel);
parentFrame.setVisible(true);
frameChildWindow = new Window(parentFrame);
frameChildWindow.setSize(WIDTH, HEIGHT);
frameChildWindow.setLocation(WIDTH + 200, 400);
childLabel = new Label("ChildForegroundAndFont");
frameChildWindow.add(childLabel);
frameChildWindow.setVisible(true);
if (parentFrame.getBackground() == frameChildWindow.getBackground()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Frame's Background Color");
}
if (parentDialog.getForeground() == windowChild.getForeground()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Frame's Foreground Color");
}
if (parentDialog.getFont() == windowChild.getFont()) {
dispose();
throw new RuntimeException("Child Window Should NOT Inherit "
+ "Parent Frame's Font Color");
}
}
MultiResolutionCursorTest.java 文件源码
项目:openjdk-jdk10
阅读 27
收藏 0
点赞 0
评论 0
public void start() {
//Get things going. Request focus, set size, et cetera
setSize(200, 200);
setVisible(true);
validate();
final Image image = new BaseMultiResolutionImage(
createResolutionVariant(0),
createResolutionVariant(1),
createResolutionVariant(2),
createResolutionVariant(3)
);
int center = sizes[0] / 2;
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
image, new Point(center, center), "multi-resolution cursor");
Frame frame = new Frame("Test Frame");
frame.setSize(300, 300);
frame.setLocation(300, 50);
frame.add(new Label("Move cursor here"));
frame.setCursor(cursor);
frame.setVisible(true);
}
WPrinterJob.java 文件源码
项目:openjdk9
阅读 21
收藏 0
点赞 0
评论 0
private void init(Component parent, String title, String message,
String buttonText) {
Panel p = new Panel();
add("Center", new Label(message));
Button btn = new Button(buttonText);
btn.addActionListener(this);
p.add(btn);
add("South", p);
pack();
Dimension dDim = getSize();
if (parent != null) {
Rectangle fRect = parent.getBounds();
setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
fRect.y + ((fRect.height - dDim.height) / 2));
}
}
MultiResolutionCursorTest.java 文件源码
项目:openjdk9
阅读 32
收藏 0
点赞 0
评论 0
public void start() {
//Get things going. Request focus, set size, et cetera
setSize(200, 200);
setVisible(true);
validate();
final Image image = new BaseMultiResolutionImage(
createResolutionVariant(0),
createResolutionVariant(1),
createResolutionVariant(2),
createResolutionVariant(3)
);
int center = sizes[0] / 2;
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
image, new Point(center, center), "multi-resolution cursor");
Frame frame = new Frame("Test Frame");
frame.setSize(300, 300);
frame.setLocation(300, 50);
frame.add(new Label("Move cursor here"));
frame.setCursor(cursor);
frame.setVisible(true);
}
Installer.java 文件源码
项目:Advanced-Java-Tools
阅读 30
收藏 0
点赞 0
评论 0
public PanelSeleDir(String scname, final File defDir)
{
this.add(new Label("Select a folder to install "+scname+"."));
selector = new FileSelector(defDir, JFileChooser.DIRECTORIES_ONLY);
selector.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(selector))
{
selected_dir = selector.getSelectedFile();
}
System.out.println(e);
}
});
this.add(selector);
// TODO Auto-generated constructor stub
}
OMCPane.java 文件源码
项目:ipst
阅读 20
收藏 0
点赞 0
评论 0
/**
* This method initializes jPanel1
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel1() {
if (jPanel1 == null) {
label = new Label();
label.setText("Expression:");
jPanel1 = new JPanel();
JPanel jPanelX = new JPanel();
jPanelX.setLayout(new BoxLayout(jPanelX, BoxLayout.X_AXIS));
jPanelX.add(label, null);
jPanelX.add(getJTextField(), null);
jPanelX.add(getJButton(), null);
jPanelX.add(getJDemoButton(), null);
JPanel jPanelY = new JPanel();
jPanelY.setLayout(new BoxLayout(jPanelY, BoxLayout.Y_AXIS));
jPanelY.add(jPanelX);
Label helpLabel = new Label();
helpLabel.setText("Use <ENTER> or press Send to send the command, <Up>/<Down> keys for command history." +
" Press Demo for a quick demonstration of available OMC commands.");
jPanelY.add(helpLabel, null);
jPanel1.add(jPanelY);
}
return jPanel1;
}
Sample2048GUI.java 文件源码
项目:2048-Game-PC
阅读 24
收藏 0
点赞 0
评论 0
public void setColor(Label l,int value)
{
l.setText(value+"");
l.setFont(new java.awt.Font("Arial", 1, 60));
if(value==0)
{
l.setText("");
l.setBackground(Color.white);
}
else if(value==2)
l.setBackground(Color.yellow);
else if(value==4)
l.setBackground(Color.orange);
else if(value==8)
l.setBackground(Color.cyan);
else if(value==16)
l.setBackground(Color.green);
else if(value==32)
l.setBackground(Color.pink);
else if(value==64)
l.setBackground(Color.red);
else if(value==128)
l.setBackground(Color.blue);
else if(value==256)
l.setBackground(Color.magenta);
else if(value==512)
l.setBackground(Color.lightGray);
else if(value==1024)
l.setBackground(Color.darkGray);
else if(value==2048)
l.setBackground(Color.black);
if(value>64)
l.setFont(new java.awt.Font("Arial", 1, 45));
if(value>512)
l.setFont(new java.awt.Font("Arial", 1, 30));
}
PiGUI.java 文件源码
项目:aya-lang
阅读 27
收藏 0
点赞 0
评论 0
/**
* Default constructor.
*/
protected PiGUI()
{
super("Pi calculator");
setSize(720, 540);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent windowEvent)
{
setVisible(false);
dispose();
System.exit(0);
}
});
setLayout(new BorderLayout());
this.statusLabel = new Label();
add(getContents(), BorderLayout.NORTH);
add(this.statusLabel, BorderLayout.SOUTH);
setVisible(true);
}
CalculatorGUI.java 文件源码
项目:aya-lang
阅读 22
收藏 0
点赞 0
评论 0
/**
* Default constructor.
*/
protected CalculatorGUI()
{
super("Calculator");
setSize(720, 540);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent windowEvent)
{
setVisible(false);
dispose();
System.exit(0);
}
});
setLayout(new BorderLayout());
add(new CalculatorAWT(), BorderLayout.NORTH);
add(new Label(), BorderLayout.SOUTH);
setVisible(true);
}
AbstractGridElement.java 文件源码
项目:Push2Display
阅读 17
收藏 0
点赞 0
评论 0
/**
* Draws a text into a boundary. The text is clipped on the right border of the bounds.
*
* @param g The graphics context in which to draw
* @param text The text to draw
* @param x The x position of the boundary
* @param y The y position of the boundary
* @param width The width position of the boundary
* @param height The height position of the boundary
* @param alignment The alignment of the text: Label.LEFT or Label.CENTER
* @param textDescent Text text descent
*/
public static void drawTextInBounds (final Graphics2D g, final String text, final int x, final int y, final int width, final int height, final int alignment, final int textDescent)
{
if (text == null || text.length () == 0)
return;
final Dimension dim = getTextDims (g, text);
g.clipRect (x, y, width, height);
final int pos;
switch (alignment)
{
case Label.LEFT:
pos = x;
break;
case Label.CENTER:
default:
pos = x + (width - dim.width) / 2;
break;
}
g.drawString (text, pos, y + height - (height - dim.height) / 2 - textDescent);
g.setClip (null);
}
AbstractGridElement.java 文件源码
项目:Push2Display
阅读 23
收藏 0
点赞 0
评论 0
/**
* Draws a menu at the top of the element.
*
* @param gc The graphics context
* @param left The left bound of the menus drawing area
* @param width The width of the menu
* @param layoutSettings The layout settings to use
*/
protected void drawMenu (final Graphics2D gc, final int left, final int width, final LayoutSettings layoutSettings)
{
final Color borderColor = layoutSettings.getBorderColor ();
if (this.menuName == null || this.menuName.length () == 0)
{
// Remove the 2 pixels of the previous menus border line
gc.setColor (borderColor);
gc.fillRect (left - SEPARATOR_SIZE, MENU_HEIGHT - 2, SEPARATOR_SIZE, 1);
return;
}
final Color textColor = layoutSettings.getTextColor ();
gc.setColor (this.isMenuSelected ? textColor : borderColor);
gc.fillRect (left, 0, width, MENU_HEIGHT - 1);
gc.setColor (textColor);
gc.fillRect (left, MENU_HEIGHT - 2, width + SEPARATOR_SIZE, 1);
gc.setColor (this.isMenuSelected ? borderColor : textColor);
gc.setFont (layoutSettings.getTextFont (UNIT));
drawTextInBounds (gc, this.menuName, left, 0, width, UNIT + SEPARATOR_SIZE, Label.CENTER);
}
ListGridElement.java 文件源码
项目:Push2Display
阅读 22
收藏 0
点赞 0
评论 0
/** {@inheritDoc} */
@Override
public void draw (final Graphics2D gc, final int left, final int width, final int height, final LayoutSettings layoutSettings)
{
final int size = this.items.size ();
final int itemHeight = DISPLAY_HEIGHT / size;
final Color textColor = layoutSettings.getTextColor ();
final Color borderColor = layoutSettings.getBorderColor ();
for (int i = 0; i < size; i++)
{
final Pair<String, Boolean> item = this.items.get (i);
final boolean isSelected = item.getValue ().booleanValue ();
final int itemLeft = left + SEPARATOR_SIZE;
final int itemTop = i * itemHeight;
final int itemWidth = width - SEPARATOR_SIZE;
gc.setColor (isSelected ? textColor : borderColor);
gc.fillRect (itemLeft, itemTop + SEPARATOR_SIZE, itemWidth, itemHeight - 2 * SEPARATOR_SIZE);
gc.setColor (isSelected ? borderColor : textColor);
gc.setFont (layoutSettings.getTextFont (itemHeight / 2));
drawTextInBounds (gc, item.getKey (), itemLeft + INSET, itemTop, itemWidth - 2 * INSET, itemHeight, Label.LEFT);
}
}
WPrinterJob.java 文件源码
项目:jdk8u_jdk
阅读 25
收藏 0
点赞 0
评论 0
private void init(Component parent, String title, String message,
String buttonText) {
Panel p = new Panel();
add("Center", new Label(message));
Button btn = new Button(buttonText);
btn.addActionListener(this);
p.add(btn);
add("South", p);
pack();
Dimension dDim = getSize();
if (parent != null) {
Rectangle fRect = parent.getBounds();
setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
fRect.y + ((fRect.height - dDim.height) / 2));
}
}
MultiResolutionCursorTest.java 文件源码
项目:jdk8u_jdk
阅读 30
收藏 0
点赞 0
评论 0
public void start() {
//Get things going. Request focus, set size, et cetera
setSize(200, 200);
setVisible(true);
validate();
final Image image = new MultiResolutionCursor();
int center = sizes[0] / 2;
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
image, new Point(center, center), "multi-resolution cursor");
Frame frame = new Frame("Test Frame");
frame.setSize(300, 300);
frame.setLocation(300, 50);
frame.add(new Label("Move cursor here"));
frame.setCursor(cursor);
frame.setVisible(true);
}
WPrinterJob.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 26
收藏 0
点赞 0
评论 0
private void init(Component parent, String title, String message,
String buttonText) {
Panel p = new Panel();
add("Center", new Label(message));
Button btn = new Button(buttonText);
btn.addActionListener(this);
p.add(btn);
add("South", p);
pack();
Dimension dDim = getSize();
if (parent != null) {
Rectangle fRect = parent.getBounds();
setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
fRect.y + ((fRect.height - dDim.height) / 2));
}
}
MultiResolutionCursorTest.java 文件源码
项目:lookaside_java-1.8.0-openjdk
阅读 30
收藏 0
点赞 0
评论 0
public void start() {
//Get things going. Request focus, set size, et cetera
setSize(200, 200);
setVisible(true);
validate();
final Image image = new MultiResolutionCursor();
int center = sizes[0] / 2;
Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor(
image, new Point(center, center), "multi-resolution cursor");
Frame frame = new Frame("Test Frame");
frame.setSize(300, 300);
frame.setLocation(300, 50);
frame.add(new Label("Move cursor here"));
frame.setCursor(cursor);
frame.setVisible(true);
}
Demo.java 文件源码
项目:javify
阅读 24
收藏 0
点赞 0
评论 0
public void init ()
{
initted = true;
Panel p = new Panel();
p.setLayout (new GridLayout (3, 1));
((GridLayout) p.getLayout ()).setHgap (5);
((GridLayout) p.getLayout ()).setVgap (5);
p.add (new Label ("left justified label", Label.LEFT));
p.add (new Label ("center justified label", Label.CENTER));
p.add (new Label ("right justified label", Label.RIGHT));
add (p, "Center");
Button cb = new Button ("Close");
cb.addActionListener(new ActionListener () {
public void actionPerformed (ActionEvent e) {
dispose();
}
});
add (cb, "South");
setTitle ("Labels");
pack();
}
SwingLabelPeer.java 文件源码
项目:javify
阅读 20
收藏 0
点赞 0
评论 0
/**
* Sets the horizontal alignment of the label. This is implemented to
* set the alignment on the Swing label.
*
* @param alignment the horizontal alignment
*
* @see Label#LEFT
* @see Label#RIGHT
* @see Label#CENTER
*/
public void setAlignment(int alignment)
{
JLabel swingLabel = (JLabel) swingComponent.getJComponent();
switch (alignment)
{
case Label.RIGHT:
swingLabel.setHorizontalAlignment(JLabel.RIGHT);
break;
case Label.CENTER:
swingLabel.setHorizontalAlignment(JLabel.CENTER);
break;
case Label.LEFT:
default:
swingLabel.setHorizontalAlignment(JLabel.LEFT);
break;
}
}
Gui.java 文件源码
项目:CraftPlugins
阅读 30
收藏 0
点赞 0
评论 0
public static void main(String[] args) {
Label label=new Label();
JLabel jlabel=new JLabel();
Gui f = new Gui();
JTextField textField = new JTextField(20);
f.setVisible(true);
f.setSize(800,500);
f.setTitle("Blockode控制台");
f.setLayout(new FlowLayout());
label.setLocation(0, 0);
label.setText("插件日志:");
jlabel.setText(jlabel.getText()+"载入成功!");
jlabel.setBackground(Color.black);
jlabel.setLocation(10, 6);
//textField.append("1");
f.add(label);
f.add(jlabel);
f.add(textField);
//再加上这一句就可以把Frame放在最中间了
f.setLocationRelativeTo(null);
//如果没有这一句,在点击关闭Frame的时候程序其实还是在执行状态中的,加上这一句才算是真正的把资源释放掉了
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
}
TiledImageComponent.java 文件源码
项目:code-similarity
阅读 23
收藏 0
点赞 0
评论 0
/** Set things up nicely. */
public TiledImageComponent() {
setLayout(new FlowLayout());
add(new Label("Name:", Label.CENTER));
add(nameTF=new TextField(10));
add(new Label("Password:", Label.CENTER));
add(passTF=new TextField(10));
passTF.setEchoChar('*');
add(new Label("Domain:", Label.CENTER));
add(domainTF=new TextField(10));
im = getToolkit().getImage(DEFAULT_IMAGE_NAME);
}
AppletGameContainer.java 文件源码
项目:trashjam2017
阅读 31
收藏 0
点赞 0
评论 0
/**
* Create a new panel to display the console output
*
* @param e The exception causing the console to be displayed
*/
public ConsolePanel(Exception e) {
setLayout(new BorderLayout());
setBackground(Color.black);
setForeground(Color.white);
Font consoleFont = new Font("Arial", Font.BOLD, 14);
Label slickLabel = new Label("SLICK CONSOLE", Label.CENTER);
slickLabel.setFont(consoleFont);
add(slickLabel, BorderLayout.PAGE_START);
StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw));
textArea.setText(sw.toString());
textArea.setEditable(false);
add(textArea, BorderLayout.CENTER);
// add a border on both sides of the console
add(new Panel(), BorderLayout.LINE_START);
add(new Panel(), BorderLayout.LINE_END);
Panel bottomPanel = new Panel();
bottomPanel.setLayout(new GridLayout(0, 1));
Label infoLabel1 = new Label("An error occured while running the applet.", Label.CENTER);
Label infoLabel2 = new Label("Plese contact support to resolve this issue.", Label.CENTER);
infoLabel1.setFont(consoleFont);
infoLabel2.setFont(consoleFont);
bottomPanel.add(infoLabel1);
bottomPanel.add(infoLabel2);
add(bottomPanel, BorderLayout.PAGE_END);
}
LabelBeanInfo.java 文件源码
项目:incubator-netbeans
阅读 20
收藏 0
点赞 0
评论 0
/** @return Propertydescriptors */
@Override
protected PropertyDescriptor[] createPDs() throws IntrospectionException {
PropertyDescriptor[] pds = new PropertyDescriptor[] {
new PropertyDescriptor("alignment", Label.class), // NOI18N
new PropertyDescriptor("text", Label.class), // NOI18N
};
pds[0].setPropertyEditorClass(LabelBeanInfo.AlignmentPropertyEditor.class);
return pds;
}
LabelBeanInfo.java 文件源码
项目:incubator-netbeans
阅读 24
收藏 0
点赞 0
评论 0
@Override
public void setAsText(String s) {
Integer i;
getTags();
if (s.equals(tags[0])) i = new Integer(java.awt.Label.LEFT);
else if (s.equals(tags[1])) i = new Integer(java.awt.Label.CENTER);
else i = new Integer(java.awt.Label.RIGHT);
setValue(i);
}