下面列出了javax.swing.JTextArea#setEnabled ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private JPanel createNoProxyPanel() {
JPanel noProxyPanel = new VerticalPanel();
JLabel noProxyListLabel = new JLabel("No Proxy for:");
noProxyPanel.add(noProxyListLabel);
noProxyList = new JTextArea(3, 10);
noProxyList.setText(DEFAULT_NO_PROXY_LIST);
noProxyList.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
noProxyList.setEnabled(false);
noProxyPanel.add(noProxyList);
JLabel noProxyExample = new JLabel("Example: .jmeter.org, .com.au, 192.168.1.0/24");
noProxyPanel.add(noProxyExample);
return noProxyPanel;
}
private static TextAreaComponent createTextArea(int rows) {
final JTextArea rootsArea = new JTextArea();
rootsArea.setFont(new Font("Monospaced", Font.PLAIN, UIManager.getFont("Label.font").getSize())); // NOI18N
TextAreaComponent rootsAreaScrollPane = new TextAreaComponent(rootsArea,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) {
public Dimension getMinimumSize() {
return getPreferredSize();
}
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
rootsArea.setEnabled(enabled);
}
};
rootsAreaScrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));
JTextArea referenceArea = new JTextArea("X"); // NOI18N
referenceArea.setFont(rootsArea.getFont());
referenceArea.setRows(rows);
Insets insets = rootsAreaScrollPane.getInsets();
rootsAreaScrollPane.setPreferredSize(new Dimension(1, referenceArea.getPreferredSize().height +
(insets != null ? insets.top + insets.bottom : 0)));
return rootsAreaScrollPane;
}
private static TextAreaComponent createTextArea(int rows) {
final JTextArea rootsArea = new JTextArea();
rootsArea.setFont(new Font("Monospaced", Font.PLAIN, UIManager.getFont("Label.font").getSize())); // NOI18N
TextAreaComponent rootsAreaScrollPane = new TextAreaComponent(rootsArea,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) {
public Dimension getMinimumSize() {
return getPreferredSize();
}
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
rootsArea.setEnabled(enabled);
}
};
rootsAreaScrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));
JTextArea referenceArea = new JTextArea("X"); // NOI18N
referenceArea.setFont(rootsArea.getFont());
referenceArea.setRows(rows);
Insets insets = rootsAreaScrollPane.getInsets();
rootsAreaScrollPane.setPreferredSize(new Dimension(1, referenceArea.getPreferredSize().height +
(insets != null ? insets.top + insets.bottom : 0)));
return rootsAreaScrollPane;
}
private static TextAreaComponent createTextArea(int rows) {
final JTextArea rootsArea = new JTextArea();
rootsArea.setFont(new Font("Monospaced", Font.PLAIN, UIManager.getFont("Label.font").getSize())); // NOI18N
TextAreaComponent rootsAreaScrollPane = new TextAreaComponent(rootsArea,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED) {
public Dimension getMinimumSize() {
return getPreferredSize();
}
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
rootsArea.setEnabled(enabled);
}
};
rootsAreaScrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));
JTextArea referenceArea = new JTextArea("X"); // NOI18N
referenceArea.setFont(rootsArea.getFont());
referenceArea.setRows(rows);
Insets insets = rootsAreaScrollPane.getInsets();
rootsAreaScrollPane.setPreferredSize(new Dimension(1, referenceArea.getPreferredSize().height +
(insets != null ? insets.top + insets.bottom : 0)));
return rootsAreaScrollPane;
}
private JComponent createWktInputPanel() {
final JTextArea textArea = new AutoResizingTextArea(3, 30);
//Overrides behavior when set enabled
textArea.addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (textArea.isEnabled()) {
textArea.setBackground(Color.WHITE);
} else {
textArea.setBackground(new Color(240, 240, 240));
}
}
});
bindingContext.bind(BinningFormModel.PROPERTY_KEY_WKT, textArea);
bindingContext.bindEnabledState(BinningFormModel.PROPERTY_KEY_WKT, false, BinningFormModel.PROPERTY_KEY_MANUAL_WKT, false);
textArea.setEnabled(false);
return new JScrollPane(textArea);
}
private static TextAreaComponent createTextArea(int rows) {
final JTextArea rootsArea = new JTextArea();
rootsArea.setEditable(false);
rootsArea.setFont(new Font("Monospaced", Font.PLAIN, UIManager.getFont("Label.font").getSize())); // NOI18N
TextAreaComponent rootsAreaScrollPane = new TextAreaComponent(rootsArea,
JScrollPane.VERTICAL_SCROLLBAR_NEVER,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
public Dimension getMinimumSize() {
return getPreferredSize();
}
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
rootsArea.setEnabled(enabled);
}
};
rootsAreaScrollPane.setBorder(BorderFactory.createLineBorder(Color.GRAY));
JTextArea referenceArea = new JTextArea("X"); // NOI18N
referenceArea.setFont(rootsArea.getFont());
referenceArea.setRows(rows);
Insets insets = rootsAreaScrollPane.getInsets();
rootsAreaScrollPane.setPreferredSize(new Dimension(1, referenceArea.getPreferredSize().height +
(insets != null ? insets.top + insets.bottom : 0)));
return rootsAreaScrollPane;
}
/**
* Creates a text component to be used as a multi-line, automatically
* wrapping label.
* <p>
* <strong>Restriction:</strong><br>
* The component may have its preferred size very wide.
*
* @param text text of the label
* @param color desired color of the label,
* or {@code null} if the default color should be used
* @return created multi-line text component
*/
public static JTextComponent createMultilineLabel(String text, Color color) {
JTextArea textArea = new JTextArea(text);
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setEnabled(false);
textArea.setOpaque(false);
textArea.setColumns(25);
textArea.setDisabledTextColor((color != null)
? color
: new JLabel().getForeground());
return textArea;
}
public SuspendInfoPanel() {
setLayout(new java.awt.GridBagLayout());
JTextArea infoText = new JTextArea(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp"));
infoText.setEditable(false);
infoText.setEnabled(false);
infoText.setBackground(getBackground());
infoText.setDisabledTextColor(new JLabel().getForeground());
infoText.setLineWrap(true);
infoText.setWrapStyleWord(true);
infoText.setPreferredSize(
new Dimension(
infoText.getFontMetrics(infoText.getFont()).stringWidth(infoText.getText()),
infoText.getPreferredSize().height));
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
//gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
//gridBagConstraints.weightx = 1.0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
add(infoText, gridBagConstraints);
infoText.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(InstancesView.class, "MSG_NotSuspendedApp"));
JButton pauseButton = new JButton();
pauseButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doStopCurrentDebugger();
}
});
org.openide.awt.Mnemonics.setLocalizedText(pauseButton, NbBundle.getMessage(InstancesView.class, "CTL_Pause"));
pauseButton.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/debugger/resources/actions/Pause.gif", false));
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.CENTER;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
add(pauseButton, gridBagConstraints);
}
private JTextComponent createMultilineLabel(String text) {
JTextArea textArea = new JTextArea(text);
textArea.setEditable(false);
textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setEnabled(false);
textArea.setOpaque(false);
textArea.setColumns(25);
textArea.setDisabledTextColor(new JLabel().getForeground());
return textArea;
}
/**
* Creates a new {@link Note} editor.
*
* @param note The {@link Note} to edit.
*/
public NoteEditor(Note note) {
super(note);
JPanel content = new JPanel(new ColumnLayout(2, RowDistribution.GIVE_EXCESS_TO_LAST));
JLabel iconLabel = new JLabel(note.getIcon(true));
JPanel right = new JPanel(new ColumnLayout(1, RowDistribution.GIVE_EXCESS_TO_LAST));
content.add(iconLabel);
content.add(right);
mReferenceField = new JTextField(Text.makeFiller(6, 'M'));
UIUtilities.setToPreferredSizeOnly(mReferenceField);
mReferenceField.setText(note.getReference());
mReferenceField.setToolTipText(Text.wrapPlainTextForToolTip(I18n.Text("A reference to the book and page this note applies to (e.g. B22 would refer to \"Basic Set\", page 22)")));
mReferenceField.setEnabled(mIsEditable);
JPanel wrapper = new JPanel(new ColumnLayout(4));
wrapper.add(new LinkedLabel(I18n.Text("Note Content:")));
wrapper.add(new JPanel());
wrapper.add(new LinkedLabel(I18n.Text("Page Reference"), mReferenceField));
wrapper.add(mReferenceField);
right.add(wrapper);
mEditor = new JTextArea(note.getDescription());
mEditor.setLineWrap(true);
mEditor.setWrapStyleWord(true);
mEditor.setEnabled(mIsEditable);
JScrollPane scroller = new JScrollPane(mEditor, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
scroller.setMinimumSize(new Dimension(400, 300));
iconLabel.setVerticalAlignment(SwingConstants.TOP);
iconLabel.setAlignmentY(-1.0f);
right.add(scroller);
add(content);
}
@Override
protected void updateMainMessage(QOptionPane pane) {
super.updateMainMessage(pane);
JTextArea mainText = getMainMessageTextArea(pane);
Dimension mainTextSize = TextSize.getPreferredSize(mainText,
getInt(pane, KEY_MESSAGE_WIDTH));
Insets insets = getInsets(pane, KEY_MAIN_MESSAGE_INSETS);
mainTextSize.width += insets.left + insets.right;
mainTextSize.height += insets.top + insets.bottom;
mainText.setPreferredSize(mainTextSize);
mainText.setMinimumSize(mainTextSize);
mainText.setEnabled(getBoolean(pane, KEY_TEXT_EDITABLE));
mainText.setOpaque(false);
}
@Override
protected void updateSecondaryMessage(QOptionPane pane) {
super.updateSecondaryMessage(pane);
JTextArea secondaryText = getSecondaryMessageTextArea(pane);
Dimension secondaryTextSize = TextSize.getPreferredSize(secondaryText,
getInt(pane, KEY_MESSAGE_WIDTH));
Insets insets = getInsets(pane, KEY_SECONDARY_MESSAGE_INSETS);
secondaryTextSize.width += insets.left + insets.right;
secondaryTextSize.height += insets.top + insets.bottom;
secondaryText.setPreferredSize(secondaryTextSize);
secondaryText.setMinimumSize(secondaryTextSize);
secondaryText.setEnabled(getBoolean(pane, KEY_TEXT_EDITABLE));
secondaryText.setOpaque(false);
}
/**
* Creates a multiline text label, which does not support HTML
*
* @param text
* the text of the label
* @return a multi line label
*/
private static JComponent createMultiLineLabel(String text) {
JTextArea flowLabel = new JTextArea(text, 1, 0);
flowLabel.setDisabledTextColor(flowLabel.getForeground());
flowLabel.setMinimumSize(new Dimension(20, 40));
flowLabel.setBackground(null);
flowLabel.setLineWrap(true);
flowLabel.setWrapStyleWord(true);
flowLabel.setBorder(BorderFactory.createEmptyBorder());
flowLabel.setOpaque(false);
flowLabel.setEnabled(false);
return flowLabel;
}
public static JPanel createSplashPanel() {
final ImageIcon picture = IconLoader.getInstance().getAboutDialogPicture();
// Create the image panel
final JPanel imagePanel = new JPanel( new BorderLayout() );
imagePanel.setUI( new BackgroundUI( picture ) );
imagePanel.setBorder( BorderFactory.createLineBorder( Color.DARK_GRAY ) );
// Overlay the version
final JLabel versionLabel = new JLabel();
final String buildString = ReportDesignerInfo.getInstance().getVersion();
if ( buildString == null ) {
versionLabel.setText( Messages.getString( "SplashScreen.DevelopmentVersion" ) );
} else {
versionLabel.setText( buildString );
}
versionLabel.setText( Messages.getString( "SplashScreen.Version", versionLabel.getText() ) );
versionLabel.setFont( new Font( Font.SANS_SERIF, Font.BOLD, 14 ) );
versionLabel.setOpaque( false );
versionLabel.setBackground( TRANSPARENT );
versionLabel.setForeground( DARK_GREY );
versionLabel.setBorder( BORDER );
versionLabel.setBounds( XLOC, YLOC, TEXT_WIDTH, versionLabel.getPreferredSize().height );
// Overlay the license
final String year = new SimpleDateFormat( "yyyy" ).format( new Date() );
final JTextArea copyrightArea = new JTextArea( Messages.getString( "SplashScreen.Copyright", year ) );
copyrightArea.setEditable( false );
copyrightArea.setBounds( XLOC, YLOC + 20, TEXT_WIDTH, LICENSE_HEIGHT );
copyrightArea.setOpaque( false );
copyrightArea.setLineWrap( true );
copyrightArea.setWrapStyleWord( true );
copyrightArea.setFont( COPYRIGHT_FONT );
copyrightArea.setEnabled( false );
copyrightArea.setBackground( TRANSPARENT );
copyrightArea.setForeground( DARK_GREY );
copyrightArea.setBorder( BORDER );
copyrightArea.setDisabledTextColor( copyrightArea.getForeground() );
// Overlay the copyright
final JTextArea licenseArea = new JTextArea( Messages.getString( "SplashScreen.License" ) );
licenseArea.setEditable( false );
licenseArea.setBounds( XLOC, YLOC + 14 + LICENSE_HEIGHT, TEXT_WIDTH, COPYRIGHT_HEIGHT );
licenseArea.setOpaque( false );
licenseArea.setLineWrap( true );
licenseArea.setWrapStyleWord( true );
licenseArea.setFont( LICENSE_FONT );
licenseArea.setEnabled( false );
licenseArea.setBackground( TRANSPARENT );
licenseArea.setBorder( BORDER );
licenseArea.setDisabledTextColor( copyrightArea.getForeground() );
// Add all the overlays
final JPanel imagePanelOverlay = new JPanel( null );
imagePanelOverlay.setOpaque( false );
imagePanelOverlay.add( versionLabel );
imagePanelOverlay.add( copyrightArea );
imagePanelOverlay.add( licenseArea );
imagePanelOverlay.setBackground( TRANSPARENT );
imagePanel.add( imagePanelOverlay );
imagePanel.setPreferredSize( new Dimension( picture.getIconWidth(), picture.getIconHeight() ) );
return imagePanel;
}
private RouterClientTest() {
setResizable(false);
setTitle("jRUDP Client Test");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(289, 500);
setLocationRelativeTo(null);
getContentPane().setLayout(null);
try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch(Exception e) {}
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(10, 69, 263, 156);
getContentPane().add(scrollPane);
lblRecPacketQueue = new JLabel("Received Packet Queue (Front==index#0)");
scrollPane.setColumnHeaderView(lblRecPacketQueue);
JList<String> listPacketQueue = new JList<>();
listPacketQueue.setEnabled(false);
listPacketQueue.setModel(modelRecPackets);
scrollPane.setViewportView(listPacketQueue);
btnConnection = new JButton("Connect");
btnConnection.addActionListener((action)->{
if(clientInstance != null && clientInstance.isConnected()) {
disconnectWGui();
}
else {
connectWGui();
}
});
btnConnection.setBounds(10, 438, 263, 23);
getContentPane().add(btnConnection);
tfServerPort = new JTextField();
tfServerPort.setText(ST_SERVER_PORT + "");
tfServerPort.setBounds(96, 407, 177, 20);
tfServerPort.setColumns(10);
getContentPane().add(tfServerPort);
tfServerHost = new JTextField();
tfServerHost.setText(ST_SERVER_HOST);
tfServerHost.setColumns(10);
tfServerHost.setBounds(96, 376, 177, 20);
getContentPane().add(tfServerHost);
JLabel lblServerHost = new JLabel("Server Host:");
lblServerHost.setBounds(23, 379, 71, 14);
getContentPane().add(lblServerHost);
JLabel lblServerPort = new JLabel("Server Port:");
lblServerPort.setBounds(23, 410, 71, 14);
getContentPane().add(lblServerPort);
JScrollPane scrollPane_1 = new JScrollPane();
scrollPane_1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane_1.setBounds(10, 236, 263, 126);
getContentPane().add(scrollPane_1);
taConsole = new JTextArea();
taConsole.setLineWrap(true);
taConsole.setWrapStyleWord(true);
taConsole.setEditable(false);
taConsole.setBackground(Color.LIGHT_GRAY);
taConsole.setFont(new Font("SansSerif", Font.BOLD, 11));
scrollPane_1.setViewportView(taConsole);
taHandledPacket = new JTextArea();
taHandledPacket.setEditable(false);
taHandledPacket.setEnabled(false);
taHandledPacket.setFont(new Font("SansSerif", Font.BOLD, 11));
taHandledPacket.setText("Last Handled Packet:\r\nnull");
taHandledPacket.setBounds(10, 11, 263, 47);
getContentPane().add(taHandledPacket);
setVisible(true);
System.setOut(new PrintStream(new OutputStream() {
@Override
public void write(int b) throws IOException {
taConsole.append("" + (char)b);
taConsole.setSize(taConsole.getPreferredSize());
JScrollBar sb = scrollPane_1.getVerticalScrollBar();
sb.setValue( sb.getMaximum() );
}
}));
System.out.println("[INFO]Console: on");
setVisible(true);
}
/**
* @author Marian Petras
*/
static void layoutSelectResourcePanel(final Container thePanel,
final String instructionsText,
final String selectionLabelText,
final Component selectionComp,
final JButton button1,
final JButton button2) {
JTextArea instructions = new JTextArea();
JLabel lblSelection = new JLabel();
instructions.setColumns(20);
instructions.setEditable(false);
instructions.setLineWrap(true);
instructions.setText(instructionsText);
instructions.setWrapStyleWord(true);
instructions.setDisabledTextColor(new JLabel().getForeground());
instructions.setEnabled(false);
instructions.setOpaque(false);
lblSelection.setLabelFor(selectionComp);
Mnemonics.setLocalizedText(lblSelection, selectionLabelText);
JScrollPane scrollPane = new JScrollPane(selectionComp);
Container filesSelection = new JPanel();
GroupLayout layout = new GroupLayout(filesSelection);
filesSelection.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(LEADING)
.addComponent(lblSelection)
.addGroup(layout.createSequentialGroup()
.addComponent(scrollPane, 0, DEFAULT_SIZE, Integer.MAX_VALUE)
.addPreferredGap(RELATED)
.addGroup(layout.createParallelGroup(LEADING)
.addComponent(button1)
.addComponent(button2)))
);
layout.linkSize(SwingConstants.HORIZONTAL, button1, button2);
layout.setVerticalGroup(
layout.createParallelGroup(LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblSelection)
.addPreferredGap(RELATED)
.addGroup(layout.createParallelGroup(LEADING)
.addComponent(scrollPane, 0, DEFAULT_SIZE, Integer.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(button1)
.addPreferredGap(RELATED)
.addComponent(button2))))
);
LayoutStyle layoutStyle = layout.getLayoutStyle();
if (layoutStyle == null) {
layoutStyle = LayoutStyle.getInstance();
}
BorderLayout mainLayout = new BorderLayout();
thePanel.setLayout(mainLayout);
thePanel.add(instructions, BorderLayout.PAGE_START);
thePanel.add(filesSelection, BorderLayout.CENTER);
mainLayout.setVgap(layoutStyle.getPreferredGap(instructions,
lblSelection,
UNRELATED,
SwingConstants.NORTH,
thePanel));
}
public ScriptConsoleTopComponent() {
this.actionMap = new HashMap<>();
registerAction(new NewAction(this));
registerAction(new OpenAction(this));
registerAction(new SaveAction(this));
registerAction(new SaveAsAction(this));
registerAction(new RunAction(this));
registerAction(new StopAction(this));
registerAction(new HelpAction(this));
inputTextArea = new JTextArea(); // todo - replace by JIDE code editor component (nf)
inputTextArea.setWrapStyleWord(false);
inputTextArea.setTabSize(4);
inputTextArea.setRows(10);
inputTextArea.setColumns(80);
inputTextArea.setFont(new Font("Courier", Font.PLAIN, 13));
outputTextArea = new JTextArea();
outputTextArea.setWrapStyleWord(false);
outputTextArea.setTabSize(4);
outputTextArea.setRows(3);
outputTextArea.setColumns(80);
outputTextArea.setEditable(false);
outputTextArea.setBackground(Color.LIGHT_GRAY);
outputTextArea.setFont(new Font("Courier", Font.PLAIN, 13));
final JToolBar toolBar = new JToolBar("Script Console");
toolBar.setFloatable(false);
toolBar.add(getToolButton(NewAction.ID));
toolBar.add(getToolButton(OpenAction.ID));
toolBar.add(getToolButton(SaveAction.ID));
toolBar.add(getToolButton(SaveAsAction.ID));
toolBar.addSeparator();
toolBar.add(getToolButton(RunAction.ID));
toolBar.add(getToolButton(StopAction.ID));
toolBar.addSeparator();
toolBar.add(getToolButton(HelpAction.ID));
getAction(NewAction.ID).setEnabled(true);
getAction(OpenAction.ID).setEnabled(true);
getAction(SaveAction.ID).setEnabled(false);
getAction(SaveAsAction.ID).setEnabled(false);
getAction(RunAction.ID).setEnabled(false);
getAction(StopAction.ID).setEnabled(false);
getAction(HelpAction.ID).setEnabled(true);
inputTextArea.setEditable(false);
inputTextArea.setEnabled(false);
JScrollPane inputEditorScrollPane = new JScrollPane(inputTextArea);
inputEditorScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
inputEditorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JScrollPane outputEditorScrollPane = new JScrollPane(outputTextArea);
outputEditorScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
outputEditorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
JSplitPane documentPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, inputEditorScrollPane, outputEditorScrollPane);
documentPanel.setDividerLocation(0.7);
documentPanel.setBorder(null);
setLayout(new BorderLayout(4, 4));
setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
setPreferredSize(new Dimension(800, 400));
add(toolBar, BorderLayout.NORTH);
add(documentPanel, BorderLayout.CENTER);
output = new PrintWriter(new ScriptOutput(), true);
scriptManager = new ScriptManager(getClass().getClassLoader(), output);
updateTitle();
}
/** Initializes the Form */
public DDChangesPanel (String caption, final JButton processButton) {
setLayout (new java.awt.BorderLayout (0, 12));
setBorder (new EmptyBorder (12, 12, 11, 0));
JTextArea text = new JTextArea ();
text.setEnabled (false);
text.setEditable (false);
text.setDisabledTextColor (UIManager.getColor ("Label.foreground")); // NOI18N
text.setBackground (UIManager.getColor ("Label.background")); // NOI18N
text.setLineWrap (true);
text.setWrapStyleWord (true);
text.setText (caption);
add (text, "North"); // NOI18N
changesPanel = new JPanel ();
changesPanel.setLayout (new java.awt.BorderLayout (5, 5));
JLabel changesLabel = new JLabel ();
changesLabel.setText (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList"));
changesLabel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yDesc")); // NOI18N
changesPanel.add (changesLabel, "North"); // NOI18N
jScrollPane1 = new JScrollPane ();
listModel = new DefaultListModel ();
changesList = new JList (listModel);
changesList.setToolTipText (NbBundle.getMessage (DDChangesPanel.class, "HINT_ChangesList"));
changesList.setCellRenderer (new ChangesListCellRenderer ());
changesList.addListSelectionListener (new ListSelectionListener () {
public void valueChanged (ListSelectionEvent e) {
processButton.setEnabled (!changesList.isSelectionEmpty ());
}
});
changesLabel.setLabelFor (changesList);
changesLabel.setDisplayedMnemonic (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList_Mnemonic").charAt (0));
getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yPanelDesc"));
jScrollPane1.setViewportView (changesList);
changesPanel.add (jScrollPane1, "Center"); // NOI18N
add (changesPanel, "Center"); // NOI18N
}
/** Initializes the Form */
public DDChangesPanel (String caption, final JButton processButton) {
setLayout (new java.awt.BorderLayout (0, 12));
setBorder (new EmptyBorder (12, 12, 11, 0));
JTextArea text = new JTextArea ();
text.setEnabled (false);
text.setEditable (false);
text.setDisabledTextColor (UIManager.getColor ("Label.foreground")); // NOI18N
text.setBackground (UIManager.getColor ("Label.background")); // NOI18N
text.setLineWrap (true);
text.setWrapStyleWord (true);
text.setText (caption);
add (text, "North"); // NOI18N
changesPanel = new JPanel ();
changesPanel.setLayout (new java.awt.BorderLayout (5, 5));
JLabel changesLabel = new JLabel ();
changesLabel.setText (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList"));
changesLabel.getAccessibleContext ().setAccessibleDescription (NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yDesc")); // NOI18N
changesPanel.add (changesLabel, "North"); // NOI18N
jScrollPane1 = new JScrollPane ();
listModel = new DefaultListModel ();
changesList = new JList (listModel);
changesList.setToolTipText (NbBundle.getMessage (DDChangesPanel.class, "HINT_ChangesList"));
changesList.setCellRenderer (new ChangesListCellRenderer ());
changesList.addListSelectionListener (new ListSelectionListener () {
public void valueChanged (ListSelectionEvent e) {
processButton.setEnabled (!changesList.isSelectionEmpty ());
}
});
changesLabel.setLabelFor (changesList);
changesLabel.setDisplayedMnemonic (NbBundle.getMessage (DDChangesPanel.class, "LAB_ChangesList_Mnemonic").charAt (0));
getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (DDChangesPanel.class, "ACS_ChangesListA11yPanelDesc"));
jScrollPane1.setViewportView (changesList);
changesPanel.add (jScrollPane1, "Center"); // NOI18N
add (changesPanel, "Center"); // NOI18N
}
public final void createControlPanelUI() throws Exception {
layout = new GridBagLayout();
mainControlPanel = new JPanel(layout);
instructionPanel = new JPanel(layout);
testPanel = new JPanel(layout);
resultButtonPanel = new JPanel(layout);
controlPanel = new JPanel(layout);
GridBagConstraints gbc = new GridBagConstraints();
String instructions
= "1) Click on MENU using mouse "
+ "\n2) Click on MENU ITEM using mouse "
+ "\n3) Check output on textArea if equal to STRING "
+ "\n\n If correct string, press \"Pass\" "
+ "\n Otherwise, press \"Fail\" ";
instructionTextArea = new JTextArea();
instructionTextArea.setText(instructions);
instructionTextArea.setEnabled(false);
instructionTextArea.setDisabledTextColor(Color.black);
instructionTextArea.setBackground(Color.white);
instructionTextArea.setBorder(
BorderFactory.createLineBorder(Color.black));
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
instructionPanel.add(instructionTextArea, gbc);
testTextArea = new JTextArea();
testTextArea.setEnabled(true);
testTextArea.setDisabledTextColor(Color.black);
testTextArea.setBackground(Color.white);
testTextArea.setBorder(
BorderFactory.createLineBorder(Color.black));
gbc.gridx = 0;
gbc.gridy = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
testPanel.add(testTextArea, gbc);
passButton = new JButton("Pass");
passButton.setActionCommand("Pass");
passButton.addActionListener(this);
failButton = new JButton("Fail");
failButton.setActionCommand("Fail");
failButton.addActionListener(this);
gbc.gridx = 0;
gbc.gridy = 0;
resultButtonPanel.add(passButton, gbc);
gbc.gridx = 1;
gbc.gridy = 0;
resultButtonPanel.add(failButton, gbc);
gbc.gridx = 0;
gbc.gridy = 0;
mainControlPanel.add(instructionPanel, gbc);
gbc.gridx = 0;
gbc.gridy = 1;
mainControlPanel.add(testPanel, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
mainControlPanel.add(resultButtonPanel, gbc);
gbc.gridx = 0;
gbc.gridy = 3;
mainControlPanel.add(controlPanel, gbc);
mainFrame = new JFrame("Control Panel");
mainFrame.add(mainControlPanel);
menuBar = new JMenuBar();
menu = new JMenu("MENU");
menuItem = new JMenuItem("MENU ITEM");
menuItem.addActionListener((e) -> {
testTextArea.setText(TEST_STRING);
});
menu.add(menuItem);
menuBar.add(menu);
mainFrame.setJMenuBar(menuBar);
mainFrame.pack();
mainFrame.setDefaultCloseOperation(EXIT_ON_CLOSE);
mainFrame.setVisible(true);
}