Dialog right painting of text
This commit is contained in:
parent
f0d333ad47
commit
5484e20bb8
@ -1,6 +1,7 @@
|
|||||||
package ruscz.game.gameOfProd.Dialog;
|
package ruscz.game.gameOfProd.Dialog;
|
||||||
|
|
||||||
import ruscz.game.gameOfProd.Image.ImageDialog;
|
import ruscz.game.gameOfProd.Image.ImageDialog;
|
||||||
|
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@ -38,20 +39,21 @@ public class Dialog {
|
|||||||
|
|
||||||
|
|
||||||
public JLabel prepareDialogBar(String string) {
|
public JLabel prepareDialogBar(String string) {
|
||||||
Font f1 = new Font("Times New Roman", Font.PLAIN, 20);
|
int cellSize = WindowOfFreeMove.CELL_SIZE;
|
||||||
|
Font f1 = new Font("Times New Roman", Font.PLAIN, cellSize / 2);
|
||||||
|
|
||||||
JLabel text = new JLabel();
|
JLabel text = new JLabel();
|
||||||
text.setText(string);
|
text.setText(string);
|
||||||
text.setFont(f1);
|
text.setFont(f1);
|
||||||
text.setForeground(Color.BLUE.darker().darker().darker().darker().darker().darker().darker().darker().darker().darker().darker().darker());
|
text.setForeground(Color.BLACK);
|
||||||
text.setVisible(true);
|
text.setVisible(true);
|
||||||
Dimension size = text.getPreferredSize();
|
Dimension size = text.getPreferredSize();
|
||||||
|
|
||||||
if (imageDialog != null) {
|
if (imageDialog != null) {
|
||||||
text.setBounds(120, 20, size.width, size.height);
|
text.setBounds(cellSize * 3, cellSize / 2, size.width, size.height);
|
||||||
dialogBar.setImageDialog(imageDialog);
|
dialogBar.setImageDialog(imageDialog);
|
||||||
} else {
|
} else {
|
||||||
text.setBounds(20, 20, size.width, size.height);
|
text.setBounds(cellSize / 2, cellSize / 2, size.width, size.height);
|
||||||
dialogBar.unsetImageDialog();
|
dialogBar.unsetImageDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +69,6 @@ public class Dialog {
|
|||||||
if (dialogBar.getComponentCount() != 0)
|
if (dialogBar.getComponentCount() != 0)
|
||||||
dialogBar.remove(0);
|
dialogBar.remove(0);
|
||||||
dialogBar.add(textToShow);
|
dialogBar.add(textToShow);
|
||||||
dialogBar.revalidate();
|
|
||||||
charNumber++;
|
charNumber++;
|
||||||
if (charNumber == textLength) {
|
if (charNumber == textLength) {
|
||||||
timer.stop();
|
timer.stop();
|
||||||
|
|||||||
@ -19,11 +19,16 @@ public class DialogBar extends JPanel {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
super.paint(g);
|
|
||||||
ImageDialog.parseBackground();
|
ImageDialog.parseBackground();
|
||||||
g.drawImage(ImageDialog.getDialogBack(), 0, 0, WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.WINDOW_WIDTH, WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.WINDOW_HEIGHT / 4, this);
|
g.drawImage(ImageDialog.getDialogBack(), 0, 0, WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.WINDOW_WIDTH,
|
||||||
|
WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.WINDOW_HEIGHT / 4, this);
|
||||||
|
|
||||||
if (imageDialog != null){
|
if (imageDialog != null){
|
||||||
g.drawImage(imageDialog.getImage(), 10, 10, 91,91, this);
|
g.drawImage(imageDialog.getImage(), WindowOfFreeMove.CELL_SIZE / 4, WindowOfFreeMove.CELL_SIZE / 4,
|
||||||
|
WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.WINDOW_HEIGHT / 4 - WindowOfFreeMove.CELL_SIZE / 2,
|
||||||
|
WindowOfFreeMove.CELL_SIZE * WindowOfFreeMove.WINDOW_HEIGHT / 4 - WindowOfFreeMove.CELL_SIZE / 2,
|
||||||
|
this);
|
||||||
}
|
}
|
||||||
|
this.paintChildren(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user