本文整理汇总了Java中javax.swing.JLabel.setLocation方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.setLocation方法的具体用法?Java JLabel.setLocation怎么用?Java JLabel.setLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setLocation方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addEntidadEnEscenario
import javax.swing.JLabel; //导入方法依赖的package包/类
public void addEntidadEnEscenario (String rutaIcono, String idEntidad, Point puntoLoc){
JLabel label = new JLabel();
// String rutaImagen=directorioTrabajo+rutaIconos+imageniconoMujer;
// numeroRobots= escenrioSimComp.getNumRobots();
// numeroRobots++;
// intervalNumRobots.setText(""+numeroRobots);
// identEntidad=tipoEntidad+numeroRobots;
// escenrioSimComp.addRoboLoc(identEntidad, new Point(coordX,coordY));
// intervalNumRobots.setText(""+numeroRobots);
label.setText(idEntidad);
label.setBounds(10, 10, 100, 100);
this.add(label);
label.setVisible(true);
label.setIcon(new ImageIcon(rutaIcono));
label.setLocation(puntoLoc);
moverComp.registerComponent(label);
this.listaEntidadesEnEscenario.add(label);
System.out.println( "Se crea la entidad : "+label.getText()+ " Punto : =" + puntoLoc );
// tablaEntidadesEnEscenario.put(identEntidad, label);
}
示例2: MessagePreferencesPanel
import javax.swing.JLabel; //导入方法依赖的package包/类
public MessagePreferencesPanel() {
setLayout(null);
refuseMessages = new JCheckBox("Refuse Messages");
refuseMessages.setSize(150, 25);
refuseMessages.setLocation(10, 25);
refuseMessages.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
updateEnabled();
}
});
add(refuseMessages);
denyMessageLabel = new JLabel("Refusal Message:");
denyMessageLabel.setSize(150, 25);
denyMessageLabel.setLocation(20, 50);
add(denyMessageLabel);
denyMessageText = new JTextField(REFUSAL_MESSAGE_DEFAULT);
denyMessageText.setSize(400, 25);
denyMessageText.setLocation(25, 75);
add(denyMessageText);
setSize(STD_XSIZE, STD_YSIZE);
}
示例3: enterUnitOutForAnimation
import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel enterUnitOutForAnimation(final Unit unit,
final Tile sourceTile) {
Integer i = unitsOutForAnimation.get(unit);
if (i == null) {
final JLabel unitLabel = createUnitLabel(unit);
i = 1;
Point tileP = calculateTilePosition(sourceTile);
Point unitP = calculateUnitLabelPositionInTile(unitLabel.getWidth(),
unitLabel.getHeight(), tileP);
unitLabel.setLocation(unitP);
unitsOutForAnimationLabels.put(unit, unitLabel);
gui.getCanvas().add(unitLabel, JLayeredPane.DEFAULT_LAYER);
} else {
i++;
}
unitsOutForAnimation.put(unit, i);
return unitsOutForAnimationLabels.get(unit);
}
示例4: enterUnitOutForAnimation
import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel enterUnitOutForAnimation(final Unit unit,
final Tile sourceTile) {
Integer i = unitsOutForAnimation.get(unit);
if (i == null) {
final JLabel unitLabel = createUnitLabel(unit);
i = 1;
unitLabel.setLocation(calculateUnitLabelPositionInTile(
unitLabel.getWidth(), unitLabel.getHeight(),
calculateTilePosition(sourceTile)));
unitsOutForAnimationLabels.put(unit, unitLabel);
gui.getCanvas().add(unitLabel, JLayeredPane.DEFAULT_LAYER);
} else {
i++;
}
unitsOutForAnimation.put(unit, i);
return unitsOutForAnimationLabels.get(unit);
}
示例5: ProgressPanel
import javax.swing.JLabel; //导入方法依赖的package包/类
public ProgressPanel() {
setLayout(null);
progressBar = new ProgressBar();
progressBar.setLocation(PROGRESS_X_OFFSET, PROGRESS_Y_OFFSET);
progressBar.setSize(440, 10);
progressBar.setForeground(Color.blue);
add(progressBar);
textLabel = new JLabel();
textLabel.setLocation(X_TEXT_OFFSET, Y_TEXT_OFFSET);
textLabel.setSize(X_SIZE - X_TEXT_OFFSET - ADDITIONAL_X_SIZE, 20);
add(textLabel);
additionalLabel = new JLabel();
additionalLabel.setLocation(X_SIZE - ADDITIONAL_X_SIZE, Y_TEXT_OFFSET);
additionalLabel.setSize(ADDITIONAL_X_SIZE, 20);
add(additionalLabel);
}
示例6: mouseEntered
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* When the cursor hovers over a card, the card is moved to the front.
*
* @param e
*/
@Override
public void mouseEntered(MouseEvent e) {
if (game.getPhase().equals(PLAY_CARDS)) {
JLabel label = (JLabel) e.getComponent();
cardPanel.getCardsPane().setLayer(label, 1);
String card = (String) label.getClientProperty("name");
label.setIcon(new ImageIcon("src/resources/images/" + card + "_BLACK.png"));
Point p = label.getLocation();
Point p1 = new Point(p.x, HIGH_Y);
label.setLocation(p1);
cardPanel.updateUI();
}
}
示例7: mouseExited
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* When the cursor exits a card, the card is moved back to its original
* depth.
*
* @param e
*/
@Override
public void mouseExited(MouseEvent e) {
if (game.getPhase().equals(PLAY_CARDS)) {
JLabel label = (JLabel) e.getComponent();
cardPanel.getCardsPane().setLayer(label, cardPanel.getLabelLayer(label));
String card = (String) label.getClientProperty("name");
label.setIcon(new ImageIcon("src/resources/images/" + card + ".png"));
Point p = label.getLocation();
Point p1 = new Point(p.x, LOW_Y);
label.setLocation(p1);
cardPanel.updateUI();
}
}
示例8: StartUp
import javax.swing.JLabel; //导入方法依赖的package包/类
public StartUp( int which ) {
try {
URL url = null;
switch (which) {
case MapApp.MERCATOR_MAP:
url = cl.getResource(startUpPath +"smallmapV3.jpg"); //New version3 images
break;
case MapApp.SOUTH_POLAR_MAP:
url = cl.getResource(startUpPath + "MapAppSouthV3.jpg");
break;
case MapApp.NORTH_POLAR_MAP:
url = cl.getResource(startUpPath + "MapAppNorthV3.jpg");
break;
case MapApp.WORLDWIND:
url = cl.getResource(startUpPath + "VirtualOceanV3.jpg");
break;
default:
url = cl.getResource(startUpPath + "smallmap.jpg");
}
image = ImageIO.read(url);
} catch (Exception ex) {
System.out.println(ex + " null");
image=null;
}
setLayout(null);
label = new JLabel("Initializing MapApp...");
label.setFont( new Font("SansSerif", Font.PLAIN, 12) );
label.setForeground( Color.black );
// add( label );
label.setLocation(10, 50);
label.setSize( label.getPreferredSize() );
JButton button = new JButton( "Abort" );
add( button );
button.setLocation( 3, 3);
button.setSize( button.getPreferredSize() );
button.addActionListener( this );
// System.out.println( getComponentCount() + " components" );
setBorder( BorderFactory.createLineBorder(Color.black, 2) );
}
示例9: stampaCartaMobileDeckShuffle
import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel stampaCartaMobileDeckShuffle(int x, int y, String carta, int spazio) {
JLabel card = new JLabel(caricaImmagine("dominio/immagini/mazzo/" + carta + ".png"));
card.setBounds(x, y, 75, 113);
sfondo.add(card);
sfondo.repaint();
for(int i = 0; i < ((this.getWidth()/2 + 20) - x - 8*spazio); i++) {
card.setLocation(x + i, y);
pausa(1);
sfondo.repaint();
}
return card;
}
示例10: stampaCartaMobileDeckShuffle
import javax.swing.JLabel; //导入方法依赖的package包/类
private JLabel stampaCartaMobileDeckShuffle(int x, int y, String carta, int spazio) {
JLabel card = new JLabel(caricaImmagine("dominio/immagini/mazzo/" + carta + ".png"));
card.setBounds(x, y, 75, 113);
sfondo.add(card);
sfondo.repaint();
for (int i = 0; i < ((this.getWidth() / 2 + 20) - x - 8 * spazio); i++) {
card.setLocation(x + i, y);
pausa(1);
sfondo.repaint();
}
return card;
}
示例11: executeWithUnitOutForAnimation
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void executeWithUnitOutForAnimation(JLabel unitLabel) {
final SwingGUI gui = (SwingGUI)getGUI();
final float scale = gui.getMapScale();
final int movementRatio = (int)(Math.pow(2, this.speed + 1) * scale);
final Rectangle r1 = gui.getTileBounds(this.sourceTile);
final Rectangle r2 = gui.getTileBounds(this.destinationTile);
final Rectangle bounds = r1.union(r2);
final double xratio = ImageLibrary.TILE_SIZE.width
/ (double)ImageLibrary.TILE_SIZE.height;
// Tile positions should be valid at this point.
final Point srcP = gui.getTilePosition(this.sourceTile);
if (srcP == null) {
logger.warning("Failed move animation for " + this.unit
+ " at source tile: " + this.sourceTile);
return;
}
final Point dstP = gui.getTilePosition(this.destinationTile);
if (dstP == null) {
logger.warning("Failed move animation for " + this.unit
+ " at destination tile: " + this.destinationTile);
return;
}
final int labelWidth = unitLabel.getWidth();
final int labelHeight = unitLabel.getHeight();
final Point srcPoint = gui.calculateUnitLabelPositionInTile(labelWidth,
labelHeight, srcP);
final Point dstPoint = gui.calculateUnitLabelPositionInTile(labelWidth,
labelHeight, dstP);
final int stepX = (srcPoint.getX() == dstPoint.getX()) ? 0
: (srcPoint.getX() > dstPoint.getX()) ? -1 : 1;
final int stepY = (srcPoint.getY() == dstPoint.getY()) ? 0
: (srcPoint.getY() > dstPoint.getY()) ? -1 : 1;
int dropFrames = 0;
Point point = srcPoint;
while (!point.equals(dstPoint)) {
long time = System.currentTimeMillis();
point.x += stepX * xratio * movementRatio;
point.y += stepY * movementRatio;
if ((stepX < 0 && point.x < dstPoint.x)
|| (stepX > 0 && point.x > dstPoint.x)) {
point.x = dstPoint.x;
}
if ((stepY < 0 && point.y < dstPoint.y)
|| (stepY > 0 && point.y > dstPoint.y)) {
point.y = dstPoint.y;
}
if (dropFrames <= 0) {
unitLabel.setLocation(point);
gui.paintImmediatelyCanvasIn(bounds);
int timeTaken = (int)(System.currentTimeMillis()-time);
final int waitTime = ANIMATION_DELAY - timeTaken;
if (waitTime > 0) {
Utils.delay(waitTime, "Animation interrupted.");
dropFrames = 0;
} else {
dropFrames = timeTaken / ANIMATION_DELAY - 1;
}
} else {
dropFrames--;
}
}
gui.refresh();
}
示例12: crearIconoRobVict
import javax.swing.JLabel; //导入方法依赖的package包/类
public JLabel crearIconoRobVict(String tipoEntidad, int coordX, int coordY){
JLabel label = new JLabel();
int correccionX=-30;
int correccionY=-93;
// int correccionX=0;
// int correccionY=0;
coordX=coordX+correccionX;
coordY=coordY+correccionY;
String rutaImagen;
String identEntidad;
if ( tipoEntidad.startsWith("Robot")){
rutaImagen=directorioTrabajo+rutaIconos+imageniconoRobot;
numeroRobots= escenarioActualComp.getNumRobots();
// intervalNumRobots.setText(""+numeroRobots);
numeroRobots++;
identEntidad=tipoEntidad+numeroRobots;
escenarioActualComp.addRoboLoc(identEntidad, new Point(coordX,coordY));
intervalNumRobots.setText(""+numeroRobots);
// label.setText(tipoEntidad+numeroRobots);
}
else{
rutaImagen=directorioTrabajo+rutaIconos+imageniconoMujer;
mumeroVictimas= escenarioActualComp.getNumVictimas();
mumeroVictimas++;
// intervalNumVictimas.setText(""+mumeroVictimas);
identEntidad=tipoEntidad+mumeroVictimas;
escenarioActualComp.addVictimLoc(identEntidad, new Point(coordX,coordY));
// mumeroVictimas=escenrioSimComp.getNumVictimas();
intervalNumVictimas.setText(""+mumeroVictimas);
// identEntidad=tipoEntidad+mumeroVictimas;
// label.setText(tipoEntidad+mumeroVictimas);
}
label.setText(identEntidad);
label.setBounds(10, 10, 100, 100);
// label.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
// @Override
// public void mouseDragged(java.awt.event.MouseEvent evt) {
// jLabelMouseDragged(evt);
// }
// public void mouseReleased(java.awt.event.MouseEvent evt) {
// jLabelMouseReleased(evt);
// }
// });
this.add(label);
label.setVisible(true);
// label.setIcon(new ImageIcon("E:\\FicheroRed\\Github\\rosaceSIM\\src\\utilsDiseniaEscenariosRosace\\Robot.png"));
label.setIcon(new ImageIcon(rutaImagen));
label.setLocation(coordX, coordY);
this.listaEntidadesEnEscenario.add(label);
System.out.println( "Se crea la entidad : "+label.getText()+ " Coordenadas : X =" + coordX +" , Y = " +coordY );
// tablaEntidadesEnEscenario.put(identEntidad, label);
// listaEntidadesEnEscenario.add(label);
moverComp.registerComponent(label);
return label;
}
示例13: cambiarPosicionRobot
import javax.swing.JLabel; //导入方法依赖的package包/类
public synchronized void cambiarPosicionRobot(String idRobot, int nueva_coordx, int nueva_coordy) {
// String numeroRobot = getNumeroRobot(idRobot);
// System.out.println("Peticiones de cambio de posicion Robot : "+ idRobot+ " CoordX: " +nueva_coordx + " CoordY: " +nueva_coordy );
//JLabel jlabelRobot = new JLabel();
if (tablaEntidadesEnEscenario!=null){
JLabel jlabelRobot = tablaEntidadesEnEscenario.get(idRobot);
if (jlabelRobot != null) {
// JOptionPane.showMessageDialog(panelVisor, "Se llama idRobot:"+valor_idRobot+" X:"+nueva_coordx+ "Y:"+nueva_coordy);
// jlabelRobot.setBounds(jlabelRobot.getX()+10, jlabelRobot.getY()+10, jlabelRobot.getWidth(), jlabelRobot.getHeight());
// jlabelRobot.setBounds(nueva_coordx, nueva_coordy, jlabelRobot.getWidth(), jlabelRobot.getHeight());
jlabelRobot.setLocation(nueva_coordx, nueva_coordy);
// this.notifyAll();
//Eliminar de la visualizacion
// jlabelRobot.setVisible(false);
// panelVisor.remove(jlabelRobot);
//Eliminar de la variable mapa que almacena identificadores y posiciones de los robots
// robotslabel.remove(numeroRobot);
//Crear una nueva label en la nueva posicion
//crear el label y posicionarlo en el JPanel
// JLabel label = new JLabel("");
// String rutaIconoRobot = directorioTrabajo + "/" + rutassrc + rutapaqueteConstructorEscenariosROSACE + imageniconoRobot;
//
// label.setIcon(new javax.swing.ImageIcon(rutaIconoRobot));
//
// label.setText(numeroRobot);
// label.setEnabled(true);
// label.setVisible(true);
//
// Dimension size = label.getPreferredSize();
// label.setBounds(nueva_coordx, nueva_coordy, size.width, size.height);
//
// panelVisor.add(label);
//
// robotslabel.put(numeroRobot, label); //Lo anoto en el Map: la clave es el numero del robot y contenido es el label creado
// System.out.println("NUEVA Localizacion del robot " + label.getText() + "-> (" + label.getLocation().x + "," + label.getLocation().y + ")");
} else
System.out.println("jlabel nulo");
}else {
System.out.println("Tabla de robots y victimas null ");
}
// System.out.println("Localizacion del robot " + jlabelRobot.getText() + "-> " + jlabelRobot.getBounds());
// System.out.println("Localizacion del robot " + jlabelRobot.getText() + "-> " + jlabelRobot.getLocationOnScreen());
}
示例14: moveCard
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* Changes the location of the card.
*
* @param x
* @param y
* @param card
*/
public void moveCard(int x, int y, JLabel card) {
card.setLocation(x, y);
}