문제

I have a few toggle buttons to add styling to text in the form of:

    JToggleButton boldButton = new JToggleButton("Bold");
    boldButton.addActionListener(new StyledEditorKit.BoldAction());
    boldButton.setFocusable(false);

and I also have various styling functions (color, left/right/center align, etc.). What I'm wanting to do is when I call a function (in this case, I'm wanting to basically make a new document) the toggle button is toggled to the off state, and all styling returns to default.

Currently I just set the frame name to untitled (previously the name of the document I was working with), and set the pane text to "", but this keeps all of the styling I had set in the previous document. Is there a better way to do it?

Thanks

도움이 되었습니까?

해결책

boldButton.setSelected(false)

should be all you need.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top