(我说法语所以我提前道歉)
我被我的申请困住了。我正在尝试正确定位JTable,但setPostion或setBound不起作用。
这就是我得到的: Picutre
我也试过使用布局,但它没有改变任何东西。我也尝试将空布局设置为JFrame,但它导致所有内容消失。
这是JTable代码:
public class STable
{
private JTable jTable;
private Object[][] data;
private String title[];
private int x, y;
public STable(int x, int y)
{
//Location
this.x = x;
this.y = y;
}
public Object[][] getData()
{
return this.data;
}
public void setData(Object[][] data)
{
this.data = data;
}
public void setTitle(String title[])
{
this.title = title;
}
public JTable getJTable()
{
return this.jTable;
}
public JTable createTable()
{
this.jTable = new JTable(this.data, this.title);
this.jTable.setLocation(this.x, this.y);
return this.jTable;
}
}
这是我的框架:
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.app.graphics.panels.MainP;
import com.app.utils.SButton;
import com.app.utils.STable;
import com.app.utils.WindowMover;
public class MainF extends JFrame implements ActionListener
{
private static final long serialVersionUID = -3853419533053844386L;
@SuppressWarnings("unused")
private JPanel currentPanel;
private MainP panel;
private SButton exitB, hideB, homeB, userB, settingB;
private BufferedImage icon;
public MainF()
{
this.setTitle("DAMP");
this.setContentPane(this.panel = new MainP());
this.currentPanel = this.panel;
//Icon
try
{
icon = ImageIO.read(getClass().getResource("/ressources/icon.png"));
}
catch (IOException e1)
{ e1.printStackTrace(); }
this.setIconImage(icon);
this.setUndecorated(true);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(new Dimension(1080, 720));
//Move window
WindowMover mover = new WindowMover(this);
this.addMouseListener(mover);
this.addMouseMotionListener(mover);
Object[][] data = {
{"Cysboy", new JButton("6boy"), new Double(1.80), new Boolean(true)},
{"BZHHydde", new JButton("BZH"), new Double(1.78), new Boolean(false)},
{"IamBow", new JButton("BoW"), new Double(1.90), new Boolean(false)},
{"FunMan", new JButton("Year"), new Double(1.85), new Boolean(true)}
};
String title[] = {"Pseudo", "Age", "Taille", "OK ?"};
STable table = new STable(500, 500);
table.setTitle(title);
table.setData(data);
this.getContentPane().add(table.createTable());
this.exitB = new SButton(this, "exitM", 1060, 8, true);
this.hideB = new SButton(this, "hideM", 1037, 16, true);
this.homeB = new SButton(this, "home", 9, 39, true);
this.userB = new SButton(this, "user", 7, 610, true);
this.settingB = new SButton(this, "settings", 7, 670, true);
this.setVisible(true);
this.setLocationRelativeTo(null);
//Animator.fadeInFrame(this, Animator.FAST);
}
@Override
public void actionPerformed(ActionEvent e)
{
if(e.getSource().equals(exitB))
System.exit(0);
else if(e.getSource().equals(hideB))
this.setState(JFrame.ICONIFIED);
else if(e.getSource().equals(homeB))
return;
else if(e.getSource().equals(settingB))
return;
else if(e.getSource().equals(userB))
return;
}
}
如果您有任何疑问,请不要犹豫。对不起任何错误。 此致 希!