Add font size dialog to shell
This commit is contained in:
parent
3219d526ed
commit
10e2b13e59
66
src/net/apocalypselabs/symat/FontOptions.form
Normal file
66
src/net/apocalypselabs/symat/FontOptions.form
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
|
<Properties>
|
||||||
|
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[110, 50]"/>
|
||||||
|
</Property>
|
||||||
|
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||||
|
<Dimension value="[110, 50]"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
<AuxValues>
|
||||||
|
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||||
|
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||||
|
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||||
|
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||||
|
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||||
|
</AuxValues>
|
||||||
|
|
||||||
|
<Layout>
|
||||||
|
<DimensionLayout dim="0">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Component id="jSpinner1" min="-2" pref="70" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
|
<EmptySpace max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
<DimensionLayout dim="1">
|
||||||
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
|
<Group type="102" alignment="0" attributes="0">
|
||||||
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
|
<Component id="jSpinner1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
<EmptySpace pref="19" max="32767" attributes="0"/>
|
||||||
|
</Group>
|
||||||
|
</Group>
|
||||||
|
</DimensionLayout>
|
||||||
|
</Layout>
|
||||||
|
<SubComponents>
|
||||||
|
<Component class="javax.swing.JSpinner" name="jSpinner1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="value" type="java.lang.Object" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||||
|
<Connection code="12" type="code"/>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="jSpinner1StateChanged"/>
|
||||||
|
</Events>
|
||||||
|
</Component>
|
||||||
|
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="pt"/>
|
||||||
|
</Properties>
|
||||||
|
</Component>
|
||||||
|
</SubComponents>
|
||||||
|
</Form>
|
116
src/net/apocalypselabs/symat/FontOptions.java
Normal file
116
src/net/apocalypselabs/symat/FontOptions.java
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
/*
|
||||||
|
* Apocalypse Laboratories
|
||||||
|
* Open Source License
|
||||||
|
*
|
||||||
|
* Source code can be used for any purpose, as long as:
|
||||||
|
* - Compiled binaries are rebranded and trademarks are not
|
||||||
|
* visible by the end user at any time, except to give
|
||||||
|
* credit to Apocalypse Laboratories, such as by showing
|
||||||
|
* "Based on <product> by Apocalypse Laboratories" or a
|
||||||
|
* similar notice;
|
||||||
|
* - You do not use the code for evil;
|
||||||
|
* - Rebranded compiled applications have significant
|
||||||
|
* differences in functionality;
|
||||||
|
* - and you provide your modified source code for download,
|
||||||
|
* under the terms of the GNU LGPL v3 or a comparable
|
||||||
|
* license.
|
||||||
|
*
|
||||||
|
* Compiled binaries cannot be redistributed or mirrored,
|
||||||
|
* unless:
|
||||||
|
* - You have written permission from Apocalypse Laboratories;
|
||||||
|
* - Downloads are not available from Apocalypse Laboratories,
|
||||||
|
* not even behind a paywall or other blocking mechanism;
|
||||||
|
* - or you have received a multi-computer license, in which
|
||||||
|
* case you should take measures to prevent unauthorized
|
||||||
|
* downloads, such as preventing download access from the
|
||||||
|
* Internet.
|
||||||
|
*/
|
||||||
|
package net.apocalypselabs.symat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Skylar
|
||||||
|
*/
|
||||||
|
public class FontOptions extends javax.swing.JPanel {
|
||||||
|
|
||||||
|
private boolean modified = false;
|
||||||
|
/**
|
||||||
|
* Creates new form FontOptions
|
||||||
|
*/
|
||||||
|
public FontOptions() {
|
||||||
|
initComponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FontOptions(int size) {
|
||||||
|
this();
|
||||||
|
jSpinner1.setValue(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is called from within the constructor to initialize the form.
|
||||||
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
|
* regenerated by the Form Editor.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
|
private void initComponents() {
|
||||||
|
|
||||||
|
jSpinner1 = new javax.swing.JSpinner();
|
||||||
|
jLabel1 = new javax.swing.JLabel();
|
||||||
|
|
||||||
|
setMinimumSize(new java.awt.Dimension(110, 50));
|
||||||
|
setPreferredSize(new java.awt.Dimension(110, 50));
|
||||||
|
|
||||||
|
jSpinner1.setValue(12);
|
||||||
|
jSpinner1.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||||
|
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||||
|
jSpinner1StateChanged(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
jLabel1.setText("pt");
|
||||||
|
|
||||||
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
|
this.setLayout(layout);
|
||||||
|
layout.setHorizontalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||||
|
.addComponent(jLabel1)
|
||||||
|
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||||
|
);
|
||||||
|
layout.setVerticalGroup(
|
||||||
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addGroup(layout.createSequentialGroup()
|
||||||
|
.addContainerGap()
|
||||||
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
|
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
|
.addComponent(jLabel1))
|
||||||
|
.addContainerGap(19, Short.MAX_VALUE))
|
||||||
|
);
|
||||||
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
|
private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner1StateChanged
|
||||||
|
if ((int)jSpinner1.getValue() <= 0) {
|
||||||
|
jSpinner1.setValue(1);
|
||||||
|
} else if ((int)jSpinner1.getValue() > 64) {
|
||||||
|
jSpinner1.setValue(64);
|
||||||
|
}
|
||||||
|
modified = true;
|
||||||
|
}//GEN-LAST:event_jSpinner1StateChanged
|
||||||
|
|
||||||
|
public int getResult() {
|
||||||
|
return (int) jSpinner1.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isModified() {
|
||||||
|
return modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JLabel jLabel1;
|
||||||
|
private javax.swing.JSpinner jSpinner1;
|
||||||
|
// End of variables declaration//GEN-END:variables
|
||||||
|
}
|
@ -51,6 +51,21 @@
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
<Menu class="javax.swing.JMenu" name="jMenu2">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Options"/>
|
||||||
|
</Properties>
|
||||||
|
<SubComponents>
|
||||||
|
<MenuItem class="javax.swing.JMenuItem" name="fontBtn">
|
||||||
|
<Properties>
|
||||||
|
<Property name="text" type="java.lang.String" value="Font size..."/>
|
||||||
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="fontBtnActionPerformed"/>
|
||||||
|
</Events>
|
||||||
|
</MenuItem>
|
||||||
|
</SubComponents>
|
||||||
|
</Menu>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
</Menu>
|
</Menu>
|
||||||
</NonVisualComponents>
|
</NonVisualComponents>
|
||||||
@ -99,16 +114,14 @@
|
|||||||
<DimensionLayout dim="1">
|
<DimensionLayout dim="1">
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="0" attributes="0">
|
||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<Component id="jScrollPane1" pref="239" max="32767" attributes="0"/>
|
<Component id="jScrollPane1" pref="245" max="32767" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="0" attributes="0">
|
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||||
<Component id="runBtn" min="-2" pref="26" max="-2" attributes="0"/>
|
|
||||||
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
|
|
||||||
<Component id="jLabel1" alignment="0" max="32767" attributes="0"/>
|
<Component id="jLabel1" alignment="0" max="32767" attributes="0"/>
|
||||||
<Component id="inputBox" alignment="0" max="32767" attributes="0"/>
|
<Component id="inputBox" alignment="0" max="32767" attributes="0"/>
|
||||||
|
<Component id="runBtn" pref="0" max="32767" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="2" pref="2" max="-2" attributes="0"/>
|
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
@ -129,7 +142,7 @@
|
|||||||
<Font name="Courier New" size="15" style="0"/>
|
<Font name="Courier New" size="15" style="0"/>
|
||||||
</Property>
|
</Property>
|
||||||
<Property name="lineWrap" type="boolean" value="true"/>
|
<Property name="lineWrap" type="boolean" value="true"/>
|
||||||
<Property name="rows" type="int" value="5"/>
|
<Property name="rows" type="int" value="2"/>
|
||||||
<Property name="tabSize" type="int" value="4"/>
|
<Property name="tabSize" type="int" value="4"/>
|
||||||
<Property name="toolTipText" type="java.lang.String" value=""/>
|
<Property name="toolTipText" type="java.lang.String" value=""/>
|
||||||
<Property name="wrapStyleWord" type="boolean" value="true"/>
|
<Property name="wrapStyleWord" type="boolean" value="true"/>
|
||||||
|
@ -30,6 +30,7 @@ package net.apocalypselabs.symat;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.text.DefaultCaret;
|
import javax.swing.text.DefaultCaret;
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set font
|
// Set font
|
||||||
int font_size = 12;
|
int font_size = 15;
|
||||||
try {
|
try {
|
||||||
font_size = Integer.valueOf(PrefStorage.getSetting("editfont"));
|
font_size = Integer.valueOf(PrefStorage.getSetting("editfont"));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -108,6 +109,8 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
|||||||
javascriptMenu = new javax.swing.JRadioButtonMenuItem();
|
javascriptMenu = new javax.swing.JRadioButtonMenuItem();
|
||||||
pythonMenu = new javax.swing.JRadioButtonMenuItem();
|
pythonMenu = new javax.swing.JRadioButtonMenuItem();
|
||||||
setDefaultLang = new javax.swing.JMenuItem();
|
setDefaultLang = new javax.swing.JMenuItem();
|
||||||
|
jMenu2 = new javax.swing.JMenu();
|
||||||
|
fontBtn = new javax.swing.JMenuItem();
|
||||||
|
|
||||||
setClosable(true);
|
setClosable(true);
|
||||||
setIconifiable(true);
|
setIconifiable(true);
|
||||||
@ -125,7 +128,7 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
|||||||
mainBox.setColumns(20);
|
mainBox.setColumns(20);
|
||||||
mainBox.setFont(new java.awt.Font("Courier New", 0, 15)); // NOI18N
|
mainBox.setFont(new java.awt.Font("Courier New", 0, 15)); // NOI18N
|
||||||
mainBox.setLineWrap(true);
|
mainBox.setLineWrap(true);
|
||||||
mainBox.setRows(5);
|
mainBox.setRows(2);
|
||||||
mainBox.setTabSize(4);
|
mainBox.setTabSize(4);
|
||||||
mainBox.setToolTipText("");
|
mainBox.setToolTipText("");
|
||||||
mainBox.setWrapStyleWord(true);
|
mainBox.setWrapStyleWord(true);
|
||||||
@ -202,6 +205,18 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
|||||||
|
|
||||||
jMenuBar1.add(langMenu);
|
jMenuBar1.add(langMenu);
|
||||||
|
|
||||||
|
jMenu2.setText("Options");
|
||||||
|
|
||||||
|
fontBtn.setText("Font size...");
|
||||||
|
fontBtn.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
fontBtnActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
jMenu2.add(fontBtn);
|
||||||
|
|
||||||
|
jMenuBar1.add(jMenu2);
|
||||||
|
|
||||||
setJMenuBar(jMenuBar1);
|
setJMenuBar(jMenuBar1);
|
||||||
|
|
||||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||||
@ -219,13 +234,12 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
|||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
|
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 245, Short.MAX_VALUE)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
||||||
.addComponent(runBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||||
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||||
.addComponent(inputBox, javax.swing.GroupLayout.Alignment.LEADING)))
|
.addComponent(inputBox, javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
|
.addComponent(runBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
|
||||||
.addGap(2, 2, 2))
|
.addGap(2, 2, 2))
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -322,6 +336,18 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
|||||||
formMouseClicked(evt);
|
formMouseClicked(evt);
|
||||||
}//GEN-LAST:event_runBtnMouseClicked
|
}//GEN-LAST:event_runBtnMouseClicked
|
||||||
|
|
||||||
|
private void fontBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fontBtnActionPerformed
|
||||||
|
FontOptions fo = new FontOptions(mainBox.getFont().getSize());
|
||||||
|
JOptionPane.showInternalMessageDialog(this,
|
||||||
|
fo,
|
||||||
|
"Font Size",
|
||||||
|
JOptionPane.PLAIN_MESSAGE);
|
||||||
|
if (fo.isModified()) {
|
||||||
|
mainBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, fo.getResult()));
|
||||||
|
inputBox.setFont(new Font(Font.MONOSPACED, Font.PLAIN, fo.getResult()));
|
||||||
|
}
|
||||||
|
}//GEN-LAST:event_fontBtnActionPerformed
|
||||||
|
|
||||||
private void doRunCode() {
|
private void doRunCode() {
|
||||||
String code = inputBox.getText();
|
String code = inputBox.getText();
|
||||||
mainBox.append(" " + code + "\n");
|
mainBox.append(" " + code + "\n");
|
||||||
@ -374,9 +400,11 @@ public class Interpreter extends javax.swing.JInternalFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
private javax.swing.JMenuItem fontBtn;
|
||||||
private javax.swing.JTextField inputBox;
|
private javax.swing.JTextField inputBox;
|
||||||
private javax.swing.JLabel jLabel1;
|
private javax.swing.JLabel jLabel1;
|
||||||
private javax.swing.JMenu jMenu1;
|
private javax.swing.JMenu jMenu1;
|
||||||
|
private javax.swing.JMenu jMenu2;
|
||||||
private javax.swing.JMenuBar jMenuBar1;
|
private javax.swing.JMenuBar jMenuBar1;
|
||||||
private javax.swing.JScrollPane jScrollPane1;
|
private javax.swing.JScrollPane jScrollPane1;
|
||||||
private javax.swing.JRadioButtonMenuItem javascriptMenu;
|
private javax.swing.JRadioButtonMenuItem javascriptMenu;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user