я закончил с добавлением JInternalFrame
внутри моего JFrame
, и способ добавления рамки - это щелкнуть значок JMenuItem
, и это идет нормально, но когда когда-либо добавляется рамка, старый компонент удаляется, и появляется белый цвет. то, что я пытаюсь сделать, это установить исправление JInternalFrame
местоположения с другим компонентом без эффекта другого компонента
код для JInternalFrame
package animeaidvlcj;
import javax.swing.JInternalFrame;
/* Used by InternalFrameDemo.java. */
public class MyInternalFrame extends JInternalFrame {
static int openFrameCount = 0;
static final int xOffset = 0, yOffset = 25;
public MyInternalFrame() {
super("Document #" + (++openFrameCount),
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
//...Create the GUI and put it in the window...
//...Then set the window size or call pack...
setSize(300,300);
//Set the window's location.
setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
}
}
Код действия
Action newAction = new AbstractAction("New", newIcon) {
@Override
public void actionPerformed(ActionEvent e) {
desktop = new JDesktopPane();
createFrame();
setContentPane(desktop);
desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
}
};
создать метод
protected void createFrame() {
MyInternalFrame frame = new MyInternalFrame();
frame.setVisible(true); //necessary as of 1.3
desktop.add(frame);
try {
frame.setSelected(true);
} catch (java.beans.PropertyVetoException e) {}
}