Так у меня есть два класса:JTextArea & JPanel разные классы одно окно ... возможно?
public class TimeServer extends JPanel implements TimeVariables
{
public TimeServer()
{
JTextArea serverLog = new JTextArea();
// Create a scroll pane to hold text area
JScrollPane scrollPane = new JScrollPane(serverLog);
JPanel serverWin = new JPanel();
serverWin.add(scrollPane);
}
и другой класс, который имеет:
private JPanel mainWin = new JPanel();
private JPanel gridArea = new JPanel(); //hold cells
TimeServer serverWin = new TimeServer();
public class TimClient extends JFrame implements Runnable, TimeVariables
{
his.add(mainWin, BorderLayout.CENTER);
mainWin.setLayout(new BorderLayout());
// mainWin.setLayout(new GridLayout(1,2));
//Create Grid
gridArea.setLayout(new GridLayout(10, 10, 2, 2));
for (int i = 0; i < 10; i++)
for (int j = 0; j < 10; j++)
gridArea.add(cell[i][j] = new Cell(i, j, this));
gridArea.setBorder(new LineBorder(Color.black, 1));
jlblTitle.setHorizontalAlignment(JLabel.CENTER);
jlblTitle.setFont(new Font("SansSerif", Font.BOLD, 16));
jlblTitle.setBorder(new LineBorder(Color.black, 1));
jlblStatus.setBorder(new LineBorder(Color.black, 1));
mainWin.add(gridArea, BorderLayout.CENTER);
mainWin.add(serverWin, BorderLayout.PAGE_END);
// Place the panel and the labels to the frame
setLayout(new BorderLayout()); // implicit anyway
add(jlblTitle, BorderLayout.NORTH);
add(mainWin, BorderLayout.CENTER);
add(jlblStatus, BorderLayout.SOUTH);
}
public static void main(String[] args) {
// Create a frame
TimClient frame = new TimClient("Time Client");
//frame.getContentPane().add(BorderLayout)
// Display the frame
frame.setSize(620, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
все, что я хочу сделать, это сохранить журнал сервера и сетку в JPanel рядом друг с другом, может вы объясните, как?
также Как добавить JPanel в класс сервера к одному в клиенте?
Вот набросок того, как я хотел бы, чтобы она выглядела:
Удаление содержимого вопроса не поможет никому другому в будущем ... – MadProgrammer