⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smalldisplay.java

📁 经典的货郎担问题解决办法
💻 JAVA
字号:
package com.well.www.user.xanthian.java.ui;import java.awt.*;import com.coyotegulch.ui.*;public class SmallDisplay{  private TravellerFrame m_displayFrame  = null;  private EdgedPanel     m_displayPanel  = null;  private Label          m_displayLabel  = null;  private final static String DISPLAY_SIZER =    "XXXXXXXXXXXXXXXXXXXXXXXXX";  private static String sizer( int howWide )  {    StringBuffer b = new StringBuffer();    for ( int i = 0; i < howWide; i++ )    {      b.append( "X" );    }    return b.toString();  }  public SmallDisplay() { this( "untitled", DISPLAY_SIZER ); }  public SmallDisplay( int howWide ) { this( "untitled", sizer( howWide ) ); }  public SmallDisplay( String frameTitle )  {    this( frameTitle, DISPLAY_SIZER );  }  public SmallDisplay( String frameTitle, int howWide )  {    this( frameTitle, sizer( howWide ) );  }/*** We deliberately make the main constructor _private_, because we don't** want clients trying to roll their own sizer strings; the public** constructor interfaces all defer to this one, possibly after building** a sizerString based on a user-requested width, possibly using the** default one if the user doesn't specify a width.*/  private SmallDisplay( String frameTitle, String sizerString )  {    super();/*** Make a little window in which to display the seeding count to let the** user know how much longer seeding will run.*/    // create a frame to hold the panel    m_displayFrame  = new TravellerFrame( frameTitle );    m_displayFrame.setVisible( true );/*** Offset the initial location vertically to get it out from under the** default location for visual debugging windows.  This should make** these displays easier to grab and arrange nicely on the screen*/    m_displayFrame.setLocation    (      0,      TravellerFrame.getTitleBarHeightAllowance()      + ( 2 * TravellerFrame.getFrameEdgeThickness() )      + TravellerCanvas.PADDED_DIMENSIONS.height    );    m_displayFrame.invalidate();    // create a panel to hold the label    m_displayPanel = new EdgedPanel();    m_displayPanel.setBackground( TravellerColors.BAR_COLOR );    m_displayPanel.setLayout( new FlowLayout() );    // create a font to avoid default font size    Font displayFont = new Font( "SansSerif", Font.PLAIN, 12 );    // create a label to hold the data    m_displayLabel = new Label( sizerString, Label.CENTER );    m_displayLabel.setBackground( TravellerColors.BAR_COLOR );    m_displayLabel.setForeground( TravellerColors.BAR_TEXT );    m_displayLabel.setFont( displayFont );    // put the label in the panel    m_displayPanel.add( m_displayLabel );    // put the panel in the frame    m_displayFrame.add( "Center", m_displayPanel );    m_displayFrame.pack();    // freeze the frame sizing for the label    m_displayFrame.validate();    m_displayFrame.repaint();  }  public void closeWindow()  {    if ( m_displayFrame != null )    {      m_displayFrame.windowClose();      m_displayFrame = null;    }  }  public void updateDisplay( String contents )  {    m_displayLabel.setText( contents );  }  public void toFront()  {    m_displayFrame.toFront();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -